Attachment 'PageActions.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 
   3 import re
   4 from MoinMoin import config, wikiutil
   5 from MoinMoin.Page import Page
   6 
   7 # Ripped from the LikePages action
   8 def execute(pagename, request):
   9     _ = request.getText
  10     from MoinMoin.formatter.text_html import Formatter
  11     request.formatter = Formatter(request)
  12 
  13     request.http_headers()
  14 
  15     # This action generate data using the user language
  16     request.setContentLanguage(request.lang)
  17     wikiutil.send_title(request, _('Actions for %s') % pagename, pagename=pagename)
  18         
  19     # Start content - IMPORTANT - without content div, there is no
  20     # direction support!
  21     request.write(request.formatter.startContent("content"))
  22 
  23     # Just list the actions
  24     request.write(availableactions(request))
  25 
  26     # End content and send footer
  27     request.write(request.formatter.endContent())
  28     wikiutil.send_footer(request, pagename)
  29 
  30 # Make a link to action
  31 def actionlink(request, action, title, comment=''):
  32     page = request.page
  33     _ = request.getText
  34     # Always add spaces: AttachFile -> Attach File 
  35     # XXX TODO do not make a page object just for split_title
  36     title = Page(request, title).split_title(request, force=1)
  37     # Use translated version if available
  38     title = _(title, formatted=False)
  39     params = '%s?action=%s' % (page.page_name, action)
  40     link = wikiutil.link_tag(request, params, _(title))
  41     return u''.join([ u'<li>', link, comment, u'</li>' ])
  42 
  43 
  44 # Rippped from the theme code
  45 def availableactions(request):
  46     page = request.page
  47     _ = request.getText
  48     html = ''
  49     links = []
  50     available = request.getAvailableActions(page)
  51     available = available.keys()
  52     for action in available:
  53         links.append(actionlink(request, action, action))
  54     if page.isWritable() and request.user.may.write(page.page_name):
  55         links.append(actionlink(request, 'edit', 'EditText'))
  56     if request.user.valid and request.user.email:
  57         action = ("Subscribe", "Unsubscribe")[request.user.isSubscribedTo([page.page_name])]
  58         links.append(actionlink(request, 'subscribe', action))
  59     if request.user.valid:
  60         links.append(actionlink(request, 'userform&logout=logout', 'Logout'))
  61     links.append(actionlink(request, 'print', 'PrintView'))
  62     links.append(actionlink(request, 'raw', 'ViewRawText'))
  63     links.append(actionlink(request, 'refresh', 'DeleteCache'))
  64     html = u'<ul>%s</ul>' % u''.join(links)
  65     return html

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] (2007-10-07 20:56:36, 2.4 KB) [[attachment:PageActions.py]]
  • [get | view] (2008-12-09 22:52:47, 36.3 KB) [[attachment:editbar_layoutproblem.png]]
  • [get | view] (2008-09-03 20:52:17, 39.8 KB) [[attachment:greenmist-1.0-moin-1.7.1.tar.gz]]
  • [get | view] (2007-03-19 09:13:53, 39.5 KB) [[attachment:greenmist-1.0.tar.gz]]
  • [get | view] (2007-03-19 00:05:29, 32.7 KB) [[attachment:greenmist.png]]
 All files | Selected Files: delete move to page copy to page

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