From: Lukasz Rekucki Date: Sun, 8 Nov 2009 13:31:12 +0000 (+0100) Subject: Zapis na serwer na Gecko/Webkit/Opera. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/4607903456ce2c96d5c40d72c603093ef02f5d29?ds=sidebyside;hp=--cc Zapis na serwer na Gecko/Webkit/Opera. --- 4607903456ce2c96d5c40d72c603093ef02f5d29 diff --git a/apps/explorer/views.py b/apps/explorer/views.py index 46cdd4ee..fd99f27e 100755 --- a/apps/explorer/views.py +++ b/apps/explorer/views.py @@ -11,6 +11,8 @@ from django.core.urlresolvers import reverse from django.http import HttpResponse from django.utils import simplejson as json from django.views.generic.simple import direct_to_template +from django.shortcuts import render_to_response +from django.template import RequestContext from django.contrib.auth.decorators import login_required from api.models import PullRequest @@ -29,11 +31,13 @@ def ajax_login_required(view): def display_editor(request, path): user = request.GET.get('user', request.user.username) log.info(user) - - return direct_to_template(request, 'explorer/editor.html', extra_context={ + + return render_to_response('explorer/editor.html', + mimetype="text/html", + dictionary = { 'fileid': path, 'euser': user - }) + }, context_instance=RequestContext(request)) # # View all files @@ -122,5 +126,5 @@ def pull_requests(request): # Testing # def renderer_test(request): - return direct_to_template(request, 'renderer.html', mimetype="text/html", + return direct_to_template(request, 'renderer.html', mimetype="application/xhtml+xml", extra_context = {} ) \ No newline at end of file diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index 5d4e08c2..acbeac2c 100755 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -225,11 +225,11 @@ /* = Footnotes and themes = */ /* ======================== */ -.htmlview .theme-begin, .htmlview .theme-end { +.htmlview .begin, .htmlview .end { background: green; } -.htmlview .theme-ref { +.htmlview .motyw { position: absolute; right: -8em; @@ -299,7 +299,7 @@ padding: 3px 5px; text-decoration: none; - z-index: 10; + z-index: 11; } diff --git a/platforma/static/js/lib/codemirror/codemirror.js b/platforma/static/js/lib/codemirror/codemirror.js old mode 100644 new mode 100755 index 97e2657b..4eb5fb73 --- a/platforma/static/js/lib/codemirror/codemirror.js +++ b/platforma/static/js/lib/codemirror/codemirror.js @@ -55,9 +55,9 @@ var CodeMirror = (function(){ function wrapLineNumberDiv(place) { return function(node) { - var container = document.createElement("DIV"), - nums = document.createElement("DIV"), - scroller = document.createElement("DIV"); + var container = document.createElement("div"), + nums = document.createElement("div"), + scroller = document.createElement("div"); container.style.position = "relative"; nums.style.position = "absolute"; nums.style.height = "100%"; @@ -98,7 +98,7 @@ var CodeMirror = (function(){ function update() { var diff = 20 + Math.max(doc.body.offsetHeight, frame.offsetHeight) - scroller.offsetHeight; for (var n = Math.ceil(diff / 10); n > 0; n--) { - var div = document.createElement("DIV"); + var div = document.createElement("div"); div.appendChild(document.createTextNode(nextNum++)); scroller.appendChild(div); } @@ -120,7 +120,7 @@ var CodeMirror = (function(){ this.options = options = options || {}; setDefaults(options, CodeMirrorConfig); - var frame = this.frame = document.createElement("IFRAME"); + var frame = this.frame = document.createElement("iframe"); if (options.iframeClass) frame.className = options.iframeClass; frame.frameBorder = 0; frame.src = "javascript:false;"; diff --git a/platforma/static/js/models.js b/platforma/static/js/models.js index d2869ede..d0e7df13 100755 --- a/platforma/static/js/models.js +++ b/platforma/static/js/models.js @@ -99,16 +99,19 @@ Editor.HTMLModel = Editor.Model.extend({ }, asWLML: function(element) - { - var result = this.wlmlXSL.transformToFragment(element, document); + { + console.log("Source", element); + var doc = this.parser.parseFromString(this.serializer.serializeToString(element), 'text/xml'); + + var result = this.wlmlXSL.transformToDocument(doc); if(!result) { - console.log(this.wlmlXSL.transformToDocument(element)); + console.log("Failed", this.wlmlXSL, doc); throw "Failed to transform fragment"; } - console.log("Transform result:", result); - return this.serializer.serializeToString(result); + console.log("Transformed", doc, " to: ", result.documentElement); + return this.serializer.serializeToString(result.documentElement); }, updateWithWLML: function($element, text) @@ -131,6 +134,7 @@ Editor.HTMLModel = Editor.Model.extend({ throw "WLML->HTML transformation failed."; $element.replaceWith(result); + this.set('state', 'dirty'); }, createXSLT: function(xslt_doc) { @@ -201,20 +205,23 @@ Editor.HTMLModel = Editor.Model.extend({ save: function(message) { if (this.get('state') == 'dirty') { - this.set('state', 'updating'); - messageCenter.addMessage('info', 'xmlsave', 'Zapisuję XML...'); + this.set('state', 'saving'); + + messageCenter.addMessage('info', 'htmlsave', 'Zapisuję HTML...'); + var wlml = this.asWLML(this.get('data')); var payload = { - contents: this.get('data'), + contents: wlml, revision: this.get('revision'), user: this.document.get('user') }; + if (message) { payload.message = message; } $.ajax({ - url: this.serverURL, + url: this.textURL, type: 'post', dataType: 'json', data: payload, @@ -227,19 +234,19 @@ Editor.HTMLModel = Editor.Model.extend({ }, saveSucceeded: function(data) { - if (this.get('state') != 'updating') { + if (this.get('state') != 'saving') { alert('erroneous state:', this.get('state')); } this.set('revision', data.revision); this.set('state', 'updated'); - messageCenter.addMessage('success', 'xmlsave', 'Zapisałem XML :-)'); + messageCenter.addMessage('success', 'htmlsave', 'Zapisałem :-)'); }, saveFailed: function() { - if (this.get('state') != 'updating') { + if (this.get('state') != 'saving') { alert('erroneous state:', this.get('state')); } - messageCenter.addMessage('error', 'xmlsave', 'Nie udało mi się zapisać XML. Spróbuj ponownie :-('); + messageCenter.addMessage('error', 'htmlsave', 'Nie udało mi się zapisać.'); this.set('state', 'dirty'); }, diff --git a/platforma/static/js/views/html.js b/platforma/static/js/views/html.js index 8aff5f06..0b1234ce 100755 --- a/platforma/static/js/views/html.js +++ b/platforma/static/js/views/html.js @@ -106,9 +106,17 @@ var HTMLView = View.extend({ this.$docbase = $('.htmlview', this.element); this.$addThemeButton = $('.htmlview-toolbar .html-add-motive', this.element); + this.$debugButton = $('.htmlview-toolbar .html-serialize', this.element); + this.updatePrintLink(); this.$docbase.bind('click', this.itemClicked.bind(this)); this.$addThemeButton.click( this.addTheme.bind(this) ); + this.$debugButton.click( this.serialized.bind(this) ); + }, + + serialized: function() { + this.model.set('state', 'dirty'); + console.log( this.model.serializer.serializeToString(this.model.get('data')) ); }, renderPart: function($e, html) { @@ -360,7 +368,7 @@ var HTMLView = View.extend({ { var range = selection.getRangeAt(i); console.log(i, range.startContainer, range.endContainer); - var date = Date.now(); + var date = (new Date()).getTime(); var random = Math.floor(4000000000*Math.random()); var id = (''+date) + '-' + (''+random); @@ -372,17 +380,20 @@ var HTMLView = View.extend({ // insert theme-ref - var elem = $('Nowy motyw'); - elem.attr('x-attrib-id', 'm'+id); + var elem = $('Nowy motyw'); + elem.attr('x-attr-qname-'+id, 'id'); + elem.attr('x-attr-value-'+id, 'm'+id); spoint.insertNode(elem[0]); // insert theme-begin - elem = $(''); - elem.attr('x-attrib-id', 'b'+id); + elem = $(''); + elem.attr('x-attr-qname-'+id, 'id'); + elem.attr('x-attr-value-'+id, 'b'+id); spoint.insertNode(elem[0]); - elem = $(''); - elem.attr('x-attrib-id', 'e'+id); + elem = $(''); + elem.attr('x-attr-qname-'+id, 'id'); + elem.attr('x-attr-value-'+id, 'e'+id); epoint.insertNode(elem[0]); } diff --git a/platforma/static/xsl/html2wl_client.xsl b/platforma/static/xsl/html2wl_client.xsl index d92a4d3e..726a404a 100755 --- a/platforma/static/xsl/html2wl_client.xsl +++ b/platforma/static/xsl/html2wl_client.xsl @@ -1,56 +1,93 @@ + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/" +> - + + --> + + + + + + + + - + - + - - + + + - + - - - - - + - + - / + / - - - - / + + / + + + + + + + - - - + + + + + + + + + + + + + + + + + - / - - - + + + + + + / - + + + / + + + \ No newline at end of file diff --git a/platforma/static/xsl/wl2html_client.xsl b/platforma/static/xsl/wl2html_client.xsl index 7a7da8c4..234ea5cf 100755 --- a/platforma/static/xsl/wl2html_client.xsl +++ b/platforma/static/xsl/wl2html_client.xsl @@ -5,7 +5,7 @@ - + @@ -25,9 +25,12 @@ --> - - - +
+ + + + +
-

