Some changes that somehow got lost on my file system.
authorŁukasz Rekucki <lrekucki@gmail.com>
Tue, 13 Apr 2010 17:52:43 +0000 (19:52 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Tue, 13 Apr 2010 18:58:40 +0000 (20:58 +0200)
25 files changed:
.gitignore
apps/wiki/constants.py
apps/wiki/forms.py
apps/wiki/helpers.py
apps/wiki/models.py
apps/wiki/nice_diff.py
apps/wiki/templates/wiki/base.html
apps/wiki/templates/wiki/document_create_missing.html
apps/wiki/templates/wiki/history_view.html
apps/wiki/templates/wiki/save_dialog.html
apps/wiki/templates/wiki/summary_view.html
apps/wiki/templates/wiki/tag_dialog.html
apps/wiki/urls.py
apps/wiki/views.py
lib/vstorage.py
lib/wlapi.py
platforma/compress_settings.py
platforma/context_processors.py
platforma/settings.py
platforma/static/js/wiki/dialog_addtag.js
platforma/static/js/wiki/dialog_save.js
platforma/static/js/wiki/view_history.js
platforma/static/js/wiki/view_summary.js
platforma/static/js/wiki/wikiapi.js
platforma/urls.py

index 38cbc21..a926b1a 100644 (file)
@@ -1,6 +1,7 @@
 localsettings.py
 dev.sqlite
 requirements.pybundle
+*~
 
 # Python garbage
 *.pyc
index 562421a..472bbb6 100644 (file)
@@ -2,23 +2,23 @@
 from django.utils.translation import ugettext_lazy as _
 
 DOCUMENT_TAGS = (
-    ("source", _("Tekst źródłowy")),
-    ("first_correction", _("Po autokorekcie")),
-    ("tagged", _("Tekst otagowany")),
-    ("second_correction", _("Po korekcie")),
-    ("source_annotations", _("Sprawdzone przypisy źródła")),
-    ("language_updates", _("Uwspółcześnienia")),
-    ("ready_to_publish", _("Tekst do publikacji")),
+    ("source", _(u"Tekst źródłowy")),
+    ("first_correction", _(u"Po autokorekcie")),
+    ("tagged", _(u"Tekst otagowany")),
+    ("second_correction", _(u"Po korekcie")),
+    ("source_annotations", _(u"Sprawdzone przypisy źródła")),
+    ("language_updates", _(u"Uwspółcześnienia")),
+    ("ready_to_publish", _(u"Tekst do publikacji")),
 )
 
 DOCUMENT_TAGS_DICT = dict(DOCUMENT_TAGS)
 
 DOCUMENT_STAGES = (
-    ("first_correction", _("Autokorekta")),
-    ("tagged", _("Tagowanie")),
-    ("second_correction", _("Korekta")),
-    ("source_annotations", _("Przypisy źródła")),
-    ("language_updates", _("Uwspółcześnienia")),
+    ("first_correction", _(u"Autokorekta")),
+    ("tagged", _(u"Tagowanie")),
+    ("second_correction", _(u"Korekta")),
+    ("source_annotations", _(u"Przypisy źródła")),
+    ("language_updates", _(u"Uwspółcześnienia")),
 )
 
 DOCUMENT_STAGES_DICT = dict(DOCUMENT_STAGES)
index 64dac29..f6e6f40 100644 (file)
@@ -43,7 +43,7 @@ class DocumentCreateForm(forms.Form):
 
 
 class DocumentTextSaveForm(forms.Form):
-    """if 
+    """
     Form for saving document's text:
 
         * name - document's storage identifier.
index 9b326d5..bc4b760 100644 (file)
@@ -25,7 +25,6 @@ class JSONResponse(http.HttpResponse):
         kwargs.pop('mimetype', None)
 
         data = json.dumps(data, cls=ExtendedEncoder)
-        print data
         super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs)
 
 
index ad15c5e..f35c307 100644 (file)
@@ -24,7 +24,7 @@ class DocumentStorage(object):
         return Document(self, name=name, text=text, revision=rev)
 
     def get_by_tag(self, name, tag):
