New tool: annotations from current text (fixes #862)
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 28 Sep 2010 15:42:12 +0000 (17:42 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 28 Sep 2010 15:42:12 +0000 (17:42 +0200)
15 files changed:
apps/wiki/templates/wiki/document_details.html
apps/wiki/templates/wiki/tabs/annotations_view.html [new file with mode: 0644]
apps/wiki/templates/wiki/tabs/annotations_view_item.html [new file with mode: 0644]
apps/wiki/templates/wiki/tabs/gallery_view_item.html
apps/wiki/templates/wiki/tabs/search_view_item.html
redakcja/settings/compress.py
redakcja/static/css/gallery.css
redakcja/static/css/master.css
redakcja/static/icons/image-x-generic.png [new file with mode: 0644]
redakcja/static/icons/system-search.png [new file with mode: 0644]
redakcja/static/js/wiki/loader.js
redakcja/static/js/wiki/view_annotations.js [new file with mode: 0644]
redakcja/static/js/wiki/view_editor_wysiwyg.js
redakcja/static/js/wiki/view_gallery.js
redakcja/static/js/wiki/view_search.js

index 71113b1..bdb2200 100644 (file)
@@ -24,6 +24,7 @@
 
 {% block tabs-right %}
     {% include "wiki/tabs/gallery_view_item.html" %}
 
 {% block tabs-right %}
     {% include "wiki/tabs/gallery_view_item.html" %}
+    {% include "wiki/tabs/annotations_view_item.html" %}
     {% include "wiki/tabs/search_view_item.html" %}
 {% endblock %}
 
     {% include "wiki/tabs/search_view_item.html" %}
 {% endblock %}
 
@@ -33,6 +34,7 @@
     </div>
     <div id="sidebar">
         {% include "wiki/tabs/gallery_view.html" %}
     </div>
     <div id="sidebar">
         {% include "wiki/tabs/gallery_view.html" %}
+        {% include "wiki/tabs/annotations_view.html" %}
         {% include "wiki/tabs/search_view.html" %}
     </div>
 {% endblock %}
         {% include "wiki/tabs/search_view.html" %}
     </div>
 {% endblock %}
diff --git a/apps/wiki/templates/wiki/tabs/annotations_view.html b/apps/wiki/templates/wiki/tabs/annotations_view.html
new file mode 100644 (file)
index 0000000..56c41b7
--- /dev/null
@@ -0,0 +1,13 @@
+{% load i18n %}
+<div id="side-annotations">
+    <!-- annotations toolbar -->
+    <div class="toolbar">
+        <button class="refresh">{% trans "Refresh" %}</button>
+        <div class="toolbar-end">
+        </div>
+    </div>
+    <div class="error-message">
+    </div>
+    <div class="annotations-list">
+    </div>
+</div>
diff --git a/apps/wiki/templates/wiki/tabs/annotations_view_item.html b/apps/wiki/templates/wiki/tabs/annotations_view_item.html
new file mode 100644 (file)
index 0000000..f478e12
--- /dev/null
@@ -0,0 +1,4 @@
+{% load i18n %}
+<li id="AnnotationsPerspective" data-ui-related="side-annotations" data-ui-jsclass="AnnotationsPerspective">
+    <super title="{% trans "Annotations" %}">[1]</super>
+</li>
index 7325c82..20505d6 100644 (file)
@@ -1,4 +1,4 @@
 {% load i18n %}
 <li id="ScanGalleryPerspective" data-ui-related="side-gallery" data-ui-jsclass="ScanGalleryPerspective" class='active'>
 {% load i18n %}
 <li id="ScanGalleryPerspective" data-ui-related="side-gallery" data-ui-jsclass="ScanGalleryPerspective" class='active'>
-    <span>{% trans "Gallery" %}</span>
+    <img src="{{STATIC_URL}}icons/image-x-generic.png" alt="{% trans "Gallery" %}" title="{% trans "Gallery" %}" />
 </li>
 </li>
index dbd4e09..7acfaac 100644 (file)
@@ -1,4 +1,4 @@
 {% load i18n %}
 <li id="SearchPerspective" data-ui-related="side-search" data-ui-jsclass="SearchPerspective">
 {% load i18n %}
 <li id="SearchPerspective" data-ui-related="side-search" data-ui-jsclass="SearchPerspective">
-    <span>{% trans "Search and replace" %}</span>
+    <img src="{{STATIC_URL}}icons/system-search.png" alt="{% trans "Search and replace" %}" title="{% trans "Search and replace" %}" />
 </li>
 </li>
index 5e8d721..2ce6ac9 100644 (file)
@@ -51,6 +51,7 @@ COMPRESS_JS = {
                 'js/wiki/view_editor_source.js',
                 'js/wiki/view_editor_wysiwyg.js',
                 'js/wiki/view_gallery.js',
                 'js/wiki/view_editor_source.js',
                 'js/wiki/view_editor_wysiwyg.js',
                 'js/wiki/view_gallery.js',
+                'js/wiki/view_annotations.js',
                 'js/wiki/view_search.js',
                 'js/wiki/view_column_diff.js',
         ),
                 'js/wiki/view_search.js',
                 'js/wiki/view_column_diff.js',
         ),
index 9c6e3a5..1274321 100644 (file)
     padding: .5em;
 }
 
     padding: .5em;
 }
 
