From: Łukasz Rekucki Date: Wed, 21 Oct 2009 21:27:20 +0000 (+0200) Subject: Roznosci. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/0600fa257660dd107bada5971b3296b3244fea03 Roznosci. --- diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index aef1e9c1..d510aa4a 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -305,7 +305,7 @@ class DocumentHTMLHandler(BaseHandler): 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)', }) @@ -313,6 +313,9 @@ class DocumentHTMLHandler(BaseHandler): 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 }) diff --git a/apps/api/handlers/text_handler.py b/apps/api/handlers/text_handler.py index 5e34ab4d..31f958da 100644 --- a/apps/api/handlers/text_handler.py +++ b/apps/api/handlers/text_handler.py @@ -71,7 +71,7 @@ class DocumentTextHandler(BaseHandler): if xchunk is None: return response.EntityNotFound().django_response({ - 'reason': 'no-part-in-document', + 'reason': 'no-chunk-in-document', 'path': chunk }) diff --git a/apps/api/views.py b/apps/api/views.py index b96fc470..a8118028 100644 --- a/apps/api/views.py +++ b/apps/api/views.py @@ -1,6 +1,10 @@ # 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 @@ -12,17 +16,16 @@ def render(request): 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'
\n', data) + data = u'%s' % LINE_SWAP_EXPR.sub(u'
\n', data) + log.info(data) doc = etree.parse( StringIO(data) ) opts = { @@ -31,11 +34,7 @@ def render(request): '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 diff --git a/apps/explorer/views.py b/apps/explorer/views.py index eff1b044..b17b8c8e 100644 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -53,7 +53,7 @@ def file_list(request): }) @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 diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index fcc111e9..105f05a7 100644 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -1,5 +1,9 @@ /* 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; @@ -70,19 +74,6 @@ 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; } @@ -150,7 +141,7 @@ } .htmlview .strofa { - margin: 1.5em 0 0; + margin: 1.5em 0 0 auto; } .htmlview .kwestia .strofa { @@ -233,6 +224,39 @@ 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; diff --git a/platforma/static/js/app.js b/platforma/static/js/app.js index ec19ee3c..e870a387 100644 --- a/platforma/static/js/app.js +++ b/platforma/static/js/app.js @@ -198,6 +198,10 @@ function parseXHRError(response) 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"; diff --git a/platforma/static/js/models.js b/platforma/static/js/models.js index d1486402..f945238d 100644 --- a/platforma/static/js/models.js +++ b/platforma/static/js/models.js @@ -246,8 +246,8 @@ Editor.HTMLModel = Editor.Model.extend({ 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; @@ -268,7 +268,7 @@ Editor.HTMLModel = Editor.Model.extend({ var path = elem.attr('wl2o:path'); this.xmlParts[path] = data; - this.set('state', 'unsynced'); + this.set('state', 'dirty'); /* re-render the changed fragment */ $.ajax({ @@ -277,11 +277,11 @@ Editor.HTMLModel = Editor.Model.extend({ 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'); } });