-        text, rev = self.vstorage.page_text(name, tag)
+        text, rev = self.vstorage.page_text_by_tag(name, tag)
         return Document(self, name=name, text=text, revision=rev)
 
     def get_or_404(self, *args, **kwargs):
index 355600b..b228fad 100755 (executable)
@@ -17,12 +17,15 @@ NAMES = {'+': 'added', '-': 'removed', '^': 'changed'}
 def diff_replace(match):
     return """<span class="diff_mark diff_mark_%s">""" % NAMES[match.group(1)]
 
+
 def filter_line(line):
     return  DIFF_RE.sub(diff_replace, html_escape(line)).replace('\x01', '</span>')
 
+
 def format_changeset(a, b, change):
     return (a[0], filter_line(a[1]), b[0], filter_line(b[1]), change)
 
+
 def html_diff_table(la, lb, context=None):
     all_changes = difflib._mdiff(la, lb)
 
index 5680e0d..b6cfe60 100644 (file)
@@ -18,7 +18,7 @@
        {% endblock leftcolumn %}
 </div>
 <div id="wiki_layout_right_column">
-       {% block rightcolumn %} 
+       {% block rightcolumn %}
        {% endblock rightcolumn %}
 </div>
 {% endblock maincontent %}
\ No newline at end of file
index a230133..0dcf378 100644 (file)
@@ -3,11 +3,11 @@
 {% block leftcolumn %}
        <form enctype="multipart/form-data" method="POST" action="">
        {{ form.as_p }}
-       
+
        <p><button type="submit">Stwórz utwór</button></p>
        </form>
 {% endblock leftcolumn %}
 
-{% block rightcolumn %}        
+{% block rightcolumn %}
 
 {% endblock rightcolumn %}
\ No newline at end of file
index 6627171..58b5415 100644 (file)
@@ -1,26 +1,26 @@
 <div id="history-view-editor" class="editor" style="display: none">
     <div class="toolbar">
-       <button type="button" id="make-diff-button">Porównaj</button> 
+       <button type="button" id="make-diff-button">Porównaj</button>
                <button type="button" id="tag-changeset-button">Oznacz wersje</button>
-       </div> 
+       </div>
     <div id="history-view">
         <p class="message-box" style="display:none;"></p>
-               
+
                <table id="changes-list-container">
-        <tbody id="changes-list">              
+        <tbody id="changes-list">
         </tbody>
                <tbody style="display: none;">
-                       <tr class="entry row-stub">                     
+                       <tr class="entry row-stub">
                        <td data-stub-value="version"></td>
                        <td>
                                <span data-stub-value="description"></span>
                                <br />
                <span data-stub-value="author"></span>, <span data-stub-value="date"></span>
                        </td>
-                       <td data-stub-value="tag">                              
+                       <td data-stub-value="tag">
                        </td>
                </tr>
                </tbody>
-               </table>                  
+               </table>
     </div>
 </div>
index aba61cc..7155964 100644 (file)
@@ -6,35 +6,35 @@
                <span data-ui-error-for="{{ forms.text_save.comment.name }}"> </span>
        </p>
        {{forms.text_save.comment }}
-       
-       
-       
+
+
+
        {% if request.user.is_anonymous %}
        <p>
-               {{ forms.text_save.author.label }}: 
+               {{ forms.text_save.author.label }}:
                {{ forms.text_save.author }}
                <span class="help_text">{{ forms.text_save.author.help_text }}</span>
                <span data-ui-error-for="{{ forms.text_save.author.name }}"> </span>
        </p>
        {% else %}
        <p>
-               {{ forms.text_save.stage_completed.label }}: 
+               {{ forms.text_save.stage_completed.label }}:
                {{ forms.text_save.stage_completed }}
                <span class="help_text">{{ forms.text_save.stage_completed.help_text }}</span>
                <span data-ui-error-for="{{ forms.text_save.stage_completed.name }}"> </span>
        </p>
        {% endif %}
-       
-       
+
+
        {% for f in forms.text_save.hidden_fields %}
                {{ f }}
        {% endfor %}
-       
+
        <p data-ui-error-for="__all__"> </p>
