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 def header(self, d, **kw): 89 """ Assemble page header 90 91 @param d: parameter dictionary 92 @rtype: unicode 93 @return: page header html 94 """ 95 96 request = self.request 97 fmt = request.formatter 98 html = [] 99 100 # NOTE: Some pages cause section numbers to be enabled, affecting the 101 # NOTE: theme. 102 103 show_section_numbers = fmt._show_section_numbers 104 fmt._show_section_numbers = 0 105 106 # The header section. 107 108 html.append(fmt.div(on=1, attr={"id" : "header"})) 109 110 html.append(self.title(d)) 111 html.append(self.about(d)) 112 113 html.append(fmt.div(on=0)) 114 115 # Show any pertinent message. 116 117 html.append(self.msg(d)) 118 119 # Complete the header. 120 121 html.append(self.startPage()) 122 123 # NOTE: Some pages cause section numbers to be enabled, affecting the 124 # NOTE: theme. 125 126 fmt._show_section_numbers = show_section_numbers 127 128 return u''.join(html) 129 130 editorheader = header 131 132 def footer(self, d, **kw): 133 """ Assemble page footer 134 135 @param d: parameter dictionary 136 @rtype: unicode 137 @return: page footer html 138 """ 139 140 request = self.request 141 fmt = request.formatter 142 _ = request.getText 143 html = [] 144 145 # NOTE: Some pages cause section numbers to be enabled, affecting the 146 # NOTE: theme. 147 148 show_section_numbers = fmt._show_section_numbers 149 fmt._show_section_numbers = 0 150 151 # End the page. 152 153 html.append(self.endPage()) 154 155 # The footer section. 156 157 html.append(fmt.div(on=1, attr={"id" : "footer"})) 158 159 html.append(fmt.div(on=1, attr={"class" : "editing"})) 160 html.append(fmt.span(on=1, attr={"class" : "menutitleholder"})) 161 html.append(fmt.span(on=1, attr={"class" : "menutitle"})) 162 html.append(fmt.text(_("Editing options"))) 163 html.append(fmt.span(on=0)) 164 html.append(self.editbar(d)) 165 html.append(fmt.span(on=0)) 166 html.append(fmt.div(on=0)) 167 168 html.append(fmt.div(on=1, attr={"id" : "navigation"})) 169 html.append(fmt.span(on=1, attr={"class" : "menutitleholder"})) 170 html.append(fmt.span(on=1, attr={"class" : "menutitle"})) 171 html.append(fmt.text(_("Useful pages"))) 172 html.append(fmt.span(on=0)) 173 html.append(self.navibar(d)) 174 html.append(fmt.span(on=0)) 175 html.append(fmt.div(on=0)) 176 177 html.append(fmt.div(on=1, attr={"id" : "identity"})) 178 html.append(fmt.span(on=1, attr={"class" : "menutitleholder"})) 179 html.append(fmt.span(on=1, attr={"class" : "menutitle"})) 180 html.append(fmt.text(_("User information"))) 181 html.append(fmt.span(on=0)) 182 html.append(self.username(d)) 183 html.append(fmt.span(on=0)) 184 html.append(fmt.div(on=0)) 185 186 #html.append(self.trail(d)) 187 188 html.append(fmt.div(on=0)) 189 190 # NOTE: Some pages cause section numbers to be enabled, affecting the 191 # NOTE: theme. 192 193 fmt._show_section_numbers = show_section_numbers 194 195 return u''.join(html) 196 197 def about(self, d, **kw): 198 """ Link to the controls in the footer. 199 200 @param d: parameter dictionary 201 @rtype: unicode 202 @return: about link html 203 """ 204 205 request = self.request 206 fmt = request.formatter 207 _ = request.getText 208 html = [] 209 210 html.append(fmt.bullet_list(on=1, attr={"id" : "pageabout"})) 211 html.append(fmt.listitem(on=1)) 212 213 html.append(fmt.anchorlink(on=1, name="footer")) 214 html.append(fmt.text(_("About this page"))) 215 html.append(fmt.anchorlink(on=0)) 216 217 html.append(fmt.listitem(on=0)) 218 html.append(fmt.bullet_list(on=0)) 219 220 return u''.join(html) 221 222 # Theme instantiation. 223 224 def execute(request): 225 """ 226 Generate and return a theme object 227 228 @param request: the request object 229 @rtype: MoinTheme 230 @return: Theme object 231 """ 232 return Theme(request) 233 234 # vim: tabstop=4 expandtab shiftwidth=4