+#side-annotations {
+    display: none;
+}
+
+.annotations-list {
+    position: absolute;
+    left: 0;
+    top: 28px;
+    right: 0;
+    bottom: 0;
+    overflow: auto;
+    padding: 1em 1em 0 1em;
+}
+
+#side-annotations p.akap {
+    font-size: 16px;
+    font-family: "Georgia", "Times New Roman", serif;
+    line-height: 1.5em;
+    margin-bottom: 1em;
+}
+
 /* =========== */
 /* = Gallery = */
 /* =========== */
 /* =========== */
 /* = Gallery = */
 /* =========== */
index bc62274..b71520f 100644 (file)
@@ -149,7 +149,6 @@ body {
 }
 
 .tabs li {
 }
 
 .tabs li {
-       height: 18px;
        margin-top: 6px;
        margin-bottom: 0px;
 
        margin-top: 6px;
        margin-bottom: 0px;
 
@@ -158,10 +157,6 @@ body {
     display: block;
     float: left;
 
     display: block;
     float: left;
 
-       padding-left: 12px;
-       padding-right: 12px;
-       padding-top: 5px;
-
     font-weight: bold;
     color: #222;
     margin-left: 4px;
     font-weight: bold;
     color: #222;
     margin-left: 4px;
@@ -179,10 +174,27 @@ body {
     -webkit-border-bottom-right-radius: 0px;
 }
 
     -webkit-border-bottom-right-radius: 0px;
 }
 
+#tabs li {
+    height: 18px;
+    padding-left: 12px;
+    padding-right: 12px;
+    padding-top: 5px;
+}
+
 .tabs li.active {
     background-color: #C1C1C1;
 }
 
 .tabs li.active {
     background-color: #C1C1C1;
 }
 
+
+#tabs-right li {
+    height: 20px;
+    padding-left: 12px;
+    padding-right: 12px;
+    padding-top: 3px;
+}
+
+
+
 #tools {
        float: right;
        clear: right;
 #tools {
        float: right;
        clear: right;
