From: Radek Czajka Date: Tue, 28 Sep 2010 15:42:12 +0000 (+0200) Subject: New tool: annotations from current text (fixes #862) X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/b5f8d214ba00903379f8716ef563f19743a120b6 New tool: annotations from current text (fixes #862) --- diff --git a/apps/wiki/templates/wiki/document_details.html b/apps/wiki/templates/wiki/document_details.html index 71113b17..bdb22007 100644 --- a/apps/wiki/templates/wiki/document_details.html +++ b/apps/wiki/templates/wiki/document_details.html @@ -24,6 +24,7 @@ {% 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 %} @@ -33,6 +34,7 @@ {% 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 index 00000000..56c41b72 --- /dev/null +++ b/apps/wiki/templates/wiki/tabs/annotations_view.html @@ -0,0 +1,13 @@ +{% load i18n %} +
+ +
+ +
+
+
+
+
+
+
+
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 index 00000000..f478e123 --- /dev/null +++ b/apps/wiki/templates/wiki/tabs/annotations_view_item.html @@ -0,0 +1,4 @@ +{% load i18n %} +
  • + [1] +
  • diff --git a/apps/wiki/templates/wiki/tabs/gallery_view_item.html b/apps/wiki/templates/wiki/tabs/gallery_view_item.html index 7325c825..20505d66 100644 --- a/apps/wiki/templates/wiki/tabs/gallery_view_item.html +++ b/apps/wiki/templates/wiki/tabs/gallery_view_item.html @@ -1,4 +1,4 @@ {% load i18n %}
  • - {% trans "Gallery" %} + {% trans
  • diff --git a/apps/wiki/templates/wiki/tabs/search_view_item.html b/apps/wiki/templates/wiki/tabs/search_view_item.html index dbd4e09a..7acfaacb 100644 --- a/apps/wiki/templates/wiki/tabs/search_view_item.html +++ b/apps/wiki/templates/wiki/tabs/search_view_item.html @@ -1,4 +1,4 @@ {% load i18n %}
  • - {% trans "Search and replace" %} + {% trans
  • diff --git a/redakcja/settings/compress.py b/redakcja/settings/compress.py index 5e8d721f..2ce6ac91 100644 --- a/redakcja/settings/compress.py +++ b/redakcja/settings/compress.py @@ -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_annotations.js', 'js/wiki/view_search.js', 'js/wiki/view_column_diff.js', ), diff --git a/redakcja/static/css/gallery.css b/redakcja/static/css/gallery.css index 9c6e3a59..12743214 100644 --- a/redakcja/static/css/gallery.css +++ b/redakcja/static/css/gallery.css @@ -18,6 +18,27 @@ 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 = */ /* =========== */ diff --git a/redakcja/static/css/master.css b/redakcja/static/css/master.css index bc622745..b71520f4 100644 --- a/redakcja/static/css/master.css +++ b/redakcja/static/css/master.css @@ -149,7 +149,6 @@ body { } .tabs li { - height: 18px; margin-top: 6px; margin-bottom: 0px; @@ -158,10 +157,6 @@ body { display: block; float: left; - padding-left: 12px; - padding-right: 12px; - padding-top: 5px; - font-weight: bold; color: #222; margin-left: 4px; @@ -179,10 +174,27 @@ body { -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-right li { + height: 20px; + padding-left: 12px; + padding-right: 12px; + padding-top: 3px; +} + + + #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 index 00000000..68da5027 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 index 00000000..fd7f0b07 Binary files /dev/null and b/redakcja/static/icons/system-search.png differ diff --git a/redakcja/static/js/wiki/loader.js b/redakcja/static/js/wiki/loader.js index f0515113..eb535a16 100644 --- a/redakcja/static/js/wiki/loader.js +++ b/redakcja/static/js/wiki/loader.js @@ -69,10 +69,12 @@ $(function() $.wiki.state.perspectives.ScanGalleryPerspective.show = false; $('#sidebar').hide(); $('.vsplitbar').css('right', 0).removeClass('active'); - if($(".vsplitbar-title").html() == "↓ SEARCH AND REPLACE â†“"){ - $(".vsplitbar-title").html("↑ SEARCH AND REPLACE ↑"); - } else { - $(".vsplitbar-title").html("↑ GALLERY ↑"); + if($(".vsplitbar-title").html() == "↓ ZNAJDŹ I ZAMIEѠ↓"){ + $(".vsplitbar-title").html("↑ ZNAJDŹ I ZAMIEŃ ↑"); + } else if($(".vsplitbar-title").html() == "↓ PRZYPISY â†“"){ + $(".vsplitbar-title").html("↑ PRZYPISY ↑"); + } else { + $(".vsplitbar-title").html("↑ GALERIA ↑"); } $('#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 index 00000000..d51ce9c8 --- /dev/null +++ b/redakcja/static/js/wiki/view_annotations.js @@ -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('

    Wystąpił błąd:

    ' + text + '
    '); + } + }); + } + 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]*>/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("↓ PRZYPISY ↓"); + + this.refresh(this); + + }; + + AnnotationsPerspective.prototype.onExit = function(success, failure) { + + }; + + $.wiki.AnnotationsPerspective = AnnotationsPerspective; + +})(jQuery); diff --git a/redakcja/static/js/wiki/view_editor_wysiwyg.js b/redakcja/static/js/wiki/view_editor_wysiwyg.js index dc24aea8..2beb4d4a 100644 --- a/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -503,7 +503,10 @@ _finalize(success); }, error: function(text, source){ - $('#html-view').html('

    Wystąpił błąd:

    '+text+'

    '+source.replace(/&/g, '&').replace(/');
    +                err = '

    Wystąpił błąd:

    '+text+'

    '; + if (source) + err += '
    '+source.replace(/&/g, '&').replace(/'
    +                $('#html-view').html(err);
                     _finalize(failure);
                 }
             });
    diff --git a/redakcja/static/js/wiki/view_gallery.js b/redakcja/static/js/wiki/view_gallery.js
    index 4f6b8a15..9630afb5 100644
    --- a/redakcja/static/js/wiki/view_gallery.js
    +++ b/redakcja/static/js/wiki/view_gallery.js
    @@ -226,7 +226,7 @@
             $.wiki.Perspective.prototype.onEnter.call(this);
     
             $('.vsplitbar').not('.active').trigger('click');
    -        $(".vsplitbar-title").html("↓ GALLERY ↓");        
    +        $(".vsplitbar-title").html("↓ GALERIA ↓");        
             
             this.doc.refreshGallery({
                 success: function(doc, data){
    diff --git a/redakcja/static/js/wiki/view_search.js b/redakcja/static/js/wiki/view_search.js
    index 789a9613..15f8e2e0 100644
    --- a/redakcja/static/js/wiki/view_search.js
    +++ b/redakcja/static/js/wiki/view_search.js
    @@ -99,7 +99,7 @@
             self.$searchCursor = null;
     
             $('.vsplitbar').not('.active').trigger('click');
    -        $(".vsplitbar-title").html("↓ SEARCH AND REPLACE ↓");        
    +        $(".vsplitbar-title").html("↓ ZNAJDŹ I ZAMIEŃ ↓");        
             
             if ($.wiki.activePerspective() != 'CodeMirrorPerspective')
                 $.wiki.switchToTab('#CodeMirrorPerspective');