+

+ @@ -110,7 +118,8 @@ --> -

+

+ @@ -133,7 +142,8 @@ --> -

+

+ @@ -157,7 +167,8 @@ --> -

+

+ @@ -173,7 +184,8 @@ -
+
+ @@ -186,7 +198,8 @@ --> -
+
+ @@ -199,16 +212,18 @@ --> -
+
+ - +
-

+

+ @@ -224,7 +239,8 @@ --> -

+
+ @@ -233,7 +249,8 @@ -

+

+ @@ -243,7 +260,24 @@ -

+

+ + + + + +

+
+ + + + +

+ @@ -264,7 +298,8 @@ --> -

+

+ @@ -278,7 +313,8 @@ --> -

+

+ @@ -292,7 +328,8 @@ --> -

+

+ @@ -310,7 +347,8 @@ -

+

+ @@ -320,7 +358,8 @@ -

+

+ @@ -335,7 +374,8 @@ -

+

+ @@ -345,7 +385,8 @@ -

+

+ @@ -361,7 +402,8 @@ -
+
+ @@ -370,7 +412,8 @@ -
+
+ @@ -379,7 +422,8 @@ -
+
+ @@ -388,16 +432,18 @@ -
+
+ - +
-
+
+ @@ -406,7 +452,8 @@ -
+
+ @@ -421,7 +468,8 @@ -