-       
+
        <p class="action_area">
                <button type="submit" class"ok" data-ui-action="save">Zapisz</button>
                <button type="button" class="cancel" data-ui-action="cancel">Anuluj</button>
-       </p>    
-       </form> 
+       </p>
+       </form>
 </div>
index 5e1f82a..9835e63 100644 (file)
@@ -3,7 +3,7 @@
     </div> -->
     <div id="summary-view">
                <img class="book-cover" src="{{MEDIA_URL}}images/empty.png">
-               
+
                <h2>
                        <label for="title">Tytuł:</label>
                        <span data-ui-editable="true" data-edit-target="meta.displayTitle"
@@ -25,7 +25,7 @@
                        <span data-ui-editable="true" data-edit-target="meta.galleryLink"
                        >{{ document_meta.gallery}}</span>
                </p>
-               
-               <p><button type="button">Publikuj na wolnelektury.pl</button></p>
+
+               <p><button type="button" id="publish_button">Publikuj na wolnelektury.pl</button></p>
        </div>
 </div>
\ No newline at end of file
index 7212e36..66b488c 100644 (file)
@@ -1,19 +1,18 @@
 <div id="add_tag_dialog" class="dialog" data-ui-jsclass="AddTagDialog">
        <form method="POST" action="#">
                {% for field in forms.add_tag.visible_fields %}
-               <p>{{ field.label_tag }} {{ field }} <span data-ui-error-for="{{ field.name }}"> </span></p> 
-               <p>{{ field.help_text }}</p>            
+               <p>{{ field.label_tag }} {{ field }} <span data-ui-error-for="{{ field.name }}"> </span></p>
+               <p>{{ field.help_text }}</p>
                {% endfor %}
-                       
-                       
-               {% for f in forms.text_save.hidden_fields %}
+
+               {% for f in forms.add_tag.hidden_fields %}
                        {{ f }}
                {% endfor %}
-               <p data-ui-error-for="__all__"> </p>    
-               
+               <p data-ui-error-for="__all__"> </p>
+
                <p class="action_area">
                        <button type="submit" class"ok" data-ui-action="save">Zapisz</button>
                        <button type="button" class="cancel" data-ui-action="cancel">Anuluj</button>
-               </p>    
+               </p>
        </form>
 </div>
index d649ba5..dd0a0df 100644 (file)
@@ -18,8 +18,7 @@ urlpatterns = patterns('wiki.views',
         'document_diff', name="wiki_diff"),
     url(r'^(?P<name>[^/]+)/tags$',
         'document_add_tag', name="wiki_add_tag"),
-    url(r'^(?P<name>[^/]+)/tags$',
-        'document_publish'),
+    url(r'^(?P<name>[^/]+)/publish$', 'document_publish'),
     url(r'^(?P<name>[^/]+)$',
         'document_detail', name="wiki_details"),
 )
index e466d6a..8269339 100644 (file)
@@ -64,7 +64,7 @@ def document_detail(request, name, template_name='wiki/document_details.html'):
         'document_meta': document.meta,
         'forms': {
             "text_save": DocumentTextSaveForm(prefix="textsave"),
-            "add_tag": DocumentTagForm(prefix="addtag")
+            "add_tag": DocumentTagForm(prefix="addtag"),
         },
     })
 
index 4cfd59a..f348074 100644 (file)
@@ -266,19 +266,6 @@ class VersionedStorage(object):
         self.repo.remove([repo_file])
         self._commit([repo_file], text, user)
 
-#    @with_working_copy_locked
-#    def _open_page(self, title):
-#        if title not in self:
-#            raise DocumentNotFound()
-#
-#        path = self._title_to_file(title)
-#        logger.debug("Opening page %s", path)
-#        try:
-#            return self.repo.wfile(path, 'rb')
-#        except IOError:
-#            logger.exception("Failed to open page %s", title)
-#            raise DocumentNotFound()
-
     def page_text(self, title, revision=None):
         """Read unicode text of a page."""
         ctx = self._find_filectx(title, revision)
@@ -286,14 +273,14 @@ class VersionedStorage(object):
 
     def page_text_by_tag(self, title, tag):
         """Read unicode text of a taged page."""
