From: Lukasz Rekucki Date: Mon, 2 Nov 2009 22:54:12 +0000 (+0100) Subject: Client-side XSLT renderer prototype. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/8705c980a8a35af6c4fc6e309f389bc1aae0b6d7?ds=sidebyside Client-side XSLT renderer prototype. --- diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index f97ff6ca..27ff47d3 100755 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -21,7 +21,7 @@ import librarian.html import difflib from librarian import dcparser, parser -from wlrepo import * +import wlrepo from api.models import PullRequest from explorer.models import GalleryForDocument @@ -157,7 +157,7 @@ class LibraryHandler(BaseHandler): import traceback # rollback branch creation lib._rollback() - raise LibraryException(traceback.format_exc()) + raise wlrepo.LibraryException(traceback.format_exc()) url = reverse('document_view', args=[doc.id]) @@ -169,12 +169,12 @@ class LibraryHandler(BaseHandler): url = url ) finally: lock.release() - except LibraryException, e: + except wlrepo.LibraryException, e: import traceback return response.InternalError().django_response({ "reason": traceback.format_exc() }) - except DocumentAlreadyExists: + except wlrepo.DocumentAlreadyExists: # Document is already there return response.EntityConflict().django_response({ "reason": "already-exists", @@ -191,7 +191,7 @@ class BasicDocumentHandler(AnonymousBaseHandler): def read(self, request, docid, lib): try: doc = lib.document(docid) - except RevisionNotFound: + except wlrepo.RevisionNotFound: return rc.NOT_FOUND result = { @@ -250,7 +250,7 @@ class DocumentHandler(BaseHandler): try: doc = lib.document(docid, user, rev=rev) - except RevisionMismatch, e: + except wlrepo.RevisionMismatch, e: # the document exists, but the revision is bad return response.EntityNotFound().django_response({ 'reason': 'revision-mismatch', @@ -258,7 +258,7 @@ class DocumentHandler(BaseHandler): 'docid': docid, 'user': user, }) - except RevisionNotFound, e: + except wlrepo.RevisionNotFound, e: # the user doesn't have this document checked out # or some other weird error occured # try to do the checkout @@ -278,7 +278,7 @@ class DocumentHandler(BaseHandler): 'docid': docid, 'user': user, }) - except RevisionNotFound, e: + except wlrepo.RevisionNotFound, e: return response.EntityNotFound().django_response({ 'reason': 'document-not-found', 'message': e.message, @@ -341,7 +341,7 @@ class DocumentHTMLHandler(BaseHandler): "with-paths": 'boolean(1)', }) - except (EntryNotFound, RevisionNotFound), e: + except (wlrepo.EntryNotFound, wlrepo.RevisionNotFound), e: return response.EntityNotFound().django_response({ 'reason': 'not-found', 'message': e.message}) except librarian.ValidationError, e: diff --git a/apps/explorer/views.py b/apps/explorer/views.py old mode 100644 new mode 100755 index 2c9b17da..46cdd4ee --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -116,3 +116,11 @@ def pull_requests(request): return direct_to_template(request, 'manager/pull_request.html', extra_context = {'objects': objects} ) + + +# +# Testing +# +def renderer_test(request): + return direct_to_template(request, 'renderer.html', mimetype="text/html", + extra_context = {} ) \ No newline at end of file diff --git a/platforma/static/js/views/html.js b/platforma/static/js/views/html.js index e1c7b15e..cefd0d2b 100755 --- a/platforma/static/js/views/html.js +++ b/platforma/static/js/views/html.js @@ -328,10 +328,8 @@ var HTMLView = View.extend({ var random = Math.floor(4000000000*Math.random()); var id = (''+date) + '-' + (''+random); - var ipoint = document.createRange(); + var ipoint = document.createRange(); - - // Firefox alters the later node when inserting, so // insert from end ipoint.setStart(range.endContainer, range.endOffset); diff --git a/platforma/static/xsl/wl2html_client.xsl b/platforma/static/xsl/wl2html_client.xsl new file mode 100755 index 00000000..85ff4a38 --- /dev/null +++ b/platforma/static/xsl/wl2html_client.xsl @@ -0,0 +1,591 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + + + +

+ + + +

+
+ + + + +

+ + + +

+
+ + + + +

+ + + +

+
+ + + + +

+ + + +

+
+ + + + + +
+ + + +
+
+ + + + +
+ + + +
+
+ + + + +
+ + + +
+
+ + + +

+ + + +

+
+ + + + +
+ + + +
+
+ + + +

+ + + +

+
+ + + +

+ + + +

+
+ + + + + + + +

+ + + +

+
+ + + + +

+ + + +

+
+ + + + +

+ + + +

+
+ + + + + +

+ + + +

+
+ + + +

+ + + +

+
+ + + + + +

+ + + +

+
+ + + +

+ + + +

+
+ + + + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + +
+ + + +
+
+ + + + + +

+ + + +

+
+ + + +

+ + + +

+
+ + + +

+ + + +

+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +

+ + + + + +

+
+ +

+ + + + + +

+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/platforma/templates/base.html b/platforma/templates/base.html old mode 100644 new mode 100755 index 590825a1..50c7bfec --- a/platforma/templates/base.html +++ b/platforma/templates/base.html @@ -21,9 +21,8 @@
{% block message-box %} {% endblock %}
-
{% block maincontent %} {% endblock %}
- +
{% block maincontent %} {% endblock %}
+ {% block extrabody %}{% endblock %} - diff --git a/platforma/templates/renderer.html b/platforma/templates/renderer.html new file mode 100755 index 00000000..dabf3381 --- /dev/null +++ b/platforma/templates/renderer.html @@ -0,0 +1,123 @@ +{% extends "base.html" %} + +{% block extrahead %} + +{% endblock %} + +{% block maincontent %} + +

Source

+ + +

Rendered

+ + + + + +
+
+
+
+{% endblock %} + +{% block extrabody %} + +{% endblock %} \ No newline at end of file diff --git a/platforma/urls.py b/platforma/urls.py old mode 100644 new mode 100755 index 786a6538..8a56210d --- a/platforma/urls.py +++ b/platforma/urls.py @@ -13,6 +13,8 @@ urlpatterns = patterns('', url(r'^$', 'explorer.views.file_list', name='file_list'), url(r'^file/upload', 'explorer.views.file_upload', name='file_upload'), + url(r'^renderer$', 'explorer.views.renderer_test'), + url(r'^management/pull-requests$', 'explorer.views.pull_requests'), # Editor panels @@ -25,6 +27,8 @@ urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/(.*)', admin.site.root), + + # Our über-restful api url(r'^api/', include('api.urls')),