1 # -*- coding: iso-8859-1 -*- 2 3 """ 4 MoinMoin - MinimalMoin theme 5 @copyright: 2009, 2010 Paul Boddie <paul@boddie.org.uk> 6 @copyright: (portions) 2003-2008 MoinMoin:ThomasWaldmann, 2003-2005 Nir Soffer 7 @license: GNU GPL (v2 or later), see COPYING.txt for details. 8 """ 9 10 from MoinMoin.theme import ThemeBase 11 from MoinMoin import i18n 12 from MoinMoin import wikiutil 13 from MoinMoin import version 14 from MoinMoin.Page import Page 15 import re 16 17 class Theme(ThemeBase): 18 19 name = "minimalmoin" 20 21 # Icon definitions from the modernized theme... 22 23 _ = lambda x: x # We don't have gettext at this moment, so we fake it 24 icons = { 25 # key alt icon filename w h 26 # FileAttach 27 'attach': ("%(attach_count)s", "moin-attach.png", 16, 16), 28 'info': ("[INFO]", "moin-info.png", 16, 16), 29 'attachimg': (_("[ATTACH]"), "attach.png", 32, 32), 30 # RecentChanges 31 'rss': (_("[RSS]"), "moin-rss.png", 16, 16), 32 'deleted': (_("[DELETED]"), "moin-deleted.png", 16, 16), 33 'updated': (_("[UPDATED]"), "moin-updated.png", 16, 16), 34 'renamed': (_("[RENAMED]"), "moin-renamed.png", 16, 16), 35 'conflict': (_("[CONFLICT]"), "moin-conflict.png", 16, 16), 36 'new': (_("[NEW]"), "moin-new.png", 16, 16), 37 'diffrc': (_("[DIFF]"), "moin-diff.png", 16, 16), 38 # General 39 'bottom': (_("[BOTTOM]"), "moin-bottom.png", 16, 16), 40 'top': (_("[TOP]"), "moin-top.png", 16, 16), 41 'www': ("[WWW]", "moin-www.png", 16, 16), 42 'mailto': ("[MAILTO]", "moin-email.png", 16, 16), 43 'news': ("[NEWS]", "moin-news.png", 16, 16), 44 'telnet': ("[TELNET]", "moin-telnet.png", 16, 16), 45 'ftp': ("[FTP]", "moin-ftp.png", 16, 16), 46 'file': ("[FILE]", "moin-ftp.png", 16, 16), 47 # search forms 48 'searchbutton': ("[?]", "moin-search.png", 16, 16), 49 'interwiki': ("[%(wikitag)s]", "moin-inter.png", 16, 16), 50 51 # smileys (this is CONTENT, but good looking smileys depend on looking 52 # adapted to the theme background color and theme style in general) 53 #vvv == vvv this must be the same for GUI editor converter 54 'X-(': ("X-(", 'angry.png', 16, 16), 55 ':D': (":D", 'biggrin.png', 16, 16), 56 '<:(': ("<:(", 'frown.png', 16, 16), 57 ':o': (":o", 'redface.png', 16, 16), 58 ':(': (":(", 'sad.png', 16, 16), 59 ':)': (":)", 'smile.png', 16, 16), 60 'B)': ("B)", 'smile2.png', 16, 16), 61 ':))': (":))", 'smile3.png', 16, 16), 62 ';)': (";)", 'smile4.png', 16, 16), 63 '/!\\': ("/!\\", 'alert.png', 16, 16), 64 '<!>': ("<!>", 'attention.png', 16, 16), 65 '(!)': ("(!)", 'idea.png', 16, 16), 66 ':-?': (":-?", 'tongue.png', 16, 16), 67 ':\\': (":\\", 'ohwell.png', 16, 16), 68 '>:>': (">:>", 'devil.png', 16, 16), 69 '|)': ("|)", 'tired.png', 16, 16), 70 ':-(': (":-(", 'sad.png', 16, 16), 71 ':-)': (":-)", 'smile.png', 16, 16), 72 'B-)': ("B-)", 'smile2.png', 16, 16), 73 ':-))': (":-))", 'smile3.png', 16, 16), 74 ';-)': (";-)", 'smile4.png', 16, 16), 75 '|-)': ("|-)", 'tired.png', 16, 16), 76 '(./)': ("(./)", 'checkmark.png', 16, 16), 77 '{OK}': ("{OK}", 'thumbs-up.png', 16, 16), 78 '{X}': ("{X}", 'icon-error.png', 16, 16), 79 '{i}': ("{i}", 'icon-info.png', 16, 16), 80 '{1}': ("{1}", 'prio1.png', 15, 13), 81 '{2}': ("{2}", 'prio2.png', 15, 13), 82 '{3}': ("{3}", 'prio3.png', 15, 13), 83 '{*}': ("{*}", 'star_on.png', 16, 16), 84 '{o}': ("{o}", 'star_off.png', 16, 16), 85 } 86 del _ 87 88 stylesheets = ( 89 # media basename 90 ('all', 'combined'), 91 ) 92 93 def header(self, d, **kw): 94 """ Assemble page header 95 96 @param d: parameter dictionary 97 @rtype: unicode 98 @return: page header html 99 """ 100 101 request = self.request 102 fmt = request.formatter 103 html = [] 104 105 # NOTE: Some pages cause section numbers to be enabled, affecting the 106 # NOTE: theme. 107 108 show_section_numbers = fmt._show_section_numbers 109 fmt._show_section_numbers = 0 110 111 # The header section. 112 113 html.append(fmt.div(on=1, attr={"id" : "header"})) 114 115 html.append(self.title(d)) 116 html.append(self.about(d)) 117 html.append(self.mainpages(d)) 118 119 html.append(fmt.div(on=0)) 120 121 # Show any pertinent message. 122 123 html.append(self.msg(d)) 124 125 # Complete the header. 126 127 html.append(self.startPage()) 128 129 # NOTE: Some pages cause section numbers to be enabled, affecting the 130 # NOTE: theme. 131 132 fmt._show_section_numbers = show_section_numbers 133 134 return u''.join(html) 135 136 editorheader = header 137 138 def footer(self, d, **kw): 139 """ Assemble page footer 140 141 @param d: parameter dictionary 142 @rtype: unicode 143 @return: page footer html 144 """ 145 146 request = self.request 147 fmt = request.formatter 148 _ = request.getText 149 page = d["page"] 150 html = [] 151 152 # NOTE: Some pages cause section numbers to be enabled, affecting the 153 # NOTE: theme. 154 155 show_section_numbers = fmt._show_section_numbers 156 fmt._show_section_numbers = 0 157 158 # End the page. 159 160 html.append(self.endPage()) 161 162 # The footer section. 163 164 html.append(fmt.div(on=1, attr={"id" : "footer"})) 165 166 if self.shouldShowEditbar(page): 167 html.append(self.menuholder(d, {"class" : "editing"}, _("Editing options"), self.editbar)) 168 html.append(self.menuholder(d, {"id" : "navigation"}, _("Useful pages"), self.navibar)) 169 html.append(self.menuholder(d, {"id" : "identity"}, _("User information"), self.username)) 170 171 #html.append(self.trail(d)) 172 173 html.append(fmt.div(on=0)) 174 175 # NOTE: Some pages cause section numbers to be enabled, affecting the 176 # NOTE: theme. 177 178 fmt._show_section_numbers = show_section_numbers 179 180 return u''.join(html) 181 182 def mainpages(self, d, **kw): 183 """ Link to the front page and potentially other pages. 184 185 @param d: parameter dictionary 186 @rtype: unicode 187 @return: front page link html 188 """ 189 190 request = self.request 191 fmt = request.formatter 192 _ = request.getText 193 html = [] 194 195 page = wikiutil.getFrontPage(self.request) 196 197 html.append(fmt.bullet_list(on=1, attr={"id" : "mainpages"})) 198 html.append(fmt.listitem(on=1)) 199 html.append(page.link_to(request, text=_("Front page"), rel='nofollow')) 200 html.append(fmt.listitem(on=0)) 201 html.append(fmt.bullet_list(on=0)) 202 203 return u''.join(html) 204 205 def about(self, d, **kw): 206 """ Link to the controls in the footer. 207 208 @param d: parameter dictionary 209 @rtype: unicode 210 @return: about link html 211 """ 212 213 request = self.request 214 fmt = request.formatter 215 _ = request.getText 216 html = [] 217 218 html.append(fmt.bullet_list(on=1, attr={"id" : "pageabout"})) 219 html.append(fmt.listitem(on=1)) 220 221 html.append(fmt.anchorlink(on=1, name="footer")) 222 html.append(fmt.text(_("About this page"))) 223 html.append(fmt.anchorlink(on=0)) 224 225 html.append(fmt.listitem(on=0)) 226 html.append(fmt.bullet_list(on=0)) 227 228 return u''.join(html) 229 230 def menuholder(self, d, menu_attr, menu_title, menu_fn): 231 """ Wrap controls in a menu container. 232 233 @param d: parameter dictionary 234 @param menu_attr: menu container element attributes 235 @param menu_title: the menu label text 236 @param menu_fn: the function or method producing the controls 237 @rtype: unicode 238 @return: menu container html 239 """ 240 241 request = self.request 242 fmt = request.formatter 243 html = [] 244 245 html.append(fmt.div(on=1, attr=menu_attr)) 246 html.append(fmt.span(on=1, attr={"class" : "menutitleholder"})) 247 html.append(fmt.span(on=1, attr={"class" : "menutitle"})) 248 html.append(fmt.text(menu_title)) 249 html.append(fmt.span(on=0)) 250 html.append(menu_fn(d)) 251 html.append(fmt.span(on=0)) 252 html.append(fmt.div(on=0)) 253 254 return u''.join(html) 255 256 # Theme instantiation. 257 258 def execute(request): 259 """ 260 Generate and return a theme object 261 262 @param request: the request object 263 @rtype: MoinTheme 264 @return: Theme object 265 """ 266 return Theme(request) 267 268 # vim: tabstop=4 expandtab shiftwidth=4