changeset 3203:136ffd0554b9

diff action: added navigation buttons (needs css work)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 06 Mar 2008 17:00:15 +0100
parents 4985657ad30a
children a9bbb1727693
files MoinMoin/action/diff.py docs/CHANGES
diffstat 2 files changed, 59 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/diff.py	Thu Mar 06 15:26:51 2008 +0100
+++ b/MoinMoin/action/diff.py	Thu Mar 06 17:00:15 2008 +0100
@@ -3,10 +3,11 @@
     MoinMoin - show diff between 2 page revisions
 
     @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
-                2006 MoinMoin:ThomasWaldmann
+                2006-2008 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
+from MoinMoin import wikiutil
 from MoinMoin.logfile import editlog
 from MoinMoin.Page import Page
 
@@ -97,11 +98,63 @@
 
     f = request.formatter
     request.write(f.div(1, id="content"))
-    request.write(f.paragraph(1, css_class="diff-header"))
-    request.write(f.text(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_rev())))
+
+    oldrev = oldpage.get_real_rev()
+    newrev = newpage.get_real_rev()
+
+    title = _('Differences between revisions %d and %d') % (oldrev, newrev)
     if edit_count > 1:
-        request.write(f.text(' ' + _('(spanning %d versions)') % (edit_count, )))
-    request.write(f.paragraph(0))
+        title += ' ' + _('(spanning %d versions)') % (edit_count, )
+    title = f.text(title)
+
+    revlist = currentpage.getRevList()
+
+    # Revision list starts from 2...
+    if oldrev == min(revlist) + 1:
+        disable_prev = u' disabled="true"'
+    else:
+        disable_prev = u''
+
+    if newrev == max(revlist):
+        disable_next = u' disabled="true"'
+    else:
+        disable_next = u''
+
+    page_url = wikiutil.escape(currentpage.url(request, relative=False))
+
+    navigation_html = """
+<table class="diff">
+<tr>
+ <td style="border:0">
+  <span style="text-align:left">
+   <form action=%s method="get">
+    <input name="action" value="diff" type="hidden">
+    <input name="rev1" value="%d" type="hidden">
+    <input name="rev2" value="%d" type="hidden">
+    <input value="%s" type="submit"%s>
+   </form>
+  </span>
+ </td>
+ <td style="border:0">
+  <span class="diff-header">%s</span>
+ </td>
+ <td style="border:0">
+  <span style="text-align:right">
+   <form action=%s method="get">
+    <input name="action" value="diff" type="hidden">
+    <input name="rev1" value="%d" type="hidden">
+    <input name="rev2" value="%d" type="hidden">
+    <input value="%s" type="submit"%s>
+   </form>
+  </span>
+ </td>
+</tr>
+</table>
+""" % (page_url, oldrev - 1, oldrev, _("Previous change"), disable_prev,
+       title,
+       page_url, newrev, newrev + 1, _("Next change"), disable_next, )
+
+    request.write(f.rawHTML(navigation_html))
 
     if request.user.show_fancy_diff:
         from MoinMoin.util import diff_html
--- a/docs/CHANGES	Thu Mar 06 15:26:51 2008 +0100
+++ b/docs/CHANGES	Thu Mar 06 17:00:15 2008 +0100
@@ -79,6 +79,7 @@
       http://moinmo.in/MoinMoinTodo/Release_1.7/HelpOnNotification
     * standalone server can now be started via the "moin" script command,
       optionally backgrounding itself. See: moin server standalone --help
+    * the diff action now has navigation buttons for prev/next change
 
   Other changes:
     * cfg.show_login is gone, see code in theme/__init__.py, this affects