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.You are not allowed to attach a file to this page.