changeset 5840:4a982b04461d

action/rss_rc.py: new option - lines - set max lines for diff/content shown in RSS.
author Eugene Syromyatnikov <evgsyr@gmail.com>
date Wed, 16 May 2012 04:29:16 +0400
parents d415cb95645c
children 8b3c4b85921b
files MoinMoin/action/rss_rc.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/rss_rc.py	Wed May 16 05:26:00 2012 +0400
+++ b/MoinMoin/action/rss_rc.py	Wed May 16 04:29:16 2012 +0400
@@ -31,6 +31,7 @@
 
     # get params
     items_limit = 100
+    lines_limit = 100
     try:
         max_items = int(request.values['items'])
         max_items = min(max_items, items_limit) # not more than `items_limit`
@@ -50,6 +51,10 @@
         ddiffs = int(request.values.get('ddiffs', 0))
     except ValueError:
         ddiffs = 0
+    try:
+        max_lines = min(int(request.values.get('lines', 20)), lines_limit)
+    except ValueError:
+        max_lines = 20
 
     # get data
     log = editlog.EditLog(request)
@@ -76,7 +81,7 @@
     del log
 
     timestamp = timefuncs.formathttpdate(lastmod)
-    etag = "%d-%d-%d-%d-%d" % (lastmod, max_items, diffs, ddiffs, unique)
+    etag = "%d-%d-%d-%d-%d-%d" % (lastmod, max_items, diffs, ddiffs, unique, max_lines)
 
     # for 304, we look at if-modified-since and if-none-match headers,
     # one of them must match and the other is either not there or must match.
@@ -126,8 +131,14 @@
             '    Add "diffs=1" to add change diffs to the description of each items.\n'
             '    \n'
             '    Add "ddiffs=1" to link directly to the diff (good for FeedReader).\n'
-            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i'
-            '-->\n' % (items_limit, max_items, unique, diffs, ddiffs)
+            '    \n'
+            '    Add "lines=nnn" to change maximum number of diff/body lines \n'
+            '    to show. Cannot be more than %d.\n'
+            '    \n'
+            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i, \n'
+            '    lines=%i\n'
+            '-->\n' % (items_limit, lines_limit, max_items, unique, diffs,
+                       ddiffs, max_lines)
             )
 
         # emit channel description
@@ -200,7 +211,7 @@
                     lines = wikiutil.pagediff(request, item.pagename,
                         item_rev - 1, item.pagename, item_rev, ignorews=1)
 
-                if len(lines) > 20:
+                if len(lines) > max_lines:
                     lines = lines[:max_lines] + ['...\n']
 
                 lines = '\n'.join(lines)