-        tag = u"{title}#{tag}".format(**locals()).encode('utf-8')
         fname = self._title_to_file(title)
+        tag = u"{fname}#{tag}".format(**locals()).encode('utf-8')
 
         try:
             ctx = self.repo[tag][fname]
             return ctx.data().decode(self.charset, 'replace'), ctx.filerev()
         except IndexError:
-            raise DocumentNotFound()
+            raise DocumentNotFound(fname)
 
     @with_working_copy_locked
     def page_file_meta(self, title):
@@ -309,11 +296,11 @@ class VersionedStorage(object):
     def page_meta(self, title):
         """Get page's revision, date, last editor and his edit comment."""
         if not title in self:
-            raise DocumentNotFound()
+            raise DocumentNotFound(title)
 
         filectx_tip = self._find_filectx(title)
         if filectx_tip is None:
-            raise DocumentNotFound()
+            raise DocumentNotFound(title)
         rev = filectx_tip.filerev()
         filectx = filectx_tip.filectx(rev)
         date = datetime.datetime.fromtimestamp(filectx.date()[0])
@@ -336,9 +323,7 @@ class VersionedStorage(object):
 
     def _find_filectx(self, title, rev=None):
         """Find the last revision in which the file existed."""
-
         repo_file = self._title_to_file(title)
-
         changectx = self._changectx()  # start with tip
         stack = [changectx]
 
@@ -360,7 +345,7 @@ class VersionedStorage(object):
 
             return fctx
         except (IndexError, LookupError) as e:
-            raise DocumentNotFound()
+            raise DocumentNotFound(title)
 
     def page_history(self, title):
         """Iterate over the page's history."""
@@ -386,10 +371,12 @@ class VersionedStorage(object):
 
     @with_working_copy_locked
     def add_page_tag(self, title, rev, tag, user, doctag=True):
+        ctitle = self._title_to_file(title)
+
         if doctag:
-            tag = u"{title}#{tag}".format(**locals()).encode('utf-8')
+            tag = u"{ctitle}#{tag}".format(**locals()).encode('utf-8')
 
