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