Attachment 'modern_iso2.py'

Download

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