Details

Applies to

MoinMoin Theme Core, MoinMoin Action (MoinMoin/theme, MoinMoin/action) v1.8.2, v.1.9beta2

Purpose

To allow for RSS feeds for pages & sub-pages

Description

The provided set of patches allows to set-up RSS feed for pages and sub-pages if #pragma rss on has been added to the page

Simply:

Add the following line to the wiki page, and RSS feed shall be available

#pragma rss on

Remove it, and RSS feed (link) will be unavailable.

Patch

There are a few patches provided:

   1 --- rss_rc.py	2009-01-07 01:26:50.000000000 +0100
   2 +++ rss_rc.py.new	2009-03-23 03:58:07.000000000 +0100
   3 @@ -52,6 +52,12 @@
   4          ddiffs = int(request.form.get('ddiffs', [0])[0])
   5      except ValueError:
   6          ddiffs = 0
   7 +    # allow feeds from local tree
   8 +    try:
   9 +        local = int(request.form.get('local', [0])[0])
  10 +    except ValueError:
  11 +        local = 0
  12 + 
  13  
  14      # get data
  15      log = editlog.EditLog(request)
  16 @@ -62,9 +68,13 @@
  17      for line in log.reverse():
  18          if not request.user.may.read(line.pagename):
  19              continue
  20 +        if (local == 1):
  21 +            pagename_len = len(pagename)
  22 +            if (line.pagename[:pagename_len] != pagename):
  23 +                continue
  24 +
  25          if (not line.action.startswith('SAVE') or
  26              ((line.pagename in pages) and unique)): continue
  27 -        #if log.dayChanged() and log.daycount > _MAX_DAYS: break
  28          line.editor = line.getInterwikiEditorData(request)
  29          line.time = timefuncs.tmtuple(wikiutil.version2timestamp(line.ed_time_usecs)) # UTC
  30          logdata.append(line)
  31 @@ -133,8 +143,10 @@
  32              '    Add "diffs=1" to add change diffs to the description of each items.\n'
  33              '    \n'
  34              '    Add "ddiffs=1" to link directly to the diff (good for FeedReader).\n'
  35 -            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i'
  36 -            '-->\n' % (items_limit, max_items, unique, diffs, ddiffs)
  37 +            '    \n'
  38 +            '    Add "local=1" to limit feed for specified page and subpages\n'
  39 +            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i, local=%i'
  40 +             '-->\n' % (items_limit, max_items, unique, diffs, ddiffs, local)
  41              )
  42  
  43          # emit channel description
rss_rc-1.8.py.patch

   1 --- rss_rc.py.orig	2009-03-14 14:22:44.000000000 +0100
   2 +++ rss_rc.py	2009-03-27 04:43:00.000000000 +0100
   3 @@ -51,6 +51,12 @@
   4          ddiffs = int(request.values.get('ddiffs', 0))
   5      except ValueError:
   6          ddiffs = 0
   7 +    # allow feeds from local tree
   8 +    try:
   9 +        local = int(request.values.get('local', 0))
  10 +    except ValueError:
  11 +        local = 0
  12 + 
  13  
  14      # get data
  15      log = editlog.EditLog(request)
  16 @@ -61,9 +67,13 @@
  17      for line in log.reverse():
  18          if not request.user.may.read(line.pagename):
  19              continue
  20 +        if local:
  21 +            pagename_len = len(pagename)
  22 +            if (line.pagename[:pagename_len] != pagename):
  23 +                continue
  24 +
  25          if (not line.action.startswith('SAVE') or
  26              ((line.pagename in pages) and unique)): continue
  27 -        #if log.dayChanged() and log.daycount > _MAX_DAYS: break
  28          line.editor = line.getInterwikiEditorData(request)
  29          line.time = timefuncs.tmtuple(wikiutil.version2timestamp(line.ed_time_usecs)) # UTC
  30          logdata.append(line)
  31 @@ -128,8 +138,10 @@
  32              '    Add "diffs=1" to add change diffs to the description of each items.\n'
  33              '    \n'
  34              '    Add "ddiffs=1" to link directly to the diff (good for FeedReader).\n'
  35 -            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i'
  36 -            '-->\n' % (items_limit, max_items, unique, diffs, ddiffs)
  37 +            '    \n'
  38 +            '    Add "local=1" to limit feed for specified page and subpages\n'
  39 +            '    Current settings: items=%i, unique=%i, diffs=%i, ddiffs=%i, local=%i'
  40 +             '-->\n' % (items_limit, max_items, unique, diffs, ddiffs, local)
  41              )
  42  
  43          # emit channel description
rss_rc-1.9.py.patch

   1 --- __init__.py	2009-01-07 01:30:29.000000000 +0100
   2 +++ __init__.py.new	2009-03-23 04:07:21.000000000 +0100
   3 @@ -828,11 +828,16 @@
   4              Currently rss is broken on plain Python, and works only when
   5              installing PyXML. Return true if PyXML is installed.
   6          """
   7 +
   8 +        request = self.request
   9 +
  10          if not rss_supported:
  11              return False
  12          return page.page_name == u'RecentChanges' or \
  13 -           page.page_name == self.request.getText(u'RecentChanges')
  14 +           page.page_name == self.request.getText(u'RecentChanges') or \
  15 +           request.getPragma('rss') == u'on'
  16  
  17 +    
  18      def rsshref(self, page):
  19          """ Create rss href, used for rss button and head link
  20  
  21 @@ -840,8 +845,15 @@
  22          @return: rss href
  23          """
  24          request = self.request
  25 -        url = page.url(request, querystr={
  26 +
  27 +        if request.getPragma('rss') == u'on':
  28 +            url = page.url(request, querystr={
  29 +                'action': 'rss_rc', 'ddiffs': '1', 'unique': '1', 'local': '1' }, 
  30 +                escape=0)
  31 +        else:
  32 +            url = page.url(request, querystr={
  33                  'action': 'rss_rc', 'ddiffs': '1', 'unique': '1', }, escape=0)
  34 +
  35          return url
  36  
  37      def rsslink(self, d):
theme-__init__.py.patch

Discussion

 if (local == 1):  is if local: -- Reimar

Thx -- StellarsHenson 2009-03-27 03:43:30

Plan


CategoryMoinMoinPatch

MoinMoin: MoinMoinPatch/RssForPages (last edited 2009-03-27 03:43:30 by StellarsHenson)