+

+ @@ -431,7 +479,8 @@ -

+

+ @@ -441,7 +490,8 @@ -

+

+ @@ -455,8 +505,10 @@ ******** --> -

+
+ + @@ -485,42 +537,41 @@ - + + - -

- - + + +

+ -

-

- - - - - -

-
- -
+ + + + +
- - +

+ + +

- + + / + - + + @@ -545,7 +597,8 @@ - + + @@ -559,22 +612,22 @@ --> -
+

-
+
-
+
-
+
- + + + + @@ -602,21 +658,29 @@ - - + + + + + + + + + - - + + + - - + + @@ -631,18 +695,29 @@ - - - - - - + +
+ + + + + +
+ + + + +
+
+ -
+ + Unmatched tag + @@ -655,9 +730,24 @@ - + + + + + + + + + + + - + + + + + + diff --git a/platforma/templates/base.html b/platforma/templates/base.html index 50c7bfec..597a4320 100755 --- a/platforma/templates/base.html +++ b/platforma/templates/base.html @@ -1,6 +1,6 @@ - + {% block title %}Platforma Redakcyjna{% block subtitle %}{% endblock subtitle %}{% endblock title%} @@ -24,5 +24,6 @@
{% block maincontent %} {% endblock %}
{% block extrabody %}{% endblock %} + http://192.168.56.2:8000/editor/mickiewicz__pan_tadeusz__ksi%C4%99ga_1/ diff --git a/platforma/templates/explorer/editor.html b/platforma/templates/explorer/editor.html index 247f59ca..f6a76307 100755 --- a/platforma/templates/explorer/editor.html +++ b/platforma/templates/explorer/editor.html @@ -65,6 +65,7 @@
{% trans "Print version" %} +
diff --git a/platforma/templates/renderer.html b/platforma/templates/renderer.html index dabf3381..84de36d6 100755 --- a/platforma/templates/renderer.html +++ b/platforma/templates/renderer.html @@ -1,29 +1,46 @@ {% extends "base.html" %} {% block extrahead %} - + + {% endblock %} {% block maincontent %} -

Source

- - -

Rendered

- - - - - -
-
-
-
+ +
{% endblock %} {% block extrabody %} + +{% comment %} + +{% endcomment %} {% endblock %} \ No newline at end of file