* Better "motto" display.
authorŁukasz Rekucki <lrekucki@gmail.com>
Sun, 18 Apr 2010 10:15:34 +0000 (12:15 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Sun, 18 Apr 2010 10:15:34 +0000 (12:15 +0200)
* Had to hack on codemirror, to make line numbers bar resize properly.

apps/wiki/templates/wiki/summary_view.html
apps/wiki/views.py
lib/vstorage.py
platforma/static/css/html.css
platforma/static/css/summary.css
platforma/static/img/sample_cover.png [new file with mode: 0644]
platforma/static/js/lib/codemirror/codemirror.js
platforma/static/js/wiki/loader.js
platforma/static/js/wiki/view_editor_source.js
platforma/static/xsl/wl2html_client.xsl

index 9835e63..f6dd3de 100644 (file)
@@ -2,7 +2,7 @@
     <!-- <div class="toolbar">
     </div> -->
     <div id="summary-view">
-               <img class="book-cover" src="{{MEDIA_URL}}images/empty.png">
+               <img class="book-cover" src="{{STATIC_URL}}img/sample_cover.png">
 
                <h2>
                        <label for="title">Tytuł:</label>
index 8269339..9b7d807 100644 (file)
@@ -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]))
 
index f348074..24d5ec9 100644 (file)
@@ -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):
index ba0f853..bd710a8 100644 (file)
 }
 
 /* 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
index 8fe3e73..8fac6e1 100644 (file)
@@ -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 (file)
index 0000000..eb7e7d1
Binary files /dev/null and b/platforma/static/img/sample_cover.png differ
index 4eb5fb7..1020217 100644 (file)
@@ -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) {
index 62eb25e..34305d7 100644 (file)
@@ -110,9 +110,7 @@ $(function()
                                $('#loading-overlay').fadeOut();
                                alert("FAILURE");
                        }
-               });
-
-               $(window).resize();
+               });             
     }; /* end of initialize() */
 
        var initAll = function(a, f) {
index 9dffaf0..0acd2cd 100644 (file)
                                },
                                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;
                                        $('.toolbar select').change();
 
                                        console.log("Initialized CodeMirror");
+                                       
                                        // textarea is no longer needed
                                        $('codemirror_placeholder').remove();
+                                       
                                        old_callback.call(self);
                                }
                        });
        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();
        }
 
index a5db5a1..6dd5080 100644 (file)
     -->
     <xsl:template match="motto">
         <xsl:param name="mixed" />
+        <div class="motto_container">
         <div x-editable="true">
             <xsl:call-template name="standard-attributes" />
             <xsl:apply-templates select="child::node()">
                 <xsl:with-param name="mixed" select="true()" />
-            </xsl:apply-templates>
+            </xsl:apply-templates>            
+        </div>
+        <xsl:apply-templates select="following-sibling::*[1][self::motto_podpis]" mode="motto">
+            <xsl:with-param name="mixed" select="true()" />
+        </xsl:apply-templates>
         </div>
     </xsl:template>
 
-    <xsl:template match="motto_podpis">
+    <!--  
+        Catch stand-alone "motto_podpis" and make then render properly.
+        If not, editing will fail :(.
+        
+        TODO: Make "motto" & "motto_podpis" one block in edit mode (like strofa) 
+    -->
+    <xsl:template match="motto_podpis[not(preceding-sibling::*[1][self::motto])]">
+       <xsl:apply-templates select="." mode="motto">
+            <xsl:with-param name="mixed" select="true()" />
+        </xsl:apply-templates>
+    </xsl:template>        
+        
+    <xsl:template match="motto_podpis" mode="motto">
         <xsl:param name="mixed" />
         <p x-editable="true">
             <xsl:call-template name="standard-attributes" />
                 <xsl:with-param name="mixed" select="true()" />
             </xsl:apply-templates>
         </p>
-    </xsl:template>
+    </xsl:template>    
+    
+    <xsl:template match="motto_podpis" />
+    
+    
 
     <!--
         Tagi obejmujące listę osób poprzedzającą tekst dramatu