From fef7f24f34c07be9d9aff6db434e997f9a1f3451 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Tue, 15 Sep 2009 17:13:59 +0200 Subject: [PATCH] * Poprawki w redmine. * Lepsza autokorekta. refs #127 * Support dla kropek w id pliku. --- .../fixtures/przyciski.xml | 114 ++++++++++-------- dump_toolbar.sh | 2 +- project/static/js/editor.js | 6 +- project/static/js/editor.ui.js | 38 +++++- project/templates/explorer/editor.html | 15 ++- .../controllers/publications_controller.rb | 85 ++++++------- .../app/views/issues/_issue_view_pub.erb | 8 ++ .../settings/_publications_settings.html.erb | 6 + redmine/redmine_publications/init.rb | 2 +- .../lib/issue_publication_hook.rb | 67 ++++++---- redmine/redmine_publications/routes.rb | 7 +- 11 files changed, 214 insertions(+), 136 deletions(-) rename apps/{explorer => toolbar}/fixtures/przyciski.xml (94%) create mode 100644 redmine/redmine_publications/app/views/issues/_issue_view_pub.erb diff --git a/apps/explorer/fixtures/przyciski.xml b/apps/toolbar/fixtures/przyciski.xml similarity index 94% rename from apps/explorer/fixtures/przyciski.xml rename to apps/toolbar/fixtures/przyciski.xml index afa1deb2..e2aa914e 100755 --- a/apps/explorer/fixtures/przyciski.xml +++ b/apps/toolbar/fixtures/przyciski.xml @@ -116,17 +116,43 @@ lowercase u - 6 + 1 Zamień wielkie litery na małe. + + Cudzysłowy (1) + fix-quotes-inner-arrows + {"exprs": [["\u00ab|\u201e", ",,"], ["\u00bb", "\""], ["([^=])\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", "$1,,$2"], ["^\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"], ["(,,)\\s+|\\s+(\")", "$1"]]} + lineregexp + + + 0 + + + + + + + Cudzysłowy (2) + swap-quotes-outer-arrows + {"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["([^=])\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", "$1,,$2"], ["^\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"], ["(,,)\\s+|\\s+(\")", "$1"]]} + lineregexp + + + 0 + + + + + Podstawowa basic_correction - {"exprs": [["\n\\d+\n", "\n"], ["-\\s*\n+", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]} - fulltextregexp + [["fulltextregexp", {"exprs": [["\ufeff", ""], ["$[\\s]*\\d+[\\s]*^", ""], ["-\\s*^", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]}], ["lineregexp", {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+|\\s+(\")", "$1"], ["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"], ["<(/?)P([aert])", "<$1p$2"], ["([^\\.])(\\s*)</p", "$1.$2</p"]]}]] + macro 0 @@ -138,7 +164,7 @@ Usuń spację strip_whitespace - {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "]]} + {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "], ["(,,)\\s+|\\s+(\")", "$1"]]} lineregexp @@ -205,19 +231,6 @@ - - Zamień cudzysłowy - zamien-cudzyslowy - {"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"]]} - lineregexp - - - 0 - - - - - Zamień dywiz zamien_dywiz @@ -1085,9 +1098,8 @@ else { editor.showPopup('generic-info', 'Przetwarzanie zaznaczonego tekstu...', '', -1); - +$.log(editor, panel, params); var cm = panel.texteditor; - var exprs = $.map(params.exprs, function(expr) { var opts = "mg"; if(expr.length > 2) @@ -1108,8 +1120,6 @@ if(!text) { partial = false; } - - var original = text; $(exprs).each(function() { text = text.replace(this.rx, this.repl); @@ -1132,54 +1142,62 @@ if(!partial) { } - params.each(function() { - - editor.callScriptlet(this[0], this[1]); + $(params).each(function() { + $.log(this[0], this[1]); + editor.callScriptlet(this[0], panel, this[1]); }); var cm = panel.texteditor; - var text = cm.selection(); if(!text) return; - -var repl = text.toLowerCase(); +var repl = ''; +var lcase = text.toLowerCase(); +var ucase = text.toUpperCase(); + +if(lcase == text) repl = ucase; /* was lowercase */ +else if(ucase != text) repl = lcase; /* neither lower- or upper-case */ +else { /* upper case -> camel-case */ + repl = '' + $(lcase.split(/\s/)).each(function() { + if(this.length > 0) repl += this[0].toUpperCase() + this.slice(1) + ' '; + }); +} if(repl != text) { - cm.replaceSelection(repl); - panel.fireEvent('contentChanged'); - }; var texteditor = panel.texteditor; - var text = texteditor.selection(); - - if(text) { - - text = '\n' + text.split('\n').join('\\\n') + '\n'; - + var verses = text.split('\n'); + var text = ''; var buf = ''; var ebuf = ''; + var first = true; + + for(var i=0; i < verses.length; i++) { + verse = verses[i].replace(/^\s+/, "").replace(/\s+$/, ""); + if(verse) { + text += (buf ? buf + '\\\n' : '') + ebuf; + buf = (first ? '<strofa>\n' : '') + verses[i]; + ebuf = ''; + first = false; + } else { + ebuf += '\n' + verses[i]; + } + }; + text = text + buf + '\n</strofa>' + ebuf; + texteditor.replaceSelection(text); } - - -texteditor.replaceSelection('<strofa>'+text+'</strofa>'); - - - if (!text) { - var pos = texteditor.cursorPosition(); - texteditor.selectLines(pos.line, pos.character + 6 + 2); - } @@ -1219,10 +1237,6 @@ $('#split-dialog').jqmShow({ failure: function() { cm.undo(); } -}) ; - - - - +}) ; diff --git a/dump_toolbar.sh b/dump_toolbar.sh index 6dcbbe08..aede1747 100755 --- a/dump_toolbar.sh +++ b/dump_toolbar.sh @@ -1 +1 @@ -./project/manage.py dumpdata --format=xml toolbar | xmllint --format - > fixtures/przyciski.new.xml +./project/manage.py dumpdata --format=xml toolbar | xmllint --format - > apps/toolbar/fixtures/przyciski.xml diff --git a/project/static/js/editor.js b/project/static/js/editor.js index 3ae16b0a..e37228ce 100644 --- a/project/static/js/editor.js +++ b/project/static/js/editor.js @@ -460,8 +460,10 @@ Editor.prototype.sendMergeRequest = function (message) { if( $('.panel-wrap.changed').length != 0) alert("There are unsaved changes - can't commit."); - var self = this; - $.log('URL !: ', $('#commit-dialog form').attr('action')); + var self = this; + + $('#commit-dialog-related-issues input:checked'). + each(function() { message += ' refs #' + $(this).val(); }); $.ajax({ url: $('#commit-dialog form').attr('action'), diff --git a/project/static/js/editor.ui.js b/project/static/js/editor.ui.js index aed04553..4d2a5d39 100755 --- a/project/static/js/editor.ui.js +++ b/project/static/js/editor.ui.js @@ -163,15 +163,17 @@ Editor.prototype.setupUI = function() { $('#commit-dialog'). jqm({ modal: true, + onShow: $.fbind(self, self.loadRelatedIssues), trigger: '#toolbar-button-commit' }); - + + /* STATIC BINDS */ $('#commit-dialog-cancel-button').click(function() { $('#commit-dialog-error-empty-message').hide(); $('#commit-dialog').jqmHide(); }); - $('#commit-dialog-save-button').click( function (event, data) + $('#commit-dialog-save-button').click( function (event, data) { if( $('#commit-dialog-message').val().match(/^\s*$/)) { $('#commit-dialog-error-empty-message').fadeIn(); @@ -180,10 +182,11 @@ Editor.prototype.setupUI = function() { $('#commit-dialog-error-empty-message').hide(); $('#commit-dialog').jqmHide(); self.sendMergeRequest($('#commit-dialog-message').val() ); - } - + } + return false; - }); + }); + /* SPLIT DIALOG */ $('#split-dialog').jqm({ @@ -195,6 +198,31 @@ Editor.prototype.setupUI = function() { // $('#split-dialog'). } +Editor.prototype.loadRelatedIssues = function(hash) +{ + var self = this; + var c = $('#commit-dialog-related-issues'); + + $("div.loading-box", c).show(); + $("div.fatal-error-box", c).hide(); + $("div.container-box", c).hide(); + + $.getJSON( c.attr('ui:ajax-src') + '?callback=?', + function(data, status) + { + var fmt = ''; + $(data).each( function() { + fmt += '\n' + }); + $("div.container-box", c).html(fmt); + $("div.loading-box", c).hide(); + $("div.container-box", c).show(); + }); + + hash.w.show(); +} + Editor.prototype.loadSplitDialog = function(hash) { var self = this; diff --git a/project/templates/explorer/editor.html b/project/templates/explorer/editor.html index 6ee1cf85..02a1c758 100644 --- a/project/templates/explorer/editor.html +++ b/project/templates/explorer/editor.html @@ -81,11 +81,20 @@ {% endfor %} +
- -

Wiadomość nie może być pusta.

+ +

Wiadomość nie może być pusta.

+

@@ -96,7 +105,7 @@