1 # -*- coding: iso-8859-1 -*-
3 MoinMoin - Debian theme
5 @copyright: 2003-2005 Nir Soffer, Thomas Waldmann
6 @license: GNU GPL, see COPYING for details.
7 theme modified by Kalle Soderman
10 from MoinMoin.theme import ThemeBase
11 from MoinMoin import wikiutil
12 from MoinMoin.Page import Page
14 class Theme(ThemeBase):
18 _ = lambda x: x # We don't have gettext at this moment, so we fake it
20 # key alt icon filename w h
22 'attach': ("%(attach_count)s", "moin-attach.png", 16, 16),
23 'info': ("[INFO]", "moin-info.png", 16, 16),
24 'attachimg': (_("[ATTACH]"), "attach.png", 32, 32),
26 'rss': (_("[RSS]"), "moin-rss.png", 16, 16),
27 'deleted': (_("[DELETED]"), "moin-deleted.png", 16, 16),
28 'updated': (_("[UPDATED]"), "moin-updated.png", 16, 16),
29 'renamed': (_("[RENAMED]"), "moin-renamed.png", 16, 16),
30 'conflict': (_("[CONFLICT]"), "moin-conflict.png", 16, 16),
31 'new': (_("[NEW]"), "moin-new.png", 16, 16),
32 'diffrc': (_("[DIFF]"), "moin-diff.png", 16, 16),
34 'bottom': (_("[BOTTOM]"), "moin-bottom.png", 16, 16),
35 'top': (_("[TOP]"), "moin-top.png", 16, 16),
36 'www': ("[WWW]", "moin-www.png", 16, 16),
37 'mailto': ("[MAILTO]", "moin-email.png", 16, 16),
38 'news': ("[NEWS]", "moin-news.png", 16, 16),
39 'telnet': ("[TELNET]", "moin-telnet.png", 16, 16),
40 'ftp': ("[FTP]", "moin-ftp.png", 16, 16),
41 'file': ("[FILE]", "moin-ftp.png", 16, 16),
43 'searchbutton': ("[?]", "moin-search.png", 16, 16),
44 'interwiki': ("[%(wikitag)s]", "moin-inter.png", 16, 16),
46 # smileys (this is CONTENT, but good looking smileys depend on looking
47 # adapted to the theme background color and theme style in general)
48 #vvv == vvv this must be the same for GUI editor converter
49 'X-(': ("X-(", 'angry.png', 16, 16),
50 ':D': (":D", 'biggrin.png', 16, 16),
51 '<:(': ("<:(", 'frown.png', 16, 16),
52 ':o': (":o", 'redface.png', 16, 16),
53 ':(': (":(", 'sad.png', 16, 16),
54 ':)': (":)", 'smile.png', 16, 16),
55 'B)': ("B)", 'smile2.png', 16, 16),
56 ':))': (":))", 'smile3.png', 16, 16),
57 ';)': (";)", 'smile4.png', 16, 16),
58 '/!\\': ("/!\\", 'alert.png', 16, 16),
59 '<!>': ("<!>", 'attention.png', 16, 16),
60 '(!)': ("(!)", 'idea.png', 16, 16),
61 ':-?': (":-?", 'tongue.png', 16, 16),
62 ':\\': (":\\", 'ohwell.png', 16, 16),
63 '>:>': (">:>", 'devil.png', 16, 16),
64 '|)': ("|)", 'tired.png', 16, 16),
65 ':-(': (":-(", 'sad.png', 16, 16),
66 ':-)': (":-)", 'smile.png', 16, 16),
67 'B-)': ("B-)", 'smile2.png', 16, 16),
68 ':-))': (":-))", 'smile3.png', 16, 16),
69 ';-)': (";-)", 'smile4.png', 16, 16),
70 '|-)': ("|-)", 'tired.png', 16, 16),
71 '(./)': ("(./)", 'checkmark.png', 16, 16),
72 '{OK}': ("{OK}", 'thumbs-up.png', 16, 16),
73 '{X}': ("{X}", 'icon-error.png', 16, 16),
74 '{i}': ("{i}", 'icon-info.png', 16, 16),
75 '{1}': ("{1}", 'prio1.png', 15, 13),
76 '{2}': ("{2}", 'prio2.png', 15, 13),
77 '{3}': ("{3}", 'prio3.png', 15, 13),
78 '{*}': ("{*}", 'star_on.png', 16, 16),
79 '{o}': ("{o}", 'star_off.png', 16, 16),
82 def header(self, d, **kw):
83 """ Assemble wiki header
85 @param d: parameter dictionary
87 @return: page header html
90 # Pre header custom html
91 self.emit_custom_html(self.cfg.page_header1),
97 u'<div id="domaintools"><p class="section">Wiki</p>',
100 u'<div id="navbar">',
103 u'<div id="breadcrumbs">',
104 u'<a href="/" title="Wiki Homepage">Wiki</a><span class="sep">/</span>',
110 #u'<hr id="pageline">',
112 u'<h1 id="locationline">',
115 u'<div id="pageline"><hr style="display:none;"></div>',
119 # Post header custom html (not recommended)
120 self.emit_custom_html(self.cfg.page_header2),
125 return u'\n'.join(html)
127 def editorheader(self, d, **kw):
128 """ Assemble wiki header for editor
130 @param d: parameter dictionary
132 @return: page header html
135 # Pre header custom html
136 self.emit_custom_html(self.cfg.page_header1),
139 u'<div id="header">',
140 u'<h1 id="locationline">',
146 # Post header custom html (not recommended)
147 self.emit_custom_html(self.cfg.page_header2),
152 return u'\n'.join(html)
154 def footer(self, d, **keywords):
155 """ Assemble wiki footer
157 @param d: parameter dictionary
160 @return: page footer html
168 # Pre footer custom html (not recommended!)
169 self.emit_custom_html(self.cfg.page_footer1),
172 u'<div id="footer">',
175 self.showversion(d, **keywords),
178 # Post footer custom html
179 self.emit_custom_html(self.cfg.page_footer2),
181 return u'\n'.join(html)
184 """ Assemble the title (now using breadcrumbs)
186 @param d: parameter dictionary
190 _ = self.request.getText
192 if d['title_text'] == d['page'].split_title(): # just showing a page, no action
194 segments = d['page_name'].split('/') # was: title_text
195 for s in segments[:-1]:
197 content.append(Page(self.request, curpage).link_to(self.request, s))
199 link_text = segments[-1]
200 link_title = _('Click to do a full-text search for this title')
202 'action': 'fullsearch',
203 'value': 'linkto:"%s"' % d['page_name'],
206 # we dont use d['title_link'] any more, but make it ourselves:
207 link = d['page'].link_to(self.request, link_text, querystr=link_query, title=link_title, css_class='backlink', rel='nofollow')
210 content.append(wikiutil.escape(d['title_text']))
212 location_html = u'<span class="sep">/</span>'.join(content)
213 html = u'<span id="pagelocation">%s</span>' % location_html
216 def username(self, d):
217 """ Assemble the username / userprefs link
219 @param d: parameter dictionary
221 @return: username html
223 request = self.request
227 # Add username/homepage link for registered users. We don't care
228 # if it exists, the user can create it.
229 if request.user.valid and request.user.name:
230 interwiki = wikiutil.getInterwikiHomePage(request)
231 name = request.user.name
232 aliasname = request.user.aliasname
235 title = "%s @ %s" % (aliasname, interwiki[0])
236 # link to (interwiki) user homepage
237 homelink = (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki) +
238 request.formatter.text(name) +
239 request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
240 userlinks.append(homelink)
241 # link to userprefs action
242 if 'userprefs' not in self.request.cfg.actions_excluded:
243 userlinks.append(d['page'].link_to(request, text=_('Settings'),
244 querystr={'action': 'userprefs'}, id='userprefs', rel='nofollow'))
246 if request.user.valid:
247 if request.user.auth_method in request.cfg.auth_can_logout:
248 userlinks.append(d['page'].link_to(request, text=_('Logout'),
249 querystr={'action': 'logout', 'logout': 'logout'}, id='logout', rel='nofollow'))
251 query = {'action': 'login'}
252 # special direct-login link if the auth methods want no input
253 if request.cfg.auth_login_inputs == ['special_no_input']:
255 if request.cfg.auth_have_login:
256 userlinks.append(d['page'].link_to(request, text=_("Login"),
257 querystr=query, id='login', rel='nofollow'))
259 userlinks_html = u'<span class="sep"> | </span>'.join(userlinks)
260 html = u'<div id="username">%s</div>' % userlinks_html
264 """ Assemble page trail
266 @param d: parameter dictionary
270 request = self.request
273 if not user.valid or user.show_page_trail:
274 trail = user.getTrail()
277 for pagename in trail:
279 interwiki, page = wikiutil.split_interwiki(pagename)
280 if interwiki != request.cfg.interwikiname and interwiki != 'Self':
281 link = (self.request.formatter.interwikilink(True, interwiki, page) +
282 self.shortenPagename(page) +
283 self.request.formatter.interwikilink(False, interwiki, page))
291 page = Page(request, pagename)
292 title = page.split_title()
293 title = self.shortenPagename(title)
294 link = page.link_to(request, title)
296 html = u'<div id="pagetrail">%s</div>' % u'<span class="sep">/</span>'.join(items)
299 def interwiki(self, d):
300 """ Assemble the interwiki name display, linking to page_front_page
302 @param d: parameter dictionary
304 @return: interwiki html
306 if self.request.cfg.show_interwiki:
307 page = wikiutil.getFrontPage(self.request)
308 text = self.request.cfg.interwikiname or 'Self'
309 link = page.link_to(self.request, text=text, rel='nofollow')
310 html = u'<span id="interwiki">%s<span class="sep">: </span></span>' % link
315 def execute(request):
317 Generate and return a theme object
319 @param request: the request object
321 @return: Theme object
323 return Theme(request)