Attachment 'Nav.py'
Download 1 """
2 MoinMoin - Nav Macro
3
4 Written by Daniela Nicklas <dani@miracle-solutions.de> for MoinMoin 1.0
5
6 Useful for Subpages: inserts links to other subpages of parent (siblings)
7 or does nothing
8
9 Note: obsolete in later versions ("Navigation" in the CVS)
10 """
11
12 from MoinMoin.Page import Page
13 from MoinMoin import wikiutil, config
14 import sys
15 import cStringIO
16 import string
17
18 def execute(macro, args):
19
20 pagename = macro.formatter.page.page_name
21 plist = string.split(pagename, "/");
22
23 if len(plist) == 1:
24 return ""
25 else:
26 # determine parent
27 plist = plist[:-1]
28 parentname = string.join(plist, "/");
29
30 # construct list of siblings
31
32 siblings = wikiutil.getPageList(config.text_dir)
33 siblings = filter(lambda x: string.find(x, parentname) != -1, siblings)
34
35 result = []
36
37 for sibname in siblings:
38 if sibname == pagename: # not myself
39 continue
40 slist = string.split(sibname, "/")
41 if len(slist) == len(plist) + 1:
42 if slist[:-1] == plist:
43 result.append(sibname);
44
45 # construct the result
46 content = ""
47 for sibname in result:
48 p = Page(sibname)
49 content = content + " " + p.link_to() + " |"
50
51 # omit last |
52 content = content[:-2]
53
54 return content
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.