From d64a8451dafc98e8f71455a55d123d22f3368ef9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Sun, 18 Apr 2010 12:15:34 +0200 Subject: [PATCH] * Better "motto" display. * Had to hack on codemirror, to make line numbers bar resize properly. --- apps/wiki/templates/wiki/summary_view.html | 2 +- apps/wiki/views.py | 3 +- lib/vstorage.py | 4 ++ platforma/static/css/html.css | 56 ++++++++++-------- platforma/static/css/summary.css | 14 +++-- platforma/static/img/sample_cover.png | Bin 0 -> 2819 bytes .../static/js/lib/codemirror/codemirror.js | 23 ++----- platforma/static/js/wiki/loader.js | 4 +- .../static/js/wiki/view_editor_source.js | 17 +++++- platforma/static/xsl/wl2html_client.xsl | 27 ++++++++- 10 files changed, 91 insertions(+), 59 deletions(-) create mode 100644 platforma/static/img/sample_cover.png diff --git a/apps/wiki/templates/wiki/summary_view.html b/apps/wiki/templates/wiki/summary_view.html index 9835e632..f6dd3de0 100644 --- a/apps/wiki/templates/wiki/summary_view.html +++ b/apps/wiki/templates/wiki/summary_view.html @@ -2,7 +2,7 @@
- +

diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 82693393..9b7d8076 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -42,9 +42,10 @@ def document_list(request, template_name='wiki/document_list.html'): @never_cache def document_detail(request, name, template_name='wiki/document_details.html'): + storage = getstorage() try: - document = getstorage().get(name) + document = storage.get(name) except DocumentNotFound: return http.HttpResponseRedirect(reverse("wiki_create_missing", args=[name])) diff --git a/lib/vstorage.py b/lib/vstorage.py index f3480744..24d5ec9d 100644 --- a/lib/vstorage.py +++ b/lib/vstorage.py @@ -269,6 +269,10 @@ class VersionedStorage(object): def page_text(self, title, revision=None): """Read unicode text of a page.""" ctx = self._find_filectx(title, revision) + + if ctx is None: + raise DocumentNotFound(title) + return ctx.data().decode(self.charset, 'replace'), ctx.filerev() def page_text_by_tag(self, title, tag): diff --git a/platforma/static/css/html.css b/platforma/static/css/html.css index ba0f8535..bd710a8c 100644 --- a/platforma/static/css/html.css +++ b/platforma/static/css/html.css @@ -159,33 +159,27 @@ } /* wersy */ -.htmlview .strofa .wers_wciety, .htmlview .strofa .wers_wciety[data-wlf-typ = -'1'] { +.htmlview .strofa .wers_wciety, .htmlview .strofa .wers_wciety[data-wlf-typ='1'] { margin-left: 1em; } -.htmlview .strofa .wers_wciety[data-wlf-typ = -'2'] { +.htmlview .strofa .wers_wciety[data-wlf-typ='2'], .htmlview .strofa .wers_cd { margin-left: 2em; } -.htmlview .strofa .wers_wciety[data-wlf-typ = -'3'] { +.htmlview .strofa .wers_wciety[data-wlf-typ='3'] { margin-left: 3em; } -.htmlview .strofa .wers_wciety[data-wlf-typ = -'4'] { +.htmlview .strofa .wers_wciety[data-wlf-typ='4'] { margin-left: 4em; } -.htmlview .strofa .wers_wciety[data-wlf-typ = -'5'] { +.htmlview .strofa .wers_wciety[data-wlf-typ='5'] { margin-left: 5em; } -.htmlview .strofa .wers_wciety[data-wlf-typ = -'6'] { +.htmlview .strofa .wers_wciety[data-wlf-typ='6'] { margin-left: 6em; } @@ -213,15 +207,21 @@ not(.strofa) > *[x-verse]::after { margin: 1.5em 0 0; } +.htmlview .motto_container { + display: inline-block; + margin: 1.5em 0 0; + clear: right; +} + .htmlview .motto { text-align: justify; - font-style: italic; - margin: 1.5em 0 0; + font-style: italic; } .htmlview p.motto_podpis { - font-size: 0.875em; - text-align: right; + position: relative; + right: -3em; + text-align: right; } .htmlview div.fragment { @@ -300,9 +300,10 @@ not(.strofa) > *[x-verse]::after { max-height: 24pt; margin-left: 0.5em; overflow: hidden; + z-index: 500; } -.utwor > .uwaga { +div[x-node] > .uwaga { float: none; padding: 0.5em 1em; margin: 1em; @@ -314,6 +315,10 @@ not(.strofa) > *[x-verse]::after { max-height: 100%; } +.htmlview .annotation-inline-box .uwaga { + max-height: 100%; +} + /* Motywy */ /* ======================== */ /* = Footnotes and themes = */ @@ -356,15 +361,12 @@ not(.strofa) > *[x-verse]::after { * Przypisy */ /* Znaczniki w tekście */ -.htmlview .annotation { - vertical-align: super; - text-decoration: none; - /* font-size: 10px; */ -} - .htmlview .annotation:before { content: "[" counter(main) "]"; counter-increment: main; + vertical-align: super; + text-decoration: none; + font-size: 66%; } .htmlview .annotation:hover { @@ -394,7 +396,7 @@ not(.strofa) > *[x-verse]::after { -webkit-border-radius: 10px; padding: 3px 5px; text-decoration: none; - z-index: 1000; + z-index: 600; } /* @@ -465,7 +467,9 @@ not(.strofa) > *[x-verse]::after { left: 70px; } -.edit-button:hover, .edit-button:active, .delete-button:hover, .delete-button:active, .accept-button:hover, .accept-button:active { +.edit-button:hover, .edit-button:active, +.delete-button:hover, .delete-button:active, +.accept-button:hover, .accept-button:active { /* color: #FFF;*/ background-color: #999; color: #FFF; @@ -562,4 +566,4 @@ not(.strofa) > *[x-verse]::after { margin: -0.25em; padding: 0.25em; border: 1px solid orange; -} +} \ No newline at end of file diff --git a/platforma/static/css/summary.css b/platforma/static/css/summary.css index 8fe3e73d..8fac6e1b 100644 --- a/platforma/static/css/summary.css +++ b/platforma/static/css/summary.css @@ -9,11 +9,13 @@ #summary-view .book-cover { float: left; margin: 1em; - min-height: 300px; - min-width: 240px; + margin-right: 2em; - max-height: 300px; - max-width: 240px; + height: 300px; + width: 212px; + + + border: 1px dashed black; } #summary-view p { @@ -23,3 +25,7 @@ #summary-view label { font-weight: bold; } + +#summary-view .book-cover { + +} diff --git a/platforma/static/img/sample_cover.png b/platforma/static/img/sample_cover.png new file mode 100644 index 0000000000000000000000000000000000000000..eb7e7d13725c5dcbd8a4f0c18373619472c8414e GIT binary patch literal 2819 zcmcImS2UcB7X5TaiD)APlRw%ZY7!AdbR#jNMXy0bw22lXdiN{IXo(s!Vu()2jLuKW zU?xn2(fLImL`lXd*S#+fcZw<8kP{>X0sw#$W~66+h9m%> zlVd$=fMSMT#xtM`G&j@%YKJebo(*hBBild#VCVg3(E<5|f@dU45X?lMh0Mqel41H3 zIq~s~x)7vq6Qt|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Lhn$KwswxMwKW;HE_tU{BK#$+-2(-(g9Cz3FPu3JeH zxS{ea8tEW-`#fv?bS%jB`4)4OU7o1} z|AV8S6F*;t=jm+c6WSlAQxkTPUdInN9ra3heSka=(Ch2jp^nBlyw)rXWpd(3`bO*u z>sFF+h4(XL=K1OOxM`}w4mrk~Rv$x!n1|DcD2%G*8K_%;vhxwU5TWL4 z;f9iDgh*h6t)q_!Zw_zHjiXoz^!3z_!@kdW{`HaPyqV{Ysx|@!a-PrB+mk-~uW1cH zjT6kSsB}?GkNw-TbIV>08?JrG=)C7)!cPqg0{tby`KqSMUIsa+^iGvDyJlje>~C2cGoQ z$=^_)bi^BU#C5!FlwL2MKIyhzr5pf-(-&-9`z^PFP@3OI7 z^;Y{2em6JB)Zjew%)x}*@*105k}!#Nymm}l-Q>*EWopof0H$%{{GIimk@wVS2phbY zIk$^!LzB1{?bVN>B~RRO{sQ0CWB?40*7yqPwNPb(c$>ore-L(MG|L4mq_!NkA}yGg z(nRn5{wjA$ma^0c`}%1K*gYKHIA%^5)mm#3HeTPUTZ+uxJMmUkJdT`Mp%FVqaia1c zR773|Z^kL9#8TyD+pYPVgKF1HvGQj-_6`HdU|X~RQyY1GJ+$M9B(;1?;(Ot0)g9EgMD5GpNGt2;y?N~NgkqXKOj7V<%S}x=S)=(!k}-DI%le%agt)Uk^VI5kgiVjzzu{RQ!u2`*mJc~ rtwTfQeppDIVB20juibwLb^BUnP)$6JaasQ?paL*`xL&P}OYA=Y%)?K} literal 0 HcmV?d00001 diff --git a/platforma/static/js/lib/codemirror/codemirror.js b/platforma/static/js/lib/codemirror/codemirror.js index 4eb5fb73..10202174 100644 --- a/platforma/static/js/lib/codemirror/codemirror.js +++ b/platforma/static/js/lib/codemirror/codemirror.js @@ -79,22 +79,8 @@ var CodeMirror = (function(){ var win = frame.contentWindow, doc = win.document, nums = frame.nextSibling, scroller = nums.firstChild; - var nextNum = 1, barWidth = null; - function sizeBar() { - if (!frame.offsetWidth || !win.Editor) { - for (var cur = frame; cur.parentNode; cur = cur.parentNode) { - if (cur != document) { - clearInterval(sizeInterval); - return; - } - } - } - - if (nums.offsetWidth != barWidth) { - barWidth = nums.offsetWidth; - nums.style.left = "-" + (frame.parentNode.style.marginLeft = barWidth + "px"); - } - } + var nextNum = 1; + function update() { var diff = 20 + Math.max(doc.body.offsetHeight, frame.offsetHeight) - scroller.offsetHeight; for (var n = Math.ceil(diff / 10); n > 0; n--) { @@ -104,11 +90,10 @@ var CodeMirror = (function(){ } nums.scrollTop = doc.body.scrollTop || doc.documentElement.scrollTop || 0; } - sizeBar(); + update(); win.addEventHandler(win, "scroll", update); - win.addEventHandler(win, "resize", update); - var sizeInterval = setInterval(sizeBar, 500); + win.addEventHandler(win, "resize", update); } function CodeMirror(place, options) { diff --git a/platforma/static/js/wiki/loader.js b/platforma/static/js/wiki/loader.js index 62eb25ec..34305d71 100644 --- a/platforma/static/js/wiki/loader.js +++ b/platforma/static/js/wiki/loader.js @@ -110,9 +110,7 @@ $(function() $('#loading-overlay').fadeOut(); alert("FAILURE"); } - }); - - $(window).resize(); + }); }; /* end of initialize() */ var initAll = function(a, f) { diff --git a/platforma/static/js/wiki/view_editor_source.js b/platforma/static/js/wiki/view_editor_source.js index 9dffaf04..0acd2cd9 100644 --- a/platforma/static/js/wiki/view_editor_source.js +++ b/platforma/static/js/wiki/view_editor_source.js @@ -16,13 +16,13 @@ }, iframeClass: 'xml-iframe', textWrapping: true, - lineNumbers: false, + lineNumbers: true, width: "100%", tabMode: 'spaces', indentUnit: 0, initCallback: function(){ - self.codemirror.grabKeys(function(event) { + self.codemirror.grabKeys(function(event) { if (event.button) { $(event.button).trigger('click'); event.button = null; @@ -62,8 +62,10 @@ $('.toolbar select').change(); console.log("Initialized CodeMirror"); + // textarea is no longer needed $('codemirror_placeholder').remove(); + old_callback.call(self); } }); @@ -78,12 +80,23 @@ CodeMirrorPerspective.prototype.freezeState = function() { }; + + CodeMirrorPerspective.prototype.onEnter = function(success, failure) { $.wiki.Perspective.prototype.onEnter.call(this); console.log('Entering', this.doc); this.codemirror.setCode(this.doc.text); + + /* fix line numbers bar */ + var $nums = $('.CodeMirror-line-numbers'); + var barWidth = $nums.width(); + + $(this.codemirror.frame).css('margin-left', barWidth); + $nums.css('left', -barWidth); + + $(this.codemirror.frame.contentWindow).trigger('resize'); if(success) success(); } diff --git a/platforma/static/xsl/wl2html_client.xsl b/platforma/static/xsl/wl2html_client.xsl index a5db5a1c..6dd50806 100644 --- a/platforma/static/xsl/wl2html_client.xsl +++ b/platforma/static/xsl/wl2html_client.xsl @@ -209,15 +209,32 @@ --> +
- + +
+ + +
- + + + + + + + +

@@ -226,7 +243,11 @@

-
+
+ + + +