changeset 2771:5762664a2887

make /+mychanges work similar to local history, needs more work... like better styling (somehow the history style doesn't get active although i copied the html from there - is it the moved <form>? also, to make the diff buttons work, we need to get the parent revid.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 02 Sep 2014 19:58:40 +0200
parents 264e4015212e
children 239e3b34c6b4
files MoinMoin/apps/frontend/views.py MoinMoin/templates/mychanges.html
diffstat 2 files changed, 77 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Tue Sep 02 16:22:47 2014 +0200
+++ b/MoinMoin/apps/frontend/views.py	Tue Sep 02 19:58:40 2014 +0200
@@ -961,11 +961,19 @@
 
     :returns: a page with all the items the current user has contributed to
     """
+    offset = request.values.get('offset', 0)
+    offset = max(int(offset), 0)
+    if flaskg.user.valid:
+        results_per_page = flaskg.user.results_per_page
+    else:
+        results_per_page = app.cfg.results_per_page
     my_changes = _mychanges(flaskg.user.itemid)
-    return render_template('link_list_no_item_panel.html',
+    my_changes_page = util.getPageContent(my_changes, offset, results_per_page)
+    return render_template('mychanges.html',
                            title_name=_(u'My Changes'),
                            headline=_(u'My Changes'),
-                           fq_names=my_changes
+                           my_changes=my_changes,
+                           my_changes_page=my_changes_page,
     )
 
 
@@ -979,9 +987,14 @@
     """
     q = And([Term(WIKINAME, app.cfg.interwikiname),
              Term(USERID, userid)])
-    revs = flaskg.storage.search(q, idx_name=ALL_REVS, limit=None)
-    fq_names = {fq_name for rev in revs for fq_name in rev.fqnames}
-    return fq_names
+    revs = flaskg.storage.search(q, idx_name=ALL_REVS, sortedby=[MTIME], reverse=True, limit=None)
+    # get rid of the content value to save potentially big amounts of memory:
+    history = []
+    for rev in revs:
+        entry = dict(rev.meta)
+        entry[FQNAME] = rev.fqname
+        history.append(entry)
+    return history
 
 
 @frontend.route('/+refs/<itemname:item_name>')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/mychanges.html	Tue Sep 02 19:58:40 2014 +0200
@@ -0,0 +1,59 @@
+{% extends theme("layout.html") %}
+{% import "utils.html" as utils %}
+
+{% block content %}
+    {% set (history, next_offset, previous_offset) = my_changes_page %}
+    {% if my_changes %}
+        <div class='moin-offset-links'>
+            {% if previous_offset >= 0 %}
+                <a href="{{ url_for('frontend.mychanges', offset=previous_offset) }}" title="{{ _("Previous") }}">&laquo;</a>
+            {% endif %}
+            {% if next_offset %}
+                <a href="{{ url_for('frontend.mychanges', offset=next_offset) }}" title="{{ _("Next") }}">&raquo;</a>
+            {% endif %}
+        </div>
+        <h1>{{ _('My Changes') }}</h1>
+        <div class="moin-clr"></div>
+        <div id="moin-page-history">
+            <table class="zebra">
+                <thead>
+                    <tr>
+                        <th>{{ _("Item") }}</th>
+                        <th>{{ _("Rev.") }}</th>
+                        <th>{{ _("Timestamp") }}</th>
+                        <th class="moin-integer">{{ _("Size") }}</th>
+                        <th>{{ _("Diff") }}</th>
+                        <th>{{ _("Content-Type") }}</th>
+                        <th>{{ _("Comment") }}</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    {% for doc in my_changes %}
+                        <tr>
+                            <td class="moin-wordbreak">
+                                {% for name in doc.name %}
+                                    {% if not loop.first %}|{% endif %}
+                                    <a href="{{ url_for_item(name, namespace=doc.fqname.namespace, endpoint='frontend.show_item') }}">{{ name }}</a>
+                                {% endfor %}
+                            </td>
+                            <td>{{ doc.revid|shorten_id }}</td>
+                            <td>{{ doc.mtime|datetimeformat }}</td>
+                            <td class="moin-integer">{{ doc.size }}</td>
+                            <td>
+                                <div class="moin-hist-rev">
+                                    <form action="{{ url_for('frontend.diff', item_name=doc.fqname) }}" method="GET">
+                                        <input type="hidden" name="rev1" value="{{ doc.revid }}" />
+                                        <input type="hidden" name="rev2" value="{{ doc.revid }}" />
+                                        <input type="submit" class="btn btn-sm btn-primary" value="Diff" />
+                                    </form>
+                                </div>
+                            </td>
+                            <td class="moin-wordbreak">{{ doc.contenttype }}</td>
+                            <td class="moin-wordbreak">{{ doc.comment }}</td>
+                        </tr>
+                    {% endfor %}
+                </tbody>
+            </table>
+        </div>
+    {% endif %}
+{% endblock %}