Attachment 'WikiList-1.1.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - WikiList macro
4
5 This macro produces a definition list of the wikis hosted in the farm.
6
7 @copyright: 2006 by The Anarcat <anarcat@anarcat.ath.cx>
8 @license: GNU GPL, see COPYING for details.
9 """
10
11 Dependencies = []
12
13 def execute(macro, args):
14 from farmconfig import wikis
15 output = ""
16 output += macro.formatter.definition_list(1)
17 for wiki in wikis:
18 name = wiki[0]
19 url = wiki[1]
20 if args == 'parse':
21 from re import sub
22 # XXX, hack: transform the regexp into a canonical url
23 # we need canonical urls in the config for this to be clean
24 # look for (foo|bar) and replace with foo
25 url = sub('\(([^\|]*)(\|[^\)]*\))+', '\\1', url)
26 # remove common regexp patterns and slap a protocol to make this a real url
27 url = 'http://' + sub('[\^\$]|(\.\*)', '', url)
28
29 mod = getattr(__import__(name), 'Config')
30 output += macro.formatter.definition_term(1)
31 output += macro.formatter.text(name)
32 output += macro.formatter.definition_term(0)
33 output += macro.formatter.definition_desc(1)
34 if args == 'parse':
35 output += macro.formatter.url(1, url)
36 output += macro.formatter.text(getattr(mod, 'sitename'))
37 output += macro.formatter.url(1, url)
38 else:
39 output += macro.formatter.text(getattr(mod, 'sitename') + " " + url)
40 output += macro.formatter.definition_desc(0)
41
42 output += macro.formatter.definition_list(0)
43 return output
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.