1 """
   2     MoinMoin - Blog Macro
   3 
   4     Copyright (c) 2002 by Ken MacLeod <ken@bitsko.slc.ut.us>
   5     All rights reserved, see COPYING for details.
   6 
   7     Display a sequence of blog pages.
   8 
   9     $Id$
  10 """
  11 
  12 import sys, cStringIO, re, time
  13 from MoinMoin import editlog, user, config, wikiutil
  14 from MoinMoin.Page import Page
  15 
  16 def execute(macro, args):
  17     ret = ''
  18 
  19     blog_name = macro.formatter.page.page_name
  20 
  21     pages = wikiutil.getPageList(config.text_dir)
  22     display_pages = []
  23     for page_name in pages:
  24         if re.match('^' + blog_name + '/', page_name):
  25             display_pages.append(page_name)
  26 
  27     display_pages.sort()
  28     display_pages.reverse()
  29     display_seper = 0
  30     for page_name in display_pages[0:20]:
  31         if display_seper:
  32             ret = ret + '<p align="center"><img src="/img/par-seper.png" /></p>'
  33         display_seper = 1
  34         
  35         inc_page = Page(page_name, formatter=macro.formatter.__class__())
  36 
  37         # output the included page
  38         stdout = sys.stdout
  39         sys.stdout = cStringIO.StringIO()
  40         inc_page.send_page(macro.form, content_only=1)
  41         ret = ret + sys.stdout.getvalue()
  42         sys.stdout = stdout
  43 
  44         # /!\  This is broken.  For reasons I don't quite understand, the first
  45         # log entry doesn't appear to have EditorData.
  46         log = editlog.EditLog()
  47         log.filter(pagename=page_name)
  48         ret = ret + '<span class="blog_page"> -- by ' + log.getEditorData() \
  49               + " in " + inc_page.link_to() + '</span>'
  50 
  51     return ret

MoinMoin: macro/Blog.py (last edited 2007-10-29 19:10:36 by localhost)