return error
return librarian.html.transform(document.data('xml'), is_file=False, \
- parse_dublincore=False, stylesheet=stylesheet,\
+ parse_dublincore=False, stylesheet='full',\
options={
"with-paths": 'boolean(1)',
})
except (EntryNotFound, RevisionNotFound), e:
return response.EntityNotFound().django_response({
'reason': 'not-found', 'message': e.message})
+ except librarian.ValidationError, e:
+ return response.InternalError().django_response({
+ 'reason': 'xml-non-valid', 'message': e.message })
except librarian.ParseError, e:
return response.InternalError().django_response({
'reason': 'xml-parse-error', 'message': e.message })
if xchunk is None:
return response.EntityNotFound().django_response({
- 'reason': 'no-part-in-document',
+ 'reason': 'no-chunk-in-document',
'path': chunk
})
# Create your views here.
+import logging
+log = logging.getLogger('platforma.render')
+
from django.http import HttpResponse
+import librarian
from librarian import html
from lxml import etree
from StringIO import StringIO
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)
- tag, pos = match.groups()
-
- print "Redner:", path, base, tag, pos
+ tag, pos = match.groups()
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 = {
'base-offset': pos,
}
- print 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
})
@permission_required('api.document.can_add')
-def file_upload(request, repo):
+def file_upload(request):
from api.resources import library_resource
from api.forms import DocumentUploadForm
from django.http import HttpRequest, HttpResponseRedirect
/* Style widoku HTML. Nie należy tu ustawiać position ani marginesów */
+
+@namespace wl2o "";
+
.htmlview {
+ counter-reset: main;
font-size: 16px;
font-family: "Georgia", "Times New Roman", serif;
line-height: 1.5em;
text-align: left;
}
-.htmlview .annotation {
- font-style: normal;
- font-weight: normal;
- font-size: 12px;
-}
-
-.htmlview #footnotes .annotation {
- display: block;
- float: left;
- width: 2.5em;
- clear: both;
-}
-
.htmlview #footnotes div {
margin: 1.5em 0 0 0;
}
}
.htmlview .strofa {
- margin: 1.5em 0 0;
+ margin: 1.5em 0 0 auto;
}
.htmlview .kwestia .strofa {
margin: 1em;
}
+/* Przypisy */
+.htmlview .annotation {
+ vertical-align: super;
+ text-decoration: none;
+ font-size: 0.66em;
+}
+
+.htmlview a:hover {
+ text-decoration: none;
+}
+
+/* .htmlview .annotation:before {
+ content: "[\2217]";
+} */
+
+.htmlview span.annotation:before {
+ content: "[" counter(main) "]";
+ counter-increment: main;
+}
+
+.htmlview *[wl2o\:editable] {
+ background-color: pink;
+}
+
+.htmlview *[wl2o\:editable] *[wl2o\:editable] {
+ background-color: red;
+}
+
+
+.htmlview .annotation:hover {
+ background-color: #dfdfdf;
+}
+
.parse-warning .message {
color: purple;
font-weight: bold;
level = "warning";
}
+ else if(json.reason == 'xml-non-valid') {
+ message = json.message;
+ level = "warning";
+ }
else {
message = json.message || json.reason || "Nieznany błąd :((";
level = "error";
data: {
revision: this.get('revision'),
user: this.document.get('user'),
- chunk: path,
- format: 'nl'
+ chunk: path
+ // format: 'nl'
},
success: function(data) {
self.xmlParts[path] = data;
var path = elem.attr('wl2o:path');
this.xmlParts[path] = data;
- this.set('state', 'unsynced');
+ this.set('state', 'dirty');
/* re-render the changed fragment */
$.ajax({
dataType: 'text; charset=utf-8',
data: {
fragment: data,
- chunk: path,
- format: 'nl'
+ chunk: path
+ // format: 'nl'
},
success: function(htmldata) {
- elem.replaceWith(htmldata);
+ elem.html(htmldata);
self.set('state', 'dirty');
}
});