1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/macros/SiteUpdates.py Mon Nov 26 01:13:01 2007 +0100
1.3 @@ -0,0 +1,60 @@
1.4 +# -*- coding: iso-8859-1 -*-
1.5 +"""
1.6 + MoinMoin - SiteUpdates Macro
1.7 +
1.8 + Inspired by the RecentChanges macro
1.9 +
1.10 + @copyright: 2007 by Paul Boddie <paul@boddie.org.uk>
1.11 + @license: GNU GPL, see COPYING for details.
1.12 +"""
1.13 +
1.14 +from MoinMoin.Page import Page
1.15 +from MoinMoin.logfile import editlog
1.16 +
1.17 +Dependencies = []
1.18 +
1.19 +MAX_ENTRIES = 5
1.20 +
1.21 +def execute(macro, args):
1.22 + request = macro.request
1.23 +
1.24 + max_entries = MAX_ENTRIES
1.25 + args = args.split(",")
1.26 + if args:
1.27 + try:
1.28 + max_entries = int(args[0])
1.29 + except ValueError:
1.30 + pass
1.31 +
1.32 + pages = {}
1.33 + log = editlog.EditLog(request)
1.34 +
1.35 + for line in log.reverse():
1.36 +
1.37 + if not request.user.may.read(line.pagename):
1.38 + continue
1.39 +
1.40 + pages[line.pagename] = line
1.41 +
1.42 + if len(pages.keys()) >= max_entries:
1.43 + break
1.44 +
1.45 + output = []
1.46 +
1.47 + if pages:
1.48 + output.append('<ul class="site-updates">\n')
1.49 +
1.50 + lines = pages.values()
1.51 + lines.sort()
1.52 + lines.reverse()
1.53 +
1.54 + for line in lines[:max_entries]:
1.55 + page = Page(request, line.pagename)
1.56 + link = page.link_to(request, text=page.split_title(request))
1.57 + output.append('<li>%s</li>\n' % link)
1.58 +
1.59 + output.append('</ul>\n')
1.60 +
1.61 + return ''.join(output)
1.62 +
1.63 +# vim: tabstop=4 expandtab shiftwidth=4