diff --git a/redakcja/static/icons/image-x-generic.png b/redakcja/static/icons/image-x-generic.png
new file mode 100644 (file)
index 0000000..68da502
Binary files /dev/null and b/redakcja/static/icons/image-x-generic.png differ
diff --git a/redakcja/static/icons/system-search.png b/redakcja/static/icons/system-search.png
new file mode 100644 (file)
index 0000000..fd7f0b0
Binary files /dev/null and b/redakcja/static/icons/system-search.png differ
index f051511..eb535a1 100644 (file)
@@ -69,10 +69,12 @@ $(function()
                                $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
                                $('#sidebar').hide();
                                $('.vsplitbar').css('right', 0).removeClass('active');
                                $.wiki.state.perspectives.ScanGalleryPerspective.show = false;
                                $('#sidebar').hide();
                                $('.vsplitbar').css('right', 0).removeClass('active');
-                               if($(".vsplitbar-title").html() == "↓&nbsp;SEARCH&nbsp;AND&nbsp;REPLACE&nbsp;↓"){
-                                       $(".vsplitbar-title").html("&uarr;&nbsp;SEARCH&nbsp;AND&nbsp;REPLACE&nbsp;&uarr;");        
-                               } else {
-                                   $(".vsplitbar-title").html("&uarr;&nbsp;GALLERY&nbsp;&uarr;");
+                               if($(".vsplitbar-title").html() == "↓&nbsp;ZNAJDŹ&nbsp;I&nbsp;ZAMIEŃ&nbsp;↓"){
+                                       $(".vsplitbar-title").html("&uarr;&nbsp;ZNAJDŹ&nbsp;I&nbsp;ZAMIEŃ&nbsp;&uarr;");        
+                               } else if($(".vsplitbar-title").html() == "↓&nbsp;PRZYPISY&nbsp;↓"){
+                        $(".vsplitbar-title").html("&uarr;&nbsp;PRZYPISY&nbsp;&uarr;");        
+                } else {
+                                   $(".vsplitbar-title").html("&uarr;&nbsp;GALERIA&nbsp;&uarr;");
                                }
                                $('#editor .editor').css('right', 30);
                                $(window).resize();
                                }
                                $('#editor .editor').css('right', 30);
                                $(window).resize();
diff --git a/redakcja/static/js/wiki/view_annotations.js b/redakcja/static/js/wiki/view_annotations.js
new file mode 100644 (file)
index 0000000..d51ce9c
--- /dev/null
@@ -0,0 +1,114 @@
+(function($){
+
+    /*
+     * Perspective
+     */
+    function AnnotationsPerspective(options){
+        var old_callback = options.callback || function() { };
+
+        this.noupdate_hash_onenter = true;
+
+        options.callback = function(){
+            var self = this;
+
+            this.$element = $("#side-annotations");
+            this.$error = $('.error-message', this.$element);
+            this.$annos = $('.annotations-list', this.$element);
+            $('.refresh', this.$element).click(function() {
+                self.refresh(self);
+            });
+
+                       old_callback.call(this);
+        };
+
+        $.wiki.Perspective.call(this, options);
+    };
+
+    AnnotationsPerspective.prototype = new $.wiki.Perspective();
+
+    AnnotationsPerspective.prototype.refresh = function(self) {
+        var xml;
+
+        persp = $.wiki.activePerspective();
+        if (persp == 'CodeMirrorPerspective') {
+            xml = $.wiki.perspectives[persp].codemirror.getCode();
+        }
+        else if (persp == 'VisualPerspective') {
+            html2text({
+                element: $('#html-view div').get(0),
+                success: function(text){
+                    xml = text;
+                },
+                error: function(text){
+                    self.$error.html('<p>Wystąpił błąd:</p><pre>' + text + '</pre>');
+                }
+            });
+        }
+        else {
+            xml = this.doc.text;
+        }
+        
+        var parser = new DOMParser();
+        var serializer = new XMLSerializer();
+        var doc = parser.parseFromString(xml, 'text/xml');
+        var error = $('parsererror', doc);
+
+        if (error.length > 0) {
+            self.$error.html('Błąd parsowania XML.');
+            self.$error.show();
+            self.$annos.hide();
+        }
+        else {
+            self.$error.hide();
+            self.$annos.hide();
+            self.$annos.html('');
+            var anno_list = new Array();
+            var annos = doc.getElementsByTagName('pe');
+            var counter = annos.length;
+
+            for (var i=0; i<annos.length; i++)
+            {
+                text = serializer.serializeToString(annos[i]).replace(/<(\/?)pe[^>]*>/g, "<$1akap>");
+                xml2html({
+                    xml: text,
+                    success: function(elem){
+                        elem.txt = $(elem).text().trim();
+                        anno_list.push(elem);
+                        counter--;
+
+                        if (!counter) {
+                            anno_list.sort(function(a, b){return (a.txt < b.txt) ? -1 : (a.txt > b.txt ? 1 : 0)});
+                            self.$annos.append(anno_list);
+                            self.$annos.show();
+                        }
+                    },
+                    error: function(text) {
+                        $.unblockUI();
+                        self.$error.html(text);
+                        self.$error.show();
+                    }
+                });
+            }
+        }
+    }
+
+
+    AnnotationsPerspective.prototype.onEnter = function(success, failure){
+        var self = this;
+
+        $.wiki.Perspective.prototype.onEnter.call(this);
+
+        $('.vsplitbar').not('.active').trigger('click');
+        $(".vsplitbar-title").html("&darr;&nbsp;PRZYPISY&nbsp;&darr;");        
+
+        this.refresh(this);
+
+    };
+
+       AnnotationsPerspective.prototype.onExit = function(success, failure) {
+
+       };
+
+    $.wiki.AnnotationsPerspective = AnnotationsPerspective;
+
+})(jQuery);
index dc24aea..2beb4d4 100644 (file)
                 _finalize(success);
             },
             error: function(text, source){
                 _finalize(success);
             },
             error: function(text, source){
-                $('#html-view').html('<p class="error">Wystąpił błąd:</p><p>'+text+'</p><pre>'+source.replace(/&/g, '&amp;').replace(/</g, '&lt;')+'</pre>');
+                err = '<p class="error">Wystąpił błąd:</p><p>'+text+'</p>';
+                if (source)
+                    err += '<pre>'+source.replace(/&/g, '&amp;').replace(/</g, '&lt;')+'</pre>'
+                $('#html-view').html(err);
                 _finalize(failure);
             }
         });
                 _finalize(failure);
             }
         });
