Attachment 'RecentChangesList.py'

Download

   1 # recent changes with diffs
   2 Dependencies = ["time"]
   3 
   4 from MoinMoin import util, wikiutil, config
   5 from MoinMoin.Page import Page
   6 
   7 class RSStoWiki:
   8     def __init__(self, macro):
   9         self.macro = macro
  10         self.fmt = macro.formatter
  11 	url = "http://wiki.personaltelco.net/index.cgi/RecentChanges?action=rss_rc&unique=1&ddiffs=1"
  12         import feedparser
  13         self.f = feedparser.parse(url)
  14         self.result = []
  15 
  16     def get_link(self, link):
  17         self.result.append(self.fmt.url(on=1, href=link) + \
  18                            self.fmt.icon('diff') + \
  19 			   self.fmt.url(on=0))
  20 
  21     def get_entry_header(self, title):
  22         import re
  23         tit = re.match('(.{30})', title)
  24 	if tit:
  25 	    bigtits = tit.group(0)
  26 	    tits = "<i>title too long</i>"
  27 	else:
  28 	    tits = title
  29 	self.result.append(self.fmt.url(on=1, href='http://wiki.personaltelco.net/index.cgi/'+title) + \
  30 			   self.fmt.rawHTML(" "+tits) + \
  31                            self.fmt.url(on=0) + \
  32                            self.fmt.rawHTML('<br>'))
  33 
  34     def get_paragraph(self, text):
  35         self.result.append(self.fmt.paragraph(on=1) + \
  36                            self.fmt.text(text) + \
  37                            self.fmt.paragraph(on=0))
  38 
  39     def get_entry_body(self, body):
  40         self.result.append(self.fmt.rawHTML('&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://wiki.personaltelco.net/images/comment2.png">&nbsp;'))
  41         self.result.append(self.fmt.text(body))
  42         self.result.append(self.fmt.rawHTML('<br>'))
  43 
  44     def get_description(self):
  45         if not self.f.feed.has_key('description'):
  46             return
  47         self.get_paragraph(self.f.feed.description)
  48 
  49     def get_entries(self):
  50         self.f.entries = self.f.entries[:int(5)]
  51 	for entry in self.f.entries:
  52             if entry.has_key('link'):
  53                 self.get_link(entry.link)
  54             if entry.has_key('title'):
  55                 self.get_entry_header(entry.title)
  56             if entry.has_key('description'):
  57                 self.get_entry_body(entry.description)
  58 
  59 
  60     def get_output(self):
  61 	self.get_entries()
  62         return ''.join(self.result)
  63 
  64 def execute(macro, args):
  65       rss = RSStoWiki(macro)
  66       return rss.get_output()
  67 

New Attachment

File to upload
Rename to
Overwrite existing attachment of same name
The state to the north of us

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.