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.
  • [get | view] (2003-12-07 18:15:54, 0.4 KB) [[attachment:Color.py]]
  • [get | view] (2003-12-07 18:15:54, 1.3 KB) [[attachment:Nav.py]]
  • [get | view] (2003-12-07 18:15:54, 0.7 KB) [[attachment:Up.py]]
  • [get | view] (2004-03-04 18:39:13, 4.6 KB) [[attachment:Vote.py]]
  • [get | view] (2003-12-07 18:15:54, 4.6 KB) [[attachment:Vote2.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.