-        message = u"Assigned tag {tag!r} to version {rev!r} of {title!r}".format(**locals()).encode('utf-8')
+        message = u"Assigned tag {tag!r} to version {rev!r} of {ctitle!r}".format(**locals()).encode('utf-8')
 
         fctx = self._find_filectx(title, rev)
         self.repo.tag(
index 0a674c8..3284211 100644 (file)
@@ -38,7 +38,7 @@ def api_call(path, format="json"):
             # prepare request
             rq = urllib2.Request(self.base_url + path + ".json")
 
-            # will send POST when there is data, GET otherwise            
+            # will send POST when there is data, GET otherwise
             if data is not None:
                 rq.add_data(json.dumps(data))
                 rq.add_header("Content-Type", "application/json")
index a287001..ab72329 100644 (file)
@@ -41,6 +41,7 @@ COMPRESS_JS = {
 
                 # dialogs
                 'js/wiki/dialog_save.js',
+                'js/wiki/dialog_addtag.js',
 
                 # views
                 'js/wiki/view_history.js',
index db6c98b..4492af7 100644 (file)
@@ -1,8 +1,8 @@
 # -*- coding: utf-8
 
-
 def settings(request):
     from django.conf import settings
-    return {'MEDIA_URL': settings.MEDIA_URL,
-            'STATIC_URL': settings.STATIC_URL,
-            'REDMINE_URL': settings.REDMINE_URL}
+    return {
+        'MEDIA_URL': settings.MEDIA_URL,
+        'STATIC_URL': settings.STATIC_URL,
+    }
index 4ec680f..1f9d5d0 100644 (file)
@@ -60,6 +60,7 @@ ADMIN_MEDIA_PREFIX = '/admin-media/'
 
 # Make this unique, and don't share it with anybody.
 SECRET_KEY = 'ife@x^_lak+x84=lxtr!-ur$5g$+s6xt85gbbm@e_fk6q3r8=+'
+SESSION_COOKIE_NAME = "redakcja_sessionid"
 
 # List of callables that know how to import templates from various sources.
 TEMPLATE_LOADERS = (
@@ -156,7 +157,7 @@ IMAGE_DIR = 'images'
 
 WL_API_CONFIG = {
     "URL": "http://localhost:7000/api/",
-    "AUTH_REALM": "wlapi",
+    "AUTH_REALM": "WL API",
     "AUTH_USER": "platforma",
     "AUTH_PASSWD": "platforma",
 }
index 42a8148..1a90ccf 100644 (file)
@@ -14,8 +14,8 @@
         /* fill out hidden fields */
         this.$form = $('form', element);
 
-        $("input[name='id']", this.$form).val(CurrentDocument.id);
-        $("input[name='revision']", this.$form).val(options.revision);
+        $("input[name='addtag-id']", this.$form).val(CurrentDocument.id);
+        $("input[name='addtag-revision']", this.$form).val(options.revision);
 
         $.wiki.cls.GenericDialog.call(this, element);
     };
index 12f131f..916f326 100644 (file)
@@ -11,8 +11,8 @@
                /* fill out hidden fields */
                this.$form = $('form', element);
 
-               $("input[name='id']", this.$form).val(CurrentDocument.id);
-               $("input[name='parent_revision']", this.$form).val(CurrentDocument.revision);
+               $("input[name='textsave-id']", this.$form).val(CurrentDocument.id);
+               $("input[name='textsave-parent_revision']", this.$form).val(CurrentDocument.revision);
 
                $.wiki.cls.GenericDialog.call(this, element);
        };
index b2fe0b0..5a3e813 100644 (file)
@@ -71,7 +71,7 @@
             var $stub = $('#history-view .row-stub');
             changes_list.html('');
 
-                       var tags = $('select#id_addtag_tag option');
+                       var tags = $('select#id_addtag-tag option');
 
             $.each(data, function(){
                 $.wiki.renderStub({
index 736f4e3..811096d 100644 (file)
@@ -9,7 +9,7 @@
                                $.blockUI({message: "Oczekiwanie na odpowiedź serwera..."});
                                self.doc.publish({
                                        success: function(doc, data) {
-                                               $.blockUI({message: "Udało się", timeout: 2000});
+                                               $.blockUI({message: "Udało się.", timeout: 2000});
                                        },
                                        failure: function(doc, message) {
                                                $.blockUI({
                                                        timeout: 5000
                                                });
                                        }
-                                       
+
                                });
                        });
-                       
+
                        old_callback.call(this);
                };
 
index a288397..d0ac5dc 100644 (file)
        function reverse() {
                var vname = arguments[0];
                var base_path = "/documents";
-               
+
                if (vname == "ajax_document_text") {
                        var path = "/" + arguments[1] + "/text";
-                       
-               if (arguments[2] !== undefined) 
+
+               if (arguments[2] !== undefined)
                                path += "/" + arguments[2];
-                       
+
                        return base_path + path;
                }
-               
+
                if (vname == "ajax_document_history") {
-                       
+
                        return base_path + "/" + arguments[1] + "/history";
                }
-               
+
                if (vname == "ajax_document_gallery") {
-                       
+
                        return base_path + "/gallery/" + arguments[1];
                }
-               
-               if (vname == "ajax_document_diff")      
+
+               if (vname == "ajax_document_diff")
                        return base_path + "/" + arguments[1] + "/diff";
-               
+
                if (vname == "ajax_document_addtag")
                        return base_path + "/" + arguments[1] + "/tags";
-                       
+
                if (vname == "ajax_publish")
                        return base_path + "/" + arguments[1] + "/publish";
-                       
-               console.log("Couldn't reverse match:", vname);          
+
+               console.log("Couldn't reverse match:", vname);
                return "/404.html";
        };
-       
+
        /*
         * Document Abstraction
         */
@@ -64,7 +64,7 @@
                this._context_lock = -1;
                this._lock_count = 0;
        };
-       
+
        WikiDocument.prototype.triggerDocumentChanged = function() {
                $(document).trigger('wlapi_document_changed', this);
        };
                        dataType: 'json',
                        success: function(data) {
                                var changed = false;
-                               
-if (self.text === null || self.revision !== data.revision) {
+
+                               if (self.text === null || self.revision !== data.revision) {
                                        self.text = data.text;
                                        self.revision = data.revision;
                                        self.gallery = data.gallery;
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
-                               
+
                                self.has_local_changes = false;
                                params['success'](self, changed);
                        },
@@ -188,23 +188,24 @@ if (self.text === null || self.revision !== data.revision) {
        WikiDocument.prototype.save = function(params) {
                params = $.extend({}, noops, params);
                var self = this;
-               
+
                if (!self.has_local_changes) {
-                       console.log("Abort: no changes.");                      
+                       console.log("Abort: no changes.");
                        return params['success'](self, false, "Nie ma zmian do zapisania.");
                };
-               
+
                // Serialize form to dictionary
                var data = {};
                $.each(params['form'].serializeArray(), function() {
                        data[this.name] = this.value;
                });
+               
                var metaComment = '<!--';
                metaComment += '\n\tgallery:' + self.galleryLink;
                metaComment += '\n-->\n'
-               
+
                data['textsave-text'] = metaComment + self.text;
-               
+
                $.ajax({
                        url: reverse("ajax_document_text", self.id),
                        type: "POST",
@@ -212,7 +213,7 @@ if (self.text === null || self.revision !== data.revision) {
                        data: data,
                        success: function(data) {
                                var changed = false;
-                               
+
                                if (data.text) {
                                        self.text = data.text;
                                        self.revision = data.revision;
@@ -220,19 +221,19 @@ if (self.text === null || self.revision !== data.revision) {
                                        changed = true;
                                        self.triggerDocumentChanged();
                                };
-                               
+
                                params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
                        },
                        error: function(xhr) {
                                try {
                                        params['failure'](self, $.parseJSON(xhr.responseText));
-                               } 
+                               }
                                catch (e) {
                                        params['failure'](self, {
                                                "__message": "<p>Nie udało się zapisać - błąd serwera.</p>"
                                        });
                                };
-                               
+
                        }
                });
        }; /* end of save() */
@@ -253,12 +254,12 @@ if (self.text === null || self.revision !== data.revision) {
                                else {
                                        try {
                                                params.failure(self, xhr.responseText);
-                                       } 
+                                       }
                                        catch (e) {
-                                               params.failure(self, "Nie udało się - błąd serwera.");                                              
-                                       };                                      
+                                               params.failure(self, "Nie udało się - błąd serwera.");
+                                       };
                                };
-                               
+
                        }
                });
        };
