changeset 465:3076415fdaba

Bookmark functionality added for the global history results
author Akash Sinha <akash2607@gmail.com>
date Mon, 13 Jun 2011 02:08:44 +0530
parents 58a29a7fd016
children 7754844a1dbe
files MoinMoin/apps/frontend/views.py MoinMoin/templates/global_history.html MoinMoin/themes/modernized/static/css/common.css
diffstat 3 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Wed Jun 08 02:16:25 2011 +0530
+++ b/MoinMoin/apps/frontend/views.py	Mon Jun 13 02:08:44 2011 +0530
@@ -548,10 +548,16 @@
 @frontend.route('/+history')
 def global_history():
     history = flaskg.storage.history(item_name='')
+    if flaskg.user.valid:
+        bookmark_time = flaskg.user.getBookmark()
+    else:
+        bookmark_time = None
     item_groups = OrderedDict()
     for rev in history:
         current_item_name = rev.item.name
-        if current_item_name in item_groups:
+        if bookmark_time and rev.timestamp <= bookmark_time:
+            break
+        elif current_item_name in item_groups:
             item_groups[current_item_name].append(rev)
         else:
             item_groups[current_item_name] = [rev]
@@ -643,9 +649,12 @@
     del grouped_history[0]  # First tuple will be a null one
 
     item_name = request.values.get('item_name', '') # actions menu puts it into qs
+    current_timestamp = int(time.time())
     return render_template('global_history.html',
                            item_name=item_name, # XXX no item
                            history=grouped_history,
+                           current_timestamp=current_timestamp,
+                           bookmark_time=bookmark_time,
                           )
 
 @frontend.route('/+wanteds')
--- a/MoinMoin/templates/global_history.html	Wed Jun 08 02:16:25 2011 +0530
+++ b/MoinMoin/templates/global_history.html	Mon Jun 13 02:08:44 2011 +0530
@@ -8,10 +8,29 @@
 
 {% block content %}
 <h1>{{ _("Global History") }}</h1>
+    {% if user.valid  %}
+    <div id="moin-set-bookmark">
+        {% if bookmark_time %}
+            {{ _("Bookmark (currently set to %(bookmark)s). ", bookmark=bookmark_time|datetimeformat) }} 
+            <a href="{{ url_for('frontend.bookmark', time='del') }}">{{ _("Delete bookmark") }}</a>
+        {% else %}
+            {{ _("Bookmark (not set). ") }}<a href="{{ url_for('frontend.bookmark', time=current_timestamp) }}">{{ _("Set bookmark") }}</a> 
+        {% endif %}
+    {% endif %}
+    </div>
     <div id="moin-global-history">
         {% for rev_date, revs in history %}
+           {% set  latest_rev = revs[0] %}
+           {% set  latest_timestamp = latest_rev.timestamp %}
             <div class="moin-history-container"> 
-                <h2 class="moin-history-container-header">{{ rev_date }}</h2>
+                <div class="moin-history-container-header">
+                    <span>
+                        <h2>{{ rev_date }}</h2>
+                        {% if user.valid %}
+                        <a class="bookmark-link" href="{{ url_for('frontend.bookmark', time=latest_timestamp) }}">{{ _("Set bookmark") }}</a>
+                        {% endif %}
+                   </span>
+                </div>
                 <div class="moin-history-container-body">
                     <table>
                     {% for rev in revs %}
@@ -49,4 +68,7 @@
             </div>
         {% endfor %}
     </div>
+   {% if bookmark_time %}
+       <div id="moin-bookmark-reached">{{ _("Bookmark reached") }}</div>
+   {% endif %}
 {% endblock %}
--- a/MoinMoin/themes/modernized/static/css/common.css	Wed Jun 08 02:16:25 2011 +0530
+++ b/MoinMoin/themes/modernized/static/css/common.css	Mon Jun 13 02:08:44 2011 +0530
@@ -220,7 +220,9 @@
 .moin-history-comment { width: 25%; }
 .moin-action { width: 2%; }
 .moin-history-container { border: 1px solid #4D7DA9; }
-.moin-history-container-header { background: #81BBF2; margin: 0px; padding: 3px; color: #3b3131; border-bottom: 1px solid #4D7DA9; }
+.moin-history-container-header { background: #81BBF2; margin: 0px; padding: 4px; color: #3b3131; border-bottom: 1px solid #4D7DA9; }
+.moin-history-container-header h2 { display: inline; }
+.moin-history-container-header a.bookmark-link { margin-left: 10px; color: #3b3131; }
 .moin-history-container-body { padding: 4px; font-size: 14px; }
 .moin-history-save:before { content: url('../img/moin-edit.png'); }
 .moin-history-trash:before { content: url('../img/moin-deleted.png'); }