Attachment 'RecentChangesMax.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - RecentChangesMax Macro
4 Mashup of RecentChanges and RandomPage Macros
5
6 @mixed: 2006 by Roger Ă–gretir <moinmoin@yoopee.de>
7 @license: GNU GPL, see COPYING for details.
8 """
9
10 from MoinMoin.Page import Page
11 from MoinMoin.logfile import editlog
12
13 Dependencies = ["time"]
14
15 def execute(macro, args):
16 request = macro.request
17
18 # get number of wanted links
19 try:
20 maxlinks = max(int(args), 1)
21 except StandardError:
22 maxlinks = 1
23
24 log = editlog.EditLog(request)
25
26 pages = []
27 known = {}
28 found = 0
29
30 for line in log.reverse():
31
32 page = Page(request, line.pagename)
33
34 if page.exists() and request.user.may.read(line.pagename) and not known.has_key(line.pagename):
35 pages.append(line.pagename)
36 found += 1
37 known[line.pagename] = None
38
39 if found >= maxlinks:
40 break
41
42
43 if not pages:
44 return ''
45
46 f = macro.formatter
47
48 # return a list of page links
49 result = []
50 write = result.append
51
52 write(f.bullet_list(1))
53 for name in pages:
54 write(f.listitem(1))
55 write(f.pagelink(1, name, generated=1))
56 write(f.text(name))
57 write(f.pagelink(0, name))
58 write(f.listitem(0))
59 write(f.bullet_list(0))
60
61 result = ''.join(result)
62 return result
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.You are not allowed to attach a file to this page.