index 4f6b8a1..9630afb 100644 (file)
         $.wiki.Perspective.prototype.onEnter.call(this);
 
         $('.vsplitbar').not('.active').trigger('click');
         $.wiki.Perspective.prototype.onEnter.call(this);
 
         $('.vsplitbar').not('.active').trigger('click');
-        $(".vsplitbar-title").html("&darr;&nbsp;GALLERY&nbsp;&darr;");        
+        $(".vsplitbar-title").html("&darr;&nbsp;GALERIA&nbsp;&darr;");        
         
         this.doc.refreshGallery({
             success: function(doc, data){
         
         this.doc.refreshGallery({
             success: function(doc, data){
index 789a961..15f8e2e 100644 (file)
@@ -99,7 +99,7 @@
         self.$searchCursor = null;
 
         $('.vsplitbar').not('.active').trigger('click');
         self.$searchCursor = null;
 
         $('.vsplitbar').not('.active').trigger('click');
-        $(".vsplitbar-title").html("&darr;&nbsp;SEARCH&nbsp;AND&nbsp;REPLACE&nbsp;&darr;");        
+        $(".vsplitbar-title").html("&darr;&nbsp;ZNAJDŹ&nbsp;I&nbsp;ZAMIEŃ&nbsp;&darr;");        
         
         if ($.wiki.activePerspective() != 'CodeMirrorPerspective')
             $.wiki.switchToTab('#CodeMirrorPerspective');
         
         if ($.wiki.activePerspective() != 'CodeMirrorPerspective')
             $.wiki.switchToTab('#CodeMirrorPerspective');