1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
# -*- coding: utf-8 -*-
"""
MoinMoin - c3hl theme
@copyright: 2010 C3-HL
@license: GNU GPL, see COPYING for details.
"""
from MoinMoin.theme import ThemeBase
from MoinMoin import wikiutil
from MoinMoin.Page import Page
class Theme(ThemeBase):
name = "c3hl"
_ = lambda x: x # We don't have gettext at this moment, so we fake it
icons = {
# key alt icon filename w h
# FileAttach
'attach': ("%(attach_count)s", "moin-attach.png", 16, 16),
'info': ("[INFO]", "moin-info.png", 16, 16),
'attachimg': (_("[ATTACH]"), "attach.png", 32, 32),
# RecentChanges
'rss': (_("[RSS]"), "moin-rss.png", 16, 16),
'deleted': (_("[DELETED]"), "moin-deleted.png", 16, 16),
'updated': (_("[UPDATED]"), "moin-updated.png", 16, 16),
'renamed': (_("[RENAMED]"), "moin-renamed.png", 16, 16),
'conflict': (_("[CONFLICT]"), "moin-conflict.png", 16, 16),
'new': (_("[NEW]"), "moin-new.png", 16, 16),
'diffrc': (_("[DIFF]"), "moin-diff.png", 16, 16),
# General
'bottom': (_("[BOTTOM]"), "moin-bottom.png", 16, 16),
'top': (_("[TOP]"), "moin-top.png", 16, 16),
'www': ("[WWW]", "moin-www.png", 16, 16),
'mailto': ("[MAILTO]", "moin-email.png", 16, 16),
'news': ("[NEWS]", "moin-news.png", 16, 16),
'telnet': ("[TELNET]", "moin-telnet.png", 16, 16),
'ftp': ("[FTP]", "moin-ftp.png", 16, 16),
'file': ("[FILE]", "moin-ftp.png", 16, 16),
# search forms
'searchbutton': ("[?]", "moin-search.png", 16, 16),
'interwiki': ("[%(wikitag)s]", "moin-inter.png", 16, 16),
# smileys (this is CONTENT, but good looking smileys depend on looking
# adapted to the theme background color and theme style in general)
#vvv == vvv this must be the same for GUI editor converter
'X-(': ("X-(", 'angry.png', 16, 16),
':D': (":D", 'biggrin.png', 16, 16),
'<:(': ("<:(", 'frown.png', 16, 16),
':o': (":o", 'redface.png', 16, 16),
':(': (":(", 'sad.png', 16, 16),
':)': (":)", 'smile.png', 16, 16),
'B)': ("B)", 'smile2.png', 16, 16),
':))': (":))", 'smile3.png', 16, 16),
';)': (";)", 'smile4.png', 16, 16),
'/!\\': ("/!\\", 'alert.png', 16, 16),
'<!>': ("<!>", 'attention.png', 16, 16),
'(!)': ("(!)", 'idea.png', 16, 16),
':-?': (":-?", 'tongue.png', 16, 16),
':\\': (":\\", 'ohwell.png', 16, 16),
'>:>': (">:>", 'devil.png', 16, 16),
'|)': ("|)", 'tired.png', 16, 16),
':-(': (":-(", 'sad.png', 16, 16),
':-)': (":-)", 'smile.png', 16, 16),
'B-)': ("B-)", 'smile2.png', 16, 16),
':-))': (":-))", 'smile3.png', 16, 16),
';-)': (";-)", 'smile4.png', 16, 16),
'|-)': ("|-)", 'tired.png', 16, 16),
'(./)': ("(./)", 'checkmark.png', 16, 16),
'{OK}': ("{OK}", 'thumbs-up.png', 16, 16),
'{X}': ("{X}", 'icon-error.png', 16, 16),
'{i}': ("{i}", 'icon-info.png', 16, 16),
'{1}': ("{1}", 'prio1.png', 15, 13),
'{2}': ("{2}", 'prio2.png', 15, 13),
'{3}': ("{3}", 'prio3.png', 15, 13),
'{*}': ("{*}", 'star_on.png', 16, 16),
'{o}': ("{o}", 'star_off.png', 16, 16),
}
del _
def shouldShowEditbar(self, page):
if not (page.isWritable() and
self.request.user.may.write(page.page_name)):
return False
return ThemeBase.shouldShowEditbar(self, page)
def topnav(self, d):
request = self.request
links = []
for pagename in request.cfg.topnav:
page = Page(request, pagename)
title = page.split_title()
title = self.shortenPagename(title)
link = page.link_to(request, title)
links.append(link)
return '<div id="topnav">%s</div>' % '<span class="sep"> | </span>'.join(links)
def parentlinks(self, d):
_ = self.request.getText
segments = d['page_name'].split('/')
if len(segments) <= 1:
return ''
content = []
curpage = ''
for s in segments[:-1]:
curpage += s
content.append(Page(self.request,
curpage).link_to(self.request, s))
curpage += '/'
path_html = u'<span class="sep"> | </span>'.join(content)
return u'<div id="parentlinks">Zurück zu: %s</div>' % path_html
def remoteip(self):
nologging = u'Dieser Server loggt keine IP-Adressen.'
addr = self.request.environ['REMOTE_ADDR']
return u'<div id="ipinfo"><div id="remoteip">Deine IP-Adresse ist %s</div><div id="nologging">%s</div></div>' % (addr, nologging)
return ''
def header(self, d, **kw):
""" Assemble wiki header
@param d: parameter dictionary
@rtype: unicode
@return: page header html
"""
html = [
# Pre header custom html
self.emit_custom_html(self.cfg.page_header1),
# Header
u'<div id="pagehead">',
self.topnav(d),
self.username(d),
u'</div>',
u'<div id="wrapper">',
u'<div id="logoright">',
u'<div id="logoleft">',
self.logo(),
u'</div>',
u'</div>',
u'<div id="header">',
#self.trail(d),
self.navibar(d),
self.searchform(d),
#u'<hr id="pageline">',
u'<div id="pageline"><hr style="display:none;"></div>',
self.msg(d),
self.editbar(d),
u'</div>',
u'<div id="pagewrapper">',
self.parentlinks(d),
#u'<h1 id="locationline">',
#self.title_with_separators(d),
#u'</h1>',
# Post header custom html (not recommended)
self.emit_custom_html(self.cfg.page_header2),
# Start of page
self.startPage(),
]
return u'\n'.join(html)
def editorheader(self, d, **kw):
""" Assemble wiki header for editor
@param d: parameter dictionary
@rtype: unicode
@return: page header html
"""
html = [
# Pre header custom html
self.emit_custom_html(self.cfg.page_header1),
# Header
u'<div id="wrapper">',
u'<div id="header">',
self.msg(d),
u'</div>',
u'<div id="pagewrapper">',
u'<h1 id="locationline">',
self.title_with_separators(d),
u'</h1>',
# Post header custom html (not recommended)
self.emit_custom_html(self.cfg.page_header2),
# Start of page
self.startPage(),
]
return u'\n'.join(html)
def footer(self, d, **keywords):
""" Assemble wiki footer
@param d: parameter dictionary
@keyword ...:...
@rtype: unicode
@return: page footer html
"""
page = d['page']
html = [
# End of page
self.pageinfo(page),
self.endPage(),
# Pre footer custom html (not recommended!)
self.emit_custom_html(self.cfg.page_footer1),
u'</div>',
# Footer
u'<div id="footer">',
#self.editbar(d),
self.credits(d),
self.showversion(d, **keywords),
self.remoteip(),
u'</div>',
u'</div>',
# Post footer custom html
self.emit_custom_html(self.cfg.page_footer2),
]
return u'\n'.join(html)
def username(self, d):
""" Assemble the username / userprefs link
@param d: parameter dictionary
@rtype: unicode
@return: username html
"""
request = self.request
_ = request.getText
userlinks = []
# Add username/homepage link for registered users. We don't care
# if it exists, the user can create it.
if request.user.valid and request.user.name:
interwiki = wikiutil.getInterwikiHomePage(request)
name = request.user.name
aliasname = request.user.aliasname
if not aliasname:
aliasname = name
title = "%s @ %s" % (aliasname, interwiki[0])
# link to (interwiki) user homepage
homelink = (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki) +
request.formatter.text(name) +
request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
userlinks.append(homelink)
# link to userprefs action
if 'userprefs' not in self.request.cfg.actions_excluded:
userlinks.append(d['page'].link_to(request, text=_('Settings'),
querystr={'action': 'userprefs'}, id='userprefs', rel='nofollow'))
if request.user.valid:
if request.user.auth_method in request.cfg.auth_can_logout:
userlinks.append(d['page'].link_to(request, text=_('Logout'),
querystr={'action': 'logout', 'logout': 'logout'}, id='logout', rel='nofollow'))
else:
query = {'action': 'login'}
# special direct-login link if the auth methods want no input
if request.cfg.auth_login_inputs == ['special_no_input']:
query['login'] = '1'
if request.cfg.auth_have_login:
userlinks.append(d['page'].link_to(request, text=_("Login"),
querystr=query, id='login', rel='nofollow'))
userlinks.append('<a href="https://%s%s" id="certlogin" rel="nofollow">Anmelden mit Client-Zertifikat</a>'
% (request.cfg.clientcerthost, d['page'].url(request)))
userlinks_html = u'<span class="sep"> | </span>'.join(userlinks)
html = u'<div id="username">%s</div>' % userlinks_html
return html
def trail(self, d):
""" Assemble page trail
@param d: parameter dictionary
@rtype: unicode
@return: trail html
"""
request = self.request
user = request.user
html = ''
if not user.valid or user.show_page_trail:
trail = user.getTrail()
if trail:
items = []
for pagename in trail:
try:
interwiki, page = wikiutil.split_interwiki(pagename)
if interwiki != request.cfg.interwikiname and interwiki != 'Self':
link = (self.request.formatter.interwikilink(True, interwiki, page) +
self.shortenPagename(page) +
self.request.formatter.interwikilink(False, interwiki, page))
items.append(link)
continue
else:
pagename = page
except ValueError:
pass
page = Page(request, pagename)
title = page.split_title()
title = self.shortenPagename(title)
link = page.link_to(request, title)
items.append(link)
html = u'<div id="pagetrail">%s</div>' % u'<span class="sep"> » </span>'.join(items)
return html
def interwiki(self, d):
""" Assemble the interwiki name display, linking to page_front_page
@param d: parameter dictionary
@rtype: string
@return: interwiki html
"""
if self.request.cfg.show_interwiki:
page = wikiutil.getFrontPage(self.request)
text = self.request.cfg.interwikiname or 'Self'
link = page.link_to(self.request, text=text, rel='nofollow')
html = u'<span id="interwiki">%s<span class="sep">: </span></span>' % link
else:
html = u''
return html
def execute(request):
"""
Generate and return a theme object
@param request: the request object
@rtype: MoinTheme
@return: Theme object
"""
return Theme(request)
|