Attachment 'modern_iso.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - modern_iso theme + approve support
   4 
   5     @copyright: 2003-2005 by Nir Soffer, Thomas Waldmann, Robert Penz
   6     @license: GNU GPL, see COPYING for details.
   7 """
   8 
   9 import os
  10 
  11 from MoinMoin.theme import ThemeBase
  12 from MoinMoin import i18n, wikiutil, config, version
  13 
  14 class Theme(ThemeBase):
  15 
  16     name = "modern_iso"
  17     _showApproveLink = None
  18 
  19     def approved(self, page):
  20         """ this methods writes approved by xxx into the output and set a flag
  21             which controls the output of the """
  22 
  23         # check whether page exists at all
  24         if not page.exists():
  25             return ""
  26 
  27         approvedFile = os.path.join(page.getPagePath(), "approved")
  28         if os.path.isfile(approvedFile):
  29             approvedRevision = {}
  30             for line in open(approvedFile).readlines():
  31                 tmp = line.split("\t")
  32                 approvedRevision[tmp[0]] = tmp[1]
  33             currentRevision = "%08d" % page.get_real_rev()
  34             if currentRevision in approvedRevision:
  35                 self._showApproveLink = False
  36                 return "approved by " + approvedRevision[currentRevision]
  37         if page.get_real_rev() == page.getRevList()[0]:
  38             self._showApproveLink = True
  39         else:
  40             self._showApproveLink = False
  41         return ""
  42 
  43     def approveLink(self, page):
  44         """ Return approve link to valid users
  45 
  46         @rtype: unicode
  47         @return: approve link
  48         """
  49         _ = self.request.getText
  50 
  51         #if user has perms
  52         title = _("Approve")
  53         quotedname = wikiutil.quoteWikinameURL(page.page_name)
  54         return page.link_to(self.request, text=_('Approve', formatted=False), querystr='action=ApprovePage')
  55 
  56     def editbarItems(self, page):
  57 	""" add our approve stuff to the list """
  58 	
  59 	links = ThemeBase.editbarItems(self,page)
  60 	if self._showApproveLink:
  61 	    if "approve" not in self.request.cfg.actions_excluded and self.request.user.may.approve(page.page_name):
  62 		links.append(self.approveLink(page))
  63 	return links
  64 
  65     def header(self, d, **kw):
  66         """ Assemble wiki header
  67 
  68         @param d: parameter dictionary
  69         @rtype: unicode
  70         @return: page header html
  71         """
  72         revision = self.request.page.rev or self.request.page.get_real_rev()
  73         html = [
  74             # Pre header custom html
  75             self.emit_custom_html(self.cfg.page_header1),
  76 
  77             # Header
  78             u'<div id="header">',
  79             self.logo(),
  80             self.searchform(d),
  81             self.username(d),
  82             self.trail(d),
  83             self.navibar(d),
  84             self.approved(d['page']),
  85             #u'<hr id="pageline">',
  86             u'<div id="pageline"><hr style="display:none;"></div>',
  87             self.msg(d),
  88             self.editbar(d),
  89             u'</div>',
  90 
  91             # Post header custom html (not recommended)
  92             self.emit_custom_html(self.cfg.page_header2),
  93 
  94             # Start of page
  95             self.startPage(),
  96             self.title(d),
  97         ]
  98         return u'\n'.join(html)
  99 
 100     def editorheader(self, d, **kw):
 101         """ Assemble wiki header for editor
 102 
 103         @param d: parameter dictionary
 104         @rtype: unicode
 105         @return: page header html
 106         """
 107         html = [
 108             # Pre header custom html
 109             self.emit_custom_html(self.cfg.page_header1),
 110 
 111             # Header
 112             u'<div id="header">',
 113             self.msg(d),
 114             u'</div>',
 115 
 116             # Post header custom html (not recommended)
 117             self.emit_custom_html(self.cfg.page_header2),
 118 
 119             # Start of page
 120             self.startPage(),
 121         ]
 122         return u'\n'.join(html)
 123 
 124     def footer(self, d, **keywords):
 125         """ Assemble wiki footer
 126 
 127         @param d: parameter dictionary
 128         @keyword ...:...
 129         @rtype: unicode
 130         @return: page footer html
 131         """
 132         page = d['page']
 133         html = [
 134             # End of page
 135             self.pageinfo(page),
 136             self.endPage(),
 137 
 138             # Pre footer custom html (not recommended!)
 139             self.emit_custom_html(self.cfg.page_footer1),
 140 
 141             # Footer
 142             u'<div id="footer">',
 143             self.editbar(d),
 144             self.credits(d),
 145             self.showversion(d, **keywords),
 146             u'</div>',
 147 
 148             # Post footer custom html
 149             self.emit_custom_html(self.cfg.page_footer2),
 150             ]
 151         return u'\n'.join(html)
 152 
 153 
 154 def execute(request):
 155     """
 156     Generate and return a theme object
 157 
 158     @param request: the request object
 159     @rtype: MoinTheme
 160     @return: Theme object
 161     """
 162     return Theme(request)

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] (2010-02-05 17:13:18, 2.6 KB) [[attachment:ApprovePage-191.py]]
  • [get | view] (2005-10-18 14:16:34, 2.8 KB) [[attachment:ApprovePage.py]]
  • [get | view] (2005-11-08 14:48:57, 2.9 KB) [[attachment:ApprovePage.py-20050811]]
  • [get | view] (2005-11-08 14:51:44, 2.9 KB) [[attachment:ApprovePage.py-20050811-2]]
  • [get | view] (2010-11-18 09:43:04, 7.1 KB) [[attachment:Page.diff-v193-18112010]]
  • [get | view] (2010-02-05 17:15:25, 78.1 KB) [[attachment:Page.py]]
  • [get | view] (2010-11-18 09:41:22, 79.2 KB) [[attachment:Page.py-v193-18112010]]
  • [get | view] (2010-02-05 17:15:58, 4.3 KB) [[attachment:Page.py.patch]]
  • [get | view] (2008-02-12 01:09:14, 4.3 KB) [[attachment:PageApproval.diff]]
  • [get | view] (2010-02-05 17:25:50, 21.4 KB) [[attachment:approval-history.png]]
  • [get | view] (2010-11-18 10:19:10, 2.4 KB) [[attachment:approvePage.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:20, 3.0 KB) [[attachment:approvepage2.py]]
  • [get | view] (2005-10-18 14:17:03, 4.5 KB) [[attachment:modern.py]]
  • [get | view] (2010-11-18 09:42:23, 3.8 KB) [[attachment:modern_iso.diff-v193-18112010]]
  • [get | view] (2005-11-08 14:48:07, 4.6 KB) [[attachment:modern_iso.py]]
  • [get | view] (2010-11-18 09:40:06, 6.2 KB) [[attachment:modern_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:00, 4.9 KB) [[attachment:modern_iso2.py]]
  • [get | view] (2010-11-18 09:40:39, 15.0 KB) [[attachment:modernized_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:39, 1.5 KB) [[attachment:page.diff]]
  • [get | view] (2010-11-18 10:10:42, 7.2 KB) [[attachment:rightsidebar_iso.py-v193-18112010]]
  • [get | view] (2010-02-05 17:13:56, 29.0 KB) [[attachment:solenoid_iso-191.py]]
  • [get | view] (2010-02-05 17:15:05, 1.4 KB) [[attachment:solenoid_iso-191.py.patch]]
 All files | Selected Files: delete move to page copy to page

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