changeset 2256:e66f66689305

UI for switching between itemid-name based history. Also fixes #15.
author Ashutosh Singla <ashu1461@gmail.com>
date Fri, 06 Sep 2013 00:52:01 +0530
parents 98be82eb3db8
children a39955ac972f
files MoinMoin/apps/frontend/views.py MoinMoin/templates/history.html
diffstat 2 files changed, 37 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Thu Sep 05 03:49:19 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Fri Sep 06 00:52:01 2013 +0530
@@ -976,6 +976,7 @@
 
 @frontend.route('/+history/<itemname:item_name>')
 def history(item_name):
+    fqname = split_fqname(item_name)
     offset = request.values.get('offset', 0)
     offset = max(int(offset), 0)
     bookmark_time = int(request.values.get('bookmark', 0))
@@ -983,7 +984,8 @@
         results_per_page = flaskg.user.results_per_page
     else:
         results_per_page = app.cfg.results_per_page
-    terms = [Term(WIKINAME, app.cfg.interwikiname), Term(NAME_EXACT, item_name), ]
+    terms = [Term(WIKINAME, app.cfg.interwikiname), ]
+    terms.extend(Term(term, value) for term, value in fqname.query.iteritems())
     if bookmark_time:
         terms.append(DateRange(MTIME, start=datetime.utcfromtimestamp(bookmark_time), end=None))
     query = And(terms)
@@ -991,9 +993,14 @@
     # it would be better to use search_page (and an appropriate limit, if needed)
     revs = flaskg.storage.search(query, idx_name=ALL_REVS, sortedby=[MTIME], reverse=True, limit=None)
     # get rid of the content value to save potentially big amounts of memory:
-    history = [dict((k, v) for k, v in rev.meta.iteritems() if k != CONTENT) for rev in revs]
+    history = []
+    for rev in revs:
+        entry = dict(rev.meta)
+        entry[FQNAME] = rev.fqname
+        history.append(entry)
     history_page = util.getPageContent(history, offset, results_per_page)
     return render_template('history.html',
+                           fqname=fqname,
                            item_name=item_name,  # XXX no item here
                            history_page=history_page,
                            bookmark_time=bookmark_time,
--- a/MoinMoin/templates/history.html	Thu Sep 05 03:49:19 2013 +0530
+++ b/MoinMoin/templates/history.html	Fri Sep 06 00:52:01 2013 +0530
@@ -1,7 +1,7 @@
 {% extends theme("layout.html") %}
 {% import "utils.html" as utils %}
 
-{% set title = _("History of '%(item_name)s'", item_name=item_name) %}
+{% set title = _("History of '%(fqname)s'", fqname=fqname|shorten_fqname) %}
 
 {% block content %}
     {% set (history, next_offset, previous_offset) = history_page %}
@@ -21,7 +21,12 @@
         <table class="zebra">
             <thead>
                 <tr>
-                    <th>{{ _("Name") }}</th>
+                    {% if fqname.field == 'name_exact' %}
+                        <th>{{ _("Item ID") }}</th> 
+                    {% else %}
+                        <th>{{ _("Name") }}</th>
+                    {% endif %}
+
                     <th>{{ _("Rev.") }}</th>
                     <th>{{ _("Timestamp") }}</th>
                     <th class="moin-integer">{{ _("Size") }}</th>
@@ -35,8 +40,19 @@
             <tbody>
                 {% for doc in history %}
                 <tr>
-                    <td class="moin-wordbreak">{{ doc.name|join(' | ') }}</td>
-                    <td>{{ doc.revid | shorten_id }}</td>
+                    {% if fqname.field == 'name_exact' %}
+                        <td class="moin-wordbreak">
+                            <a href="{{ url_for_item(doc.itemid, field='itemid', namespace=fqname.namespace, endpoint='frontend.history') }}">{{ doc.itemid|shorten_id }}</a>
+                        </td>
+                    {% else %}
+                        <td class="moin-wordbreak">
+                            {% for name in doc.name %}
+                                {% if not loop.first %}|{% endif %}
+                                <a href="{{ url_for_item(name, namespace=fqname.namespace, endpoint='frontend.history') }}">{{ name }}</a>
+                            {% endfor %}
+                        </td>
+                    {% endif %}
+                    <td>{{ doc.revid|shorten_id }}</td>
                     <td>{{ doc.mtime|datetimeformat }}</td>
                     <td class="moin-integer">{{ doc.size }}</td>
                     <td>
@@ -48,15 +64,15 @@
                     <td class="moin-wordbreak">{{ utils.editor_info(doc) }}</td>
                     <td class="moin-wordbreak">{{ doc.contenttype }}</td>
                     <td class="moin-wordbreak">{{ doc.comment }}</td>
-                    <td><a href="{{ url_for('frontend.show_item', item_name=doc.name[0], rev=doc.revid) }}">{{ _('show') }}</a></td>
-                    <td><a href="{{ url_for('frontend.show_item_meta', item_name=doc.name[0], rev=doc.revid) }}">{{ _('meta') }}</a></td>
-                    <td><a href="{{ url_for('frontend.download_item', item_name=doc.name[0], rev=doc.revid) }}">{{ _('download') }}</a></td>
-                    <td><a href="{{ url_for('frontend.highlight_item', item_name=doc.name[0], rev=doc.revid) }}">{{ _('highlight') }}</a></td>
-                    {% if user.may.write(item_name) -%}
-                    <td><a href="{{ url_for('frontend.revert_item', item_name=doc.name[0], rev=doc.revid) }}">{{ _('revert') }}</a></td>
+                    <td><a href="{{ url_for('frontend.show_item', item_name=doc.fqname, rev=doc.revid) }}">{{ _('show') }}</a></td>
+                    <td><a href="{{ url_for('frontend.show_item_meta', item_name=doc.fqname, rev=doc.revid) }}">{{ _('meta') }}</a></td>
+                    <td><a href="{{ url_for('frontend.download_item', item_name=doc.fqname, rev=doc.revid) }}">{{ _('download') }}</a></td>
+                    <td><a href="{{ url_for('frontend.highlight_item', item_name=doc.fqname, rev=doc.revid) }}">{{ _('highlight') }}</a></td>
+                    {% if user.may.write(fqname) -%}
+                        <td><a href="{{ url_for('frontend.revert_item', item_name=doc.fqname, rev=doc.revid) }}">{{ _('revert') }}</a></td>
                     {%- endif %}
-                    {% if user.may.destroy(item_name) -%}
-                    <td><a href="{{ url_for('frontend.destroy_item', item_name=doc.name[0], rev=doc.revid) }}">{{ _('destroy') }}</a></td>
+                    {% if user.may.destroy(fqname) -%}
+                        <td><a href="{{ url_for('frontend.destroy_item', item_name=doc.fqname, rev=doc.revid) }}">{{ _('destroy') }}</a></td>
                     {%- endif %}
                 </tr>
                 {% endfor %}