@@ -266,12 +267,14 @@ if (self.text === null || self.revision !== data.revision) {
                params = $.extend({}, noops, params);
                var self = this;
                var data = {
-                       "id": self.id,
+                       "addtag-id": self.id,
                };
+               
                /* unpack form */
                $.each(params.form.serializeArray(), function() {
                        data[this.name] = this.value;
                });
+               
                $.ajax({
                        url: reverse("ajax_document_addtag", self.id),
                        type: "POST",
@@ -280,7 +283,7 @@ if (self.text === null || self.revision !== data.revision) {
                        success: function(data) {
                                params.success(self, data.message);
                        },
-                       error: function(xhr) {                          
+                       error: function(xhr) {
                                if (xhr.status == 403 || xhr.status == 401) {
                                        params.failure(self, {
                                                "__all__": ["Nie masz uprawnień lub nie jesteś zalogowany."]
@@ -289,15 +292,15 @@ if (self.text === null || self.revision !== data.revision) {
                                else {
                                        try {
                                                params.failure(self, $.parseJSON(xhr.responseText));
-                                       } 
+                                       }
                                        catch (e) {
                                                params.failure(self, {
                                                        "__all__": ["Nie udało się - błąd serwera."]
                                                });
                                        };
-                                       
+
                                };
-                               
+
                        }
                });
        };
index 3c2b6c8..904ad44 100644 (file)
@@ -24,6 +24,6 @@ urlpatterns = patterns('',
     url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
         {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
 
-    url(r'^$', 'redirect_to', {'url': '/documents/'}),
+    url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}),
     url(r'^documents/', include('wiki.urls')),
 )