[Moin-devel] CVS: MoinMoin/macro RecentChanges.py,1.53,1.54

J?rgen Hermann jhermann at users.sourceforge.net
Tue Feb 19 16:29:08 EST 2002


Update of /cvsroot/moin/MoinMoin/macro
In directory usw-pr-cvs1:/tmp/cvs-serv30686/macro

Modified Files:
	RecentChanges.py 
Log Message:
Added "diffs=1" to rss feed


Index: RecentChanges.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/macro/RecentChanges.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -r1.53 -r1.54
*** RecentChanges.py	13 Feb 2002 21:13:53 -0000	1.53
--- RecentChanges.py	20 Feb 2002 00:28:52 -0000	1.54
***************
*** 262,266 ****
          """
          from MoinMoin import webapi
!         import re, new, cStringIO
  
          # get params
--- 262,266 ----
          """
          from MoinMoin import webapi
!         import os, re, new, cStringIO
  
          # get params
***************
*** 276,279 ****
--- 276,283 ----
          except ValueError:
              unique = 0
+         try:
+             diffs = int(form.getvalue('diffs', 0))
+         except ValueError:
+             diffs = 0
  
          # prepare output
***************
*** 296,299 ****
--- 300,304 ----
              if log.action != 'SAVE': continue
              logdata.append(new.instance(Bag, {
+                 'ed_time': log.ed_time,
                  'time': log.time_tuple,
                  'pagename': log.pagename,
***************
*** 316,319 ****
--- 321,326 ----
              '    Add "unique=1" to get a list of changes where page names are unique,\n'
              '    i.e. where only the latest change of each page is reflected.\n'
+             '    \n'
+             '    Add "diffs=1" to add change diffs to the description of each items.\n'
              '-->\n' % items_limit
          )
***************
*** 367,373 ****
              handler.simpleNode('title', item.pagename)
              handler.simpleNode('link', link)
-             if item.comment:
-                 handler.simpleNode('description', item.comment)
              handler.simpleNode(('dc', 'date'), util.W3CDate(item.time))
  
              # contributor
--- 374,402 ----
              handler.simpleNode('title', item.pagename)
              handler.simpleNode('link', link)
              handler.simpleNode(('dc', 'date'), util.W3CDate(item.time))
+ 
+             # description
+             desc_text = item.comment
+             if diffs:
+                 # !!! TODO: rewrite / extend wikiutil.pagediff
+                 # searching for the matching pages doesn't really belong here
+                 # also, we have a problem to get a diff between two backup versions
+                 # so it's always a diff to the current version for now
+                 oldversions = wikiutil.getBackupList(config.backup_dir, item.pagename)
+ 
+                 for idx in range(len(oldversions)):
+                     oldpage = oldversions[idx]
+                     try:
+                         date = os.path.getmtime(os.path.join(config.backup_dir, oldpage))
+                     except EnvironmentError:
+                         continue
+                     if date <= item.ed_time:
+                         if idx+1 < len(oldversions):
+                             page_file, backup_file, lines = wikiutil.pagediff(item.pagename, oldversions[idx+1], ignorews=1)
+                             if len(lines) > 20: lines = lines[20:] + ['...\n']
+                             desc_text = desc_text + '<pre>\n' + string.join(lines, '') + '</pre>'
+                         break
+             if desc_text:
+                 handler.simpleNode('description', desc_text)
  
              # contributor





More information about the Moin-devel mailing list