Attachment 'woodpecker.py'
Download 1 # coding:utf-8
2 """
3 MoinMoin ubuntu theme
4
5 @copyright: (c) 2003-2004 by Nir Soffer, Thomas Waldmann
6 @license: GNU GPL, see COPYING for details.
7
8 Borrows heavily from modern, a bit from Classic, and has a few
9 things of its own.
10 Zoomq::060426 fixed from balanced2
11 """
12
13 from MoinMoin.theme import ThemeBase
14 from MoinMoin import wikiutil
15 from MoinMoin.Page import Page
16 import re
17
18 class Theme(ThemeBase):
19 name = 'woodpecker'
20
21 # Overriding theme/__init__.py #########################################
22
23 # fake _ function to get gettext recognize those texts:
24 _ = lambda x: x
25
26 # TODO: remove icons that are not used any more.
27 icons = {
28 # key alt icon filename w h
29 # ------------------------------------------------------------------
30 # navibar
31 'help': ("%(page_help_contents)s", "s-help.png", 20, 20),
32 'find': ("%(page_find_page)s", "s-search.png", 20, 20),
33 'diff': (_("Diffs"), "diff.png", 22, 22),
34 'info': (_("Info"), "info.png", 22, 22),
35 'edit': (_("Edit"), "edit.png", 20, 20),
36 'unsubscribe':(_("Unsubscribe"), "unsubscribe.png", 23, 21),
37 'subscribe': (_("Subscribe"), "subscribe_dk.png", 23, 21),
38 'raw': (_("Raw"), "raw.png", 21, 23),
39 'xml': (_("XML"), "moin-xml2.png", 36, 14),
40 'print': (_("Print"), "print.png", 20, 20),
41 'view': (_("View"), "show.png", 20, 20),
42 'home': (_("Home"), "home.png", 20, 20),
43 'up': (_("Up"), "parent.png", 20, 20),
44 # FileAttach
45 'attach': ("%(attach_count)s", "moin-attach.png", 7, 15),
46 # RecentChanges
47 'rss': (_("[RSS]"), "moin-rss.png", 36, 14),
48 'deleted': (_("[DELETED]"), "deleted.png", 22, 22),
49 'updated': (_("[UPDATED]"), "updated.png", 22, 22),
50 'new': (_("[NEW]"), "new.png", 22, 22),
51 'diffrc': (_("[DIFF]"), "diff.png", 22, 22),
52 # General
53 'bottom': (_("[BOTTOM]"), "u-bottom.png", 14, 10),
54 'top': (_("[TOP]"), "u-top.png", 14, 10),
55 'www': ("[WWW]", "www.png", 16, 16),
56 'mailto': ("[MAILTO]", "email.png", 23, 13),
57 'news': ("[NEWS]", "news.png", 16, 16),
58 'telnet': ("[TELNET]", "telnet.png", 16, 16),
59 'ftp': ("[FTP]", "ftp.png", 16, 16),
60 'file': ("[FILE]", "ftp.png", 16, 16),
61 # search forms
62 'searchbutton': ("[?]", "s-search.png", 20, 20),
63 'interwiki': ("[%(wikitag)s]", "inter.png", 16, 16),
64 }
65 del _
66
67 # Public functions #####################################################
68
69 def header(self, d, **kw):
70 """ Assemble wiki header
71
72 @param d: parameter dictionary
73 @rtype: unicode
74 @return: page header html
75 """
76 html = [
77 # Header
78 u'<div id="mastwrap">',
79 u'<div id="masthead">',
80 self.logo(),
81 self.searchform(d),
82 u'<div id="locationline">',
83 self.interwiki(d),
84 self.title(d),
85 u'</div> <!-- 4 locationline -->',
86
87 u'<div id="pagetrail">',
88 self.trail(d),
89 u'</div> <!-- 4 pagetrail -->',
90
91 ##Zoomq::060418 usage
92 #self.sisternav(),
93 self.navibar(d),
94 # Zoomq::060418 fixed for woodpecker
95
96 u'</div> <!-- of masthead -->',
97 u'</div> <!-- of mastwrap -->',
98 ## Zoomq::060418 not Columns
99 u'<div id="editbar">',
100 self.username(d),
101 self.msg(d),
102 self.editbar(d),
103 u'</div>',
104
105 u'<div id="outerColumnContainer"><div id="innerColumnContainer">',
106
107 #u'<div id="leftColumn"><div class="inside">Left',
108 #self.leftsidemenu(d),
109 #u'</div></div> <!-- of leftColumn & inside -->',
110
111 #u'<div id="rightColumn"><div class="inside">Right',
112 #self.rightsidemenu(d),
113 #u'</div></div> <!-- of rightColumn & inside -->',
114
115 u'<div id="contentColumn"><div class="inside">',
116 #u'<div id="pageline"><hr style="display:none;"></div>',
117 ]
118 return u'\n'.join(html)
119
120
121 def footer(self, d, **keywords):
122 """ Assemble wiki footer
123
124 @param d: parameter dictionary
125 @keyword ...:...
126 @rtype: unicode
127 @return: page footer html
128 """
129 page = d['page']
130 ## zoomq::060812 for Yahoo! search support
131 ysearcode = """
132 <!-- START CODE
133 background:#FFFFFF;
134 -->
135
136 <div id="ysrchForm" style="
137 border:1px solid #7E9DB9;
138
139 width:350px;
140 margin:0 auto;
141 padding:0px; position:relative;">
142
143 <form id="searchBoxForm_U0RNxnDNGDJdIAAEc2eOU" action="http://builder.search.yahoo.com/a/bouncer" style="padding:0;">
144 <input name="mobid" value="U0RNxnDNGDJdIAAEc2eOU" type="hidden">
145 <input name="ei" value="UTF-8" type="hidden">
146 <input name="fr" value="ystg-c" type="hidden"><div style="padding:0 30px 0 0;zoom:1;">
147 Searching all CPUG sites and mailist::<br/>
148 <input type="text" id="searchTerm"
149 onFocus="this.style.background='#fff';"
150 onBlur="if(this.value=='')this.style.background='#fff url(http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/horiz_pwrlogo_red2.gif) 3px center no-repeat'"
151 name="p" style=" margin:1px 0; width:100%; border:1px solid #7E9DB9; color:#666666; height:18px; padding:1px 3px; background:#fff url(http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/horiz_pwrlogo_red2.gif) 3px center no-repeat; position:relative;">
152 <input type="submit" id="btn_U0RNxnDNGDJdIAAEc2eOU" value="Search"
153 style=" padding-bottom:2px; position:absolute; right:10px; top:20px; margin:0px; height:22px; width:65px; ">
154 </div>
155
156 <ul style="color:#666666;
157 font:11px/11px normal Arial, Helvetica, sans-serif;
158 margin:0;
159 padding:0;
160 text-align:left;
161 list-style-type:none;radios">
162 <li style="display:inline;padding-right:10px;">
163 <input name="mobvs" id="web_U0RNxnDNGDJdIAAEc2eOU" value="0" onclick='displayPopSearch("web","U0RNxnDNGDJdIAAEc2eOU");' type="hidden">
164 <label for="web_U0RNxnDNGDJdIAAEc2eOU" style="vertical-align:middle;display:none;">Web</label>
165
166 </li></ul></form></div>
167 <!-- END CODE -->
168 """
169
170 html = [
171 u'</div></div> <!-- of contentColumn & inside -->',
172 u'<div class="clear mozclear"></div>',
173
174 u'</div></div> <!-- of outerColumnContainer & innerColumnContainer -->',
175 # Footer
176 u'<div id="footer" class="inside">',
177 #self.editbar(d),
178 self.credits(d),
179 # zoomq::060811 support yahoo! searching
180 ysearcode,
181 self.showversion(d, **keywords),
182 #self.footerlinks(),
183 ### Zoomq::060626 add for try pipi
184 #u'<script language="javascript" src="http://hi.51pipi.com/container_1_2.js" ></script>',
185 u'</div>',
186 ]
187 return u'\n'.join(html)
188
189
190
191
192
193
194 def extranav(self, d):
195 """ Assemble the helpful extra navigation
196
197 Of course in a normal theme these come from wikiconfig.py
198
199 @param d: parameter dictionary
200 @rtype: unicode
201 @return: extranav html
202 """
203 request = self.request
204 _ = request.getText
205 changesPage = wikiutil.getSysPage(request, 'RecentChanges')
206 findPage = wikiutil.getSysPage(request, 'FindPage')
207
208 extralinks = []
209 # Set page to localized RC page
210 title = changesPage.split_title(request)
211 extralinks.append(changesPage.link_to(request, text=title))
212 # Set page to localized find page
213 title = findPage.split_title(request)
214 extralinks.append(findPage.link_to(request, text=title))
215
216 extralinks = [u'<li>%s</li>\n' % link for link in extralinks]
217 html = u'<ul class="extranav">\n%s</ul>' % ''.join(extralinks)
218
219 return html
220
221
222
223
224 def leftsidemenu(self, d):
225 """ Assemble the side menu """
226
227 html = 'error'
228 menuTag = "##MENU .*html"
229 menuPath = "C:\\APPS\\MMDE\\wiki\\data\\pages\\MenuPages\\attachments\\" # FIXME: abstract out the path
230 pageBody = self.request.page.get_raw_body()
231 menuLineObj = re.search(menuTag, pageBody)
232 # catch bad or missing tag
233 if menuLineObj:
234 menuLine = menuLineObj.group()
235 fileName = re.sub("##MENU ","",menuLine)
236 else:
237 fileName = 'sidemenu-default.html'
238
239 # catch non-existant files
240 try:
241 fullName = menuPath+fileName
242 fileHandle = open(fullName)
243 except IOError:
244 fileName = 'sidemenu-default.html'
245 fullName = menuPath+fileName
246 fileHandle = open(fullName)
247
248 html = fileHandle.read()
249 fileHandle.close()
250 return html
251
252
253 def rightsidemenu(self, d):
254 """ Assemble the side menu """
255
256 html = 'error'
257 menuTag = "##MENU .*html"
258 menuPath = "C:\\APPS\\MMDE\\wiki\\data\\pages\\MenuPages\\attachments\\" # FIXME: abstract out the path
259 pageBody = self.request.page.get_raw_body()
260 menuLineObj = re.search(menuTag, pageBody)
261 # catch bad or missing tag
262 if menuLineObj:
263 menuLine = menuLineObj.group()
264 fileName = re.sub("##MENU ","",menuLine)
265 else:
266 fileName = 'sidemenu-default.html'
267
268 # catch non-existant files
269 try:
270 fullName = menuPath+fileName
271 fileHandle = open(fullName)
272 except IOError:
273 fileName = 'sidemenu-default.html'
274 fullName = menuPath+fileName
275 fileHandle = open(fullName)
276
277 html = fileHandle.read()
278 fileHandle.close()
279 return html
280
281
282
283 def username(self, d):
284 """ Assemble the username / userprefs link
285
286 @param d: parameter dictionary
287 @rtype: unicode
288 @return: username html
289 @note: lost logout link usage normal username
290 """
291 request = self.request
292 _ = request.getText
293 preferencesPage = wikiutil.getSysPage(request, 'UserPreferences')
294 helpPage = wikiutil.getSysPage(request, 'HelpContents')
295
296 userlinks = []
297 # Add username/homepage link for registered users. We don't care
298 # if it exists, the user can create it.
299 if request.user.valid:
300 homepage = Page(request, request.user.name)
301 title = homepage.split_title(request)
302 homelink = homepage.link_to(request, text=title)
303 userlinks.append(homelink)
304 # Set pref page to localized Preferences page
305 title = preferencesPage.split_title(request)
306 userlinks.append(preferencesPage.link_to(request, text=title))
307 #userlinks.append(helpPage.link_to(request, text=_("Help")))
308 else:
309 # Add prefpage links with title: Login
310 userlinks.append(preferencesPage.link_to(request, text=_("Login")))
311
312 if request.cfg.show_login:
313 if request.user.valid:
314 userlinks.append(d['page'].link_to(request, text=_('Logout', formatted=False),
315 querystr={'action': 'logout', 'logout': 'logout'}, id="logout"))
316 else:
317 userlinks.append(d['page'].link_to(request, text=_("Login", formatted=False),
318 querystr={'action': 'login'}, id="login"))
319
320 userlinks = [u'<li>%s</li>\n' % link for link in userlinks]
321 html = u'<ul id="username">\n%s</ul>' % ''.join(userlinks)
322 return html
323
324
325 def sisternav(self):
326 """ Assemble fancy nav tabs to the sister sites
327 """
328
329 html = u'''<div id="sisternav">
330 <ul>
331 <li id="current"><a href="/moin/FrontPage" 首页</a></li>
332 <li id="plain"><a href="/moin/RecentChanges" >更新</a></li>
333 <li id="plain"><a href="/moin/FindPage" >搜索</a></li>
334 <li id="plain"><a href="/moin/HelpContents" >帮助</a></li>
335 </ul>
336 </div>'''
337 return html
338
339 def footerlinks(self):
340 """ Copyright notices and local links """
341 html = u'''
342 © Henrik Nilsen Omma
343 <a href="/UserPreferences">Admin</a>
344 '''
345 return html
346
347
348
349
350
351 def execute(request):
352 """
353 Generate and return a theme object
354
355 @param request: the request object
356 @rtype: MoinTheme
357 @return: Theme object
358 """
359
360 return Theme(request)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.