1 # -*- coding: iso-8859-1 -*-
3 MoinMoin - modern theme
5 @copyright: 2003-2005 Nir Soffer, Thomas Waldmann
6 @license: GNU GPL, see COPYING for details.
9 from MoinMoin.theme import ThemeBase
10 from MoinMoin import wikiutil
11 from MoinMoin.Page import Page
13 class Theme(ThemeBase):
17 _ = lambda x: x # We don't have gettext at this moment, so we fake it
19 # key alt icon filename w h
21 'attach': ("%(attach_count)s", "moin-attach.png", 16, 16),
22 'info': ("[INFO]", "moin-info.png", 16, 16),
23 'attachimg': (_("[ATTACH]"), "attach.png", 32, 32),
25 'rss': (_("[RSS]"), "moin-rss.png", 16, 16),
26 'deleted': (_("[DELETED]"), "moin-deleted.png", 16, 16),
27 'updated': (_("[UPDATED]"), "moin-updated.png", 16, 16),
28 'renamed': (_("[RENAMED]"), "moin-renamed.png", 16, 16),
29 'conflict': (_("[CONFLICT]"), "moin-conflict.png", 16, 16),
30 'new': (_("[NEW]"), "moin-new.png", 16, 16),
31 'diffrc': (_("[DIFF]"), "moin-diff.png", 16, 16),
33 'bottom': (_("[BOTTOM]"), "moin-bottom.png", 16, 16),
34 'top': (_("[TOP]"), "moin-top.png", 16, 16),
35 'www': ("[WWW]", "moin-www.png", 16, 16),
36 'mailto': ("[MAILTO]", "moin-email.png", 16, 16),
37 'news': ("[NEWS]", "moin-news.png", 16, 16),
38 'telnet': ("[TELNET]", "moin-telnet.png", 16, 16),
39 'ftp': ("[FTP]", "moin-ftp.png", 16, 16),
40 'file': ("[FILE]", "moin-ftp.png", 16, 16),
42 'searchbutton': ("[?]", "moin-search.png", 16, 16),
43 'interwiki': ("[%(wikitag)s]", "moin-inter.png", 16, 16),
45 # smileys (this is CONTENT, but good looking smileys depend on looking
46 # adapted to the theme background color and theme style in general)
47 #vvv == vvv this must be the same for GUI editor converter
48 'X-(': ("X-(", 'angry.png', 16, 16),
49 ':D': (":D", 'biggrin.png', 16, 16),
50 '<:(': ("<:(", 'frown.png', 16, 16),
51 ':o': (":o", 'redface.png', 16, 16),
52 ':(': (":(", 'sad.png', 16, 16),
53 ':)': (":)", 'smile.png', 16, 16),
54 'B)': ("B)", 'smile2.png', 16, 16),
55 ':))': (":))", 'smile3.png', 16, 16),
56 ';)': (";)", 'smile4.png', 16, 16),
57 '/!\\': ("/!\\", 'alert.png', 16, 16),
58 '<!>': ("<!>", 'attention.png', 16, 16),
59 '(!)': ("(!)", 'idea.png', 16, 16),
60 ':-?': (":-?", 'tongue.png', 16, 16),
61 ':\\': (":\\", 'ohwell.png', 16, 16),
62 '>:>': (">:>", 'devil.png', 16, 16),
63 '|)': ("|)", 'tired.png', 16, 16),
64 ':-(': (":-(", 'sad.png', 16, 16),
65 ':-)': (":-)", 'smile.png', 16, 16),
66 'B-)': ("B-)", 'smile2.png', 16, 16),
67 ':-))': (":-))", 'smile3.png', 16, 16),
68 ';-)': (";-)", 'smile4.png', 16, 16),
69 '|-)': ("|-)", 'tired.png', 16, 16),
70 '(./)': ("(./)", 'checkmark.png', 16, 16),
71 '{OK}': ("{OK}", 'thumbs-up.png', 16, 16),
72 '{X}': ("{X}", 'icon-error.png', 16, 16),
73 '{i}': ("{i}", 'icon-info.png', 16, 16),
74 '{1}': ("{1}", 'prio1.png', 15, 13),
75 '{2}': ("{2}", 'prio2.png', 15, 13),
76 '{3}': ("{3}", 'prio3.png', 15, 13),
77 '{*}': ("{*}", 'star_on.png', 16, 16),
78 '{o}': ("{o}", 'star_off.png', 16, 16),
81 def header(self, d, **kw):
82 """ Assemble wiki header
84 @param d: parameter dictionary
86 @return: page header html
89 # Pre header custom html
90 self.emit_custom_html(self.cfg.page_header1),
94 u'<div id="wikisection">',
95 u'<p class="section"><a href="/" title="Debian Wiki Homepage">Wiki</a></p>',
104 #u'<a href="/" title="wiki home">Wiki</a> / ',
105 u'<div id="breadcrumbs"><a href="/" title="Debian Wiki Homepage">Wiki</a><span class="sep">/</span>',self.trail(d),
107 #u'<hr id="pageline">',
108 #u'<div id="pageline"><hr style="display:none;"></div>',
111 u'<h1 id="locationline">',
113 #self.title_with_separators(d),
118 # Post header custom html (not recommended)
119 self.emit_custom_html(self.cfg.page_header2),
124 return u'\n'.join(html)
126 def editorheader(self, d, **kw):
127 """ Assemble wiki header for editor
129 @param d: parameter dictionary
131 @return: page header html
134 # Pre header custom html
135 self.emit_custom_html(self.cfg.page_header1),
138 u'<div id="header">',
139 u'<h1 id="locationline">',
140 self.title_with_separators(d),
145 # Post header custom html (not recommended)
146 self.emit_custom_html(self.cfg.page_header2),
151 return u'\n'.join(html)
153 def footer(self, d, **keywords):
154 """ Assemble wiki footer
156 @param d: parameter dictionary
159 @return: page footer html
166 # Pre footer custom html (not recommended!)
167 self.emit_custom_html(self.cfg.page_footer1),
170 u'<div id="footer">',
174 self.showversion(d, **keywords),
177 # Post footer custom html
178 self.emit_custom_html(self.cfg.page_footer2),
180 return u'\n'.join(html)
182 def username(self, d):
183 """ Assemble the username / userprefs link
185 @param d: parameter dictionary
187 @return: username html
189 request = self.request
193 # Add username/homepage link for registered users. We don't care
194 # if it exists, the user can create it.
195 if request.user.valid and request.user.name:
196 interwiki = wikiutil.getInterwikiHomePage(request)
197 name = request.user.name
198 aliasname = request.user.aliasname
201 title = "%s @ %s" % (aliasname, interwiki[0])
202 # link to (interwiki) user homepage
203 homelink = (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki) +
204 request.formatter.text(name) +
205 request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
206 userlinks.append(homelink)
207 # link to userprefs action
208 if 'userprefs' not in self.request.cfg.actions_excluded:
209 userlinks.append(d['page'].link_to(request, text=_('Settings'),
210 querystr={'action': 'userprefs'}, id='userprefs', rel='nofollow'))
212 if request.user.valid:
213 if request.user.auth_method in request.cfg.auth_can_logout:
214 userlinks.append(d['page'].link_to(request, text=_('Logout'),
215 querystr={'action': 'logout', 'logout': 'logout'}, id='logout', rel='nofollow'))
217 query = {'action': 'login'}
218 # special direct-login link if the auth methods want no input
219 if request.cfg.auth_login_inputs == ['special_no_input']:
221 if request.cfg.auth_have_login:
222 userlinks.append(d['page'].link_to(request, text=_("Login"),
223 querystr=query, id='login', rel='nofollow'))
225 userlinks_html = u'<span class="sep"> | </span>'.join(userlinks)
226 html = u'<div id="username">%s</div>' % userlinks_html
230 """ Assemble page trail
232 @param d: parameter dictionary
236 request = self.request
239 if not user.valid or user.show_page_trail:
240 trail = user.getTrail()
243 for pagename in trail:
245 interwiki, page = wikiutil.split_interwiki(pagename)
246 if interwiki != request.cfg.interwikiname and interwiki != 'Self':
247 link = (self.request.formatter.interwikilink(True, interwiki, page) +
248 self.shortenPagename(page) +
249 self.request.formatter.interwikilink(False, interwiki, page))
257 page = Page(request, pagename)
258 title = page.split_title()
259 title = self.shortenPagename(title)
260 link = page.link_to(request, title)
262 html = u'<div id="pagetrail">%s</div>'% u'<span class="sep">/</span>'.join(items)
265 def interwiki(self, d):
266 """ Assemble the interwiki name display, linking to page_front_page
268 @param d: parameter dictionary
270 @return: interwiki html
272 if self.request.cfg.show_interwiki:
273 page = wikiutil.getFrontPage(self.request)
274 text = self.request.cfg.interwikiname or 'Self'
275 link = page.link_to(self.request, text=text, rel='nofollow')
276 html = u'<span id="interwiki">%s<span class="sep">: </span></span>' % link
281 def execute(request):
283 Generate and return a theme object
285 @param request: the request object
287 @return: Theme object
289 return Theme(request)