|
0
|
1 # -*- coding: iso-8859-1 -*-
|
|
|
2 """
|
|
|
3 MoinMoin acm theme
|
|
|
4
|
|
|
5 Based on the classic theme.
|
|
|
6
|
|
|
7 @copyright: 2006 by RadomirDopieralski (moose@sheep.prv.pl)
|
|
|
8 @license: GNU GPL, see COPYING for details.
|
|
|
9 """
|
|
|
10
|
|
|
11 from MoinMoin import wikiutil, version
|
|
|
12 from MoinMoin import caching
|
|
|
13 from MoinMoin.theme import ThemeBase
|
|
|
14 from MoinMoin.theme import rightsidebar
|
|
|
15 from MoinMoin.Page import Page
|
|
|
16
|
|
|
17 class Theme(rightsidebar.Theme):
|
|
|
18 """ here are the functions generating the html responsible for
|
|
|
19 the look and feel of your wiki site
|
|
|
20 """
|
|
|
21
|
|
|
22 name = "dew"
|
|
|
23
|
|
|
24 # fake _ function to get gettext recognize those texts:
|
|
|
25 _ = lambda x: x
|
|
|
26
|
|
|
27 # TODO: remove icons that are not used any more.
|
|
|
28 icons = {
|
|
|
29 # key alt icon filename w h
|
|
|
30 # ------------------------------------------------------------------
|
|
|
31 # navibar
|
|
|
32 'help': ("%(page_help_contents)s", "moin-help.gif", 24, 24),
|
|
|
33 'find': ("%(page_find_page)s", "moin-search.gif", 24, 24),
|
|
|
34 'diff': (_("Diffs"), "moin-diff.gif", 24, 24),
|
|
|
35 'info': (_("Info"), "moin-info.gif", 24, 24),
|
|
|
36 'edit': (_("Edit"), "moin-edit.gif", 24, 24),
|
|
|
37 'unsubscribe':(_("Unsubscribe"), "moin-unsubscribe.gif", 24, 24),
|
|
|
38 'subscribe': (_("Subscribe"), "moin-subscribe.gif", 24, 24),
|
|
|
39 'raw': (_("Raw"), "moin-raw.gif", 24, 24),
|
|
|
40 'xml': (_("XML"), "moin-xml.gif", 24, 24),
|
|
|
41 'print': (_("Print"), "moin-print.gif", 24, 24),
|
|
|
42 'view': (_("View"), "moin-show.gif", 24, 24),
|
|
|
43 'home': (_("Home"), "moin-home.gif", 24, 24),
|
|
|
44 'up': (_("Up"), "moin-parent.gif", 23, 23),
|
|
|
45 # FileAttach
|
|
|
46 'attach': ("%(attach_count)s", "moin-attach.gif", 24, 24),
|
|
|
47 # RecentChanges
|
|
|
48 'rss': (_("[RSS]"), "moin-rss.png", 36, 14),
|
|
|
49 'deleted': (_("[DELETED]"), "moin-delete.gif", 24, 24),
|
|
|
50 'updated': (_("[UPDATED]"), "moin-show.gif",24, 24),
|
|
|
51 'new': (_("[NEW]"), "moin-edit.gif", 24, 24),
|
|
|
52 'diffrc': (_("[DIFF]"), "moin-diff.gif", 24, 24),
|
|
|
53 # General
|
|
|
54 'bottom': (_("[BOTTOM]"), "moin-bottom.gif", 14, 10),
|
|
|
55 'top': (_("[TOP]"), "moin-top.gif", 14, 10),
|
|
|
56 'www': ("[WWW]", "moin-www.gif", 11, 11),
|
|
|
57 'mailto': ("[MAILTO]", "moin-email.gif", 14, 10),
|
|
|
58 'news': ("[NEWS]", "moin-news.gif", 10, 11),
|
|
|
59 'telnet': ("[TELNET]", "moin-telnet.gif", 10, 11),
|
|
|
60 'ftp': ("[FTP]", "moin-ftp.gif", 11, 11),
|
|
|
61 'file': ("[FILE]", "moin-ftp.gif", 11, 11),
|
|
|
62 # search forms
|
|
|
63 'searchbutton': ("[?]", "moin-search.gif", 12, 12),
|
|
|
64 'interwiki': ("[%(wikitag)s]", "moin-inter.gif", 16, 16),
|
|
|
65 }
|
|
|
66 del _
|
|
|
67
|
|
|
68 def footer(self, d, **keywords):
|
|
|
69 """ Assemble wiki footer
|
|
|
70
|
|
|
71 @param d: parameter dictionary
|
|
|
72 @keyword ...:...
|
|
|
73 @rtype: unicode
|
|
|
74 @return: page footer html
|
|
|
75 """
|
|
|
76 page = d['page']
|
|
|
77 dict = {
|
|
|
78 'username_html': self.username(d),
|
|
|
79 'page_footer1': self.emit_custom_html(self.cfg.page_footer1),
|
|
|
80 'page_footer2': self.emit_custom_html(self.cfg.page_footer2),
|
|
|
81 'page_info': self.pageinfo(page),
|
|
|
82 'end_page': self.endPage(),
|
|
|
83 'credits': self.credits(d),
|
|
|
84 'version': self.showversion(d, **keywords),
|
|
|
85 'navibar_html': self.navibar(d),
|
|
|
86 'search_form_html': self.searchform(d),
|
|
|
87 'editbar': self.editbar(d),
|
|
|
88 }
|
|
|
89 if not self.in_editor:
|
|
|
90 return u'''
|
|
|
91 %(page_info)s%(end_page)s</div><div class="menu">
|
|
|
92 <h1>Menu</h1>
|
|
|
93 %(navibar_html)s
|
|
|
94 %(search_form_html)s
|
|
|
95 %(editbar)s
|
|
|
96 </div><div class="footer"><div id="footer">
|
|
|
97 %(page_footer1)s
|
|
|
98 %(username_html)s
|
|
|
99 %(page_footer2)s
|
|
|
100 %(credits)s
|
|
|
101 %(version)s
|
|
|
102 </div></div></div></div></div>
|
|
|
103 '''%dict
|
|
|
104 else:
|
|
|
105 return u'''
|
|
|
106 %(page_info)s
|
|
|
107 %(end_page)s
|
|
|
108 </div>
|
|
|
109 '''%dict
|
|
|
110
|
|
|
111 def iconbar(self, d):
|
|
|
112 """
|
|
|
113 Assemble the iconbar
|
|
|
114
|
|
|
115 @param d: parameter dictionary
|
|
|
116 @rtype: string
|
|
|
117 @return: iconbar html
|
|
|
118 """
|
|
|
119 iconbar = []
|
|
|
120 if self.cfg.page_iconbar and self.request.user.show_toolbar and d['page_name']:
|
|
|
121 iconbar.append('<ul id="iconbar">\n')
|
|
|
122 icons = self.cfg.page_iconbar[:]
|
|
|
123 for icon in icons:
|
|
|
124 if icon == "up":
|
|
|
125 if d['page_parent_page']:
|
|
|
126 iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
|
|
|
127 elif icon == "subscribe" and self.cfg.mail_enabled:
|
|
|
128 iconbar.append('<li>%s</li>\n' % self.make_iconlink(
|
|
|
129 ["subscribe", "unsubscribe"][self.request.user.isSubscribedTo([d['page_name']])], d))
|
|
|
130 else:
|
|
|
131 iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
|
|
|
132 iconbar.append('</ul>\n')
|
|
|
133 return ''.join(iconbar)
|
|
|
134
|
|
|
135 def header(self, d):
|
|
|
136 """
|
|
|
137 Assemble page header
|
|
|
138
|
|
|
139 @param d: parameter dictionary
|
|
|
140 @rtype: string
|
|
|
141 @return: page header html
|
|
|
142 """
|
|
|
143 self.in_editor = False;
|
|
|
144
|
|
|
145 dict = {
|
|
|
146 'config_header1_html': self.emit_custom_html(self.cfg.page_header1),
|
|
|
147 'config_header2_html': self.emit_custom_html(self.cfg.page_header2),
|
|
|
148 'logo_html': self.logo(),
|
|
|
149 'title_html': self.title(d),
|
|
|
150 'msg_html': self.msg(d),
|
|
|
151 'trail_html': self.trail(d),
|
|
|
152 'startpage_html': self.startPage(),
|
|
|
153 'interwiki_html': self.interwiki(d),
|
|
|
154 'iconbar_html': self.iconbar(d),
|
|
|
155 }
|
|
|
156 dict.update(d)
|
|
|
157
|
|
|
158 #<div id="locationline">%(interwiki_html)s%(title_html)s</div>
|
|
|
159 html = """
|
|
|
160 %(config_header1_html)s
|
|
|
161 <div class="cont1"><div class="cont2"><div class="cont3">
|
|
|
162 <div id="header"><div class="header">
|
|
|
163 %(logo_html)s
|
|
|
164 </div><div class="bar">
|
|
|
165 <div id="traildiv">%(trail_html)s</div>
|
|
|
166 %(msg_html)s
|
|
|
167 </div></div>%(config_header2_html)s<div class="content">%(iconbar_html)s%(startpage_html)s
|
|
|
168 """ % dict
|
|
|
169 return html
|
|
|
170
|
|
|
171 def editorheader(self, d):
|
|
|
172 """
|
|
|
173 Assemble page header for editor
|
|
|
174
|
|
|
175 @param d: parameter dictionary
|
|
|
176 @rtype: string
|
|
|
177 @return: page header html
|
|
|
178 """
|
|
|
179 self.in_editor = True;
|
|
|
180
|
|
|
181 dict = {
|
|
|
182 'config_header1_html': self.emit_custom_html(self.cfg.page_header1),
|
|
|
183 'config_header2_html': self.emit_custom_html(self.cfg.page_header2),
|
|
|
184 'title_html': self.title(d),
|
|
|
185 'msg_html': self.msg(d),
|
|
|
186 'startpage_html': self.startPage(),
|
|
|
187 }
|
|
|
188 dict.update(d)
|
|
|
189
|
|
|
190 html = """
|
|
|
191 <div class="editor">
|
|
|
192 %(config_header1_html)s
|
|
|
193
|
|
|
194 %(title_html)s
|
|
|
195 %(msg_html)s
|
|
|
196
|
|
|
197 %(config_header2_html)s
|
|
|
198
|
|
|
199 %(startpage_html)s
|
|
|
200 """ % dict
|
|
|
201 return html
|
|
|
202
|
|
|
203 def editbar(self, d):
|
|
|
204 if self.request.user.valid:
|
|
|
205 return rightsidebar.Theme.editbar(self, d)
|
|
|
206 else:
|
|
|
207 return ''
|
|
|
208
|
|
|
209 def recentchanges_entry(self, d):
|
|
|
210 """
|
|
|
211 Assemble a single recentchanges entry (table row)
|
|
|
212
|
|
|
213 @param d: parameter dictionary
|
|
|
214 @rtype: string
|
|
|
215 @return: recentchanges entry html
|
|
|
216 """
|
|
|
217 _ = self.request.getText
|
|
|
218 html = []
|
|
|
219 html.append('<tr>\n')
|
|
|
220
|
|
|
221 html.append('<td class="rcicon1">%(icon_html)s</td>\n' % d)
|
|
|
222
|
|
|
223 html.append('<td class="rcpagelink">%(pagelink_html)s</td>\n' % d)
|
|
|
224
|
|
|
225 html.append('<td class="rctime">')
|
|
|
226 if d['time_html']:
|
|
|
227 html.append("%(time_html)s" % d)
|
|
|
228 html.append('</td>\n')
|
|
|
229
|
|
|
230 html.append('<td class="rcicon2">%(info_html)s</td>\n' % d)
|
|
|
231
|
|
|
232 html.append('<td class="rceditor">')
|
|
|
233 if d['editors']:
|
|
|
234 html.append('<br>'.join(d['editors']))
|
|
|
235 html.append('</td>\n')
|
|
|
236
|
|
|
237 html.append('</tr><tr class="rccomment">')
|
|
|
238 html.append('<td class="rccomment" colspan="5">')
|
|
|
239 if d['comments']:
|
|
|
240 if d['changecount'] > 1:
|
|
|
241 notfirst = 0
|
|
|
242 for comment in d['comments']:
|
|
|
243 html.append('%s<tt>#%02d</tt> %s' % (
|
|
|
244 notfirst and '<br>' or '' , comment[0], comment[1]))
|
|
|
245 notfirst = 1
|
|
|
246 else:
|
|
|
247 comment = d['comments'][0]
|
|
|
248 html.append('%s' % comment[1])
|
|
|
249 html.append('</td>\n')
|
|
|
250
|
|
|
251 html.append('</tr>\n')
|
|
|
252
|
|
|
253 return ''.join(html)
|
|
|
254
|