fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usunięcie różowego kolorku w tle elementów blokowych oraz zwiększenie czcionki, którą...
[redakcja.git]
/
apps
/
api
/
views.py
diff --git
a/apps/api/views.py
b/apps/api/views.py
index
b96fc47
..
a811802
100644
(file)
--- a/
apps/api/views.py
+++ b/
apps/api/views.py
@@
-1,6
+1,10
@@
# Create your views here.
# Create your views here.
+import logging
+log = logging.getLogger('platforma.render')
+
from django.http import HttpResponse
from django.http import HttpResponse
+import librarian
from librarian import html
from lxml import etree
from StringIO import StringIO
from librarian import html
from lxml import etree
from StringIO import StringIO
@@
-12,17
+16,16
@@
def render(request):
style_filename = html.get_stylesheet('partial')
data = request.POST['fragment']
style_filename = html.get_stylesheet('partial')
data = request.POST['fragment']
- path = request.POST['
part
']
+ path = request.POST['
chunk
']
base, me = path.rsplit('/', 1)
match = re.match(r'([^\[]+)\[(\d+)\]', me)
base, me = path.rsplit('/', 1)
match = re.match(r'([^\[]+)\[(\d+)\]', me)
- tag, pos = match.groups()
-
- print "Redner:", path, base, tag, pos
+ tag, pos = match.groups()
style = etree.parse(style_filename)
style = etree.parse(style_filename)
- data = LINE_SWAP_EXPR.sub(u'<br />\n', data)
+ data = u'<chunk>%s</chunk>' % LINE_SWAP_EXPR.sub(u'<br />\n', data)
+ log.info(data)
doc = etree.parse( StringIO(data) )
opts = {
doc = etree.parse( StringIO(data) )
opts = {
@@
-31,11
+34,7
@@
def render(request):
'base-offset': pos,
}
'base-offset': pos,
}
- print opts
-
result = doc.xslt(style, **opts)
result = doc.xslt(style, **opts)
-
- print result
-
- return HttpResponse(
- etree.tostring(result, encoding=unicode, pretty_print=True) )
\ No newline at end of file
+ log.info( str(doc), str(result) )
+
+ return HttpResponse( librarian.serialize_children(result.getroot()) )
\ No newline at end of file