Attachment 'SubscribedPages.py'

Download

   1 #format python
   2 # -*- coding: iso-8859-1 -*-
   3 """
   4     MoinMoin - List all subscribed pages
   5 
   6     [[SubscribedPages]] will display a list of all pages you have subscribed to.
   7 
   8     [[SubscribedPages(SomeUser)]] will display a list of all pages SomeUser has subscribed to.
   9 
  10     @copyright: 2004 by Peter Kleiweg <kleiweg@let.rug.nl>
  11     @license: GNU GPL, see COPYING for details.
  12 """
  13 
  14 from MoinMoin import config, user, wikiutil
  15 
  16 # Dependencies = ["namespace"]
  17 #   Probably can't use Dependencies as above.
  18 #   Dependencies should be: namespace, userpreferences
  19 #   The second does not exist
  20 
  21 def execute (macro, name):
  22     _ = macro.request.getText
  23     
  24     if name:
  25         uid = user.getUserId (name)
  26         if not uid:
  27             return _('<p>User <u>%s</u> does not exist<p>') % name
  28         else:
  29             U = user.User (macro.request, id = uid)
  30     else:
  31         U = macro.request.user
  32 
  33     all_pages = wikiutil.getPageList (config.text_dir)
  34 
  35     pages = []
  36     for page in all_pages:
  37         if U.isSubscribedTo ([page]):
  38             pages.append (page)
  39 
  40     if pages == []:
  41         if (name):
  42             result = _('<p>User <u>%s</u> has no subscribed pages<p>') % name
  43         else:
  44             result = _('<p>You have no subscribed pages<p>')
  45     else:
  46         pages.sort ()
  47         result = macro.formatter.bullet_list (1)
  48         for name in pages:
  49             result += macro.formatter.listitem (1)
  50             result += macro.formatter.pagelink (name, generated = 1)
  51             result += macro.formatter.listitem (0)
  52         result += macro.formatter.bullet_list (0)
  53     
  54     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.
  • [get | view] (2008-01-29 21:49:56, 1.6 KB) [[attachment:SubscribedPages.py]]
 All files | Selected Files: delete move to page copy to page

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