[wiki/theme] thèmes crans et crans-www dans /usr/scripts
Ignore-this: 62481bd1e942fdf5cd197fb81e335062 darcs-hash:20100326165539-bd074-38b222f3cae3cf896123b99e1bbf633e4a1281d3.gz
This commit is contained in:
parent
bca01e74ec
commit
ad66550320
2 changed files with 247 additions and 0 deletions
124
wiki/theme/crans-www.py
Executable file
124
wiki/theme/crans-www.py
Executable file
|
@ -0,0 +1,124 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
MoinMoin monobook theme.
|
||||
|
||||
Author: Antoine Durand-Gasselin <adg@crans.org>
|
||||
"""
|
||||
|
||||
from MoinMoin.theme import ThemeBase
|
||||
|
||||
class Theme(ThemeBase):
|
||||
|
||||
name = "crans-www"
|
||||
|
||||
# liste des liens du menu
|
||||
menu_links = [
|
||||
# tire #lien
|
||||
|
||||
(u"Accueil", u"http://www.crans.org/"),
|
||||
(u"Webmail", u"https://webmail.crans.org/"),
|
||||
(u"Accès SSH", u"http://www.crans.org/VieCrans/OpenSsh"),
|
||||
(u"Accès Intranet",u"https://intranet.crans.org/"),
|
||||
(u"Pages persos", u"http://www.crans.org/PagesPerso"),
|
||||
]
|
||||
|
||||
# Chemin des badges
|
||||
badgesPath = u'/wiki/additional/badges/'
|
||||
|
||||
|
||||
# liste des badges
|
||||
support_badges = [
|
||||
# page, # image # alt text
|
||||
(u'http://www.mozilla-europe.org/fr/firefox/',
|
||||
u'badges_80x15_firefox.gif', u'Get firefox'),
|
||||
(u'http://www.debian.org/', u'badges_80x15_debian.png', u'Debian powered'),
|
||||
(u'http://www.apache.org/', u'badges_80x15_apache.gif', u'Apache powered'),
|
||||
(u'http://www.python.org/', u'badges_80x15_python.png', u'Python powered'),
|
||||
(u'http://www.federez.org/', u'badges_80x15_federez.png', u'Membre du réseau federez'),
|
||||
(u'http://moinmo.in/', u'badges_80x15_moinmoin.png', u'Moinmoin powered'),
|
||||
(u'http://jigsaw.w3.org/css-validator/check?uri=referer&profile=css3&warning=no',
|
||||
u'valid_css_80x15.png', u'Valid css3'),
|
||||
(u'http://validator.w3.org/check?uri=referer',
|
||||
u'valid_html401_80x15.gif', u'Valid HTML 4.01'),
|
||||
]
|
||||
|
||||
def img_url(self, img):
|
||||
return "%s/crans/img/%s" % (self.cfg.url_prefix_static, img)
|
||||
|
||||
def header(self, d):
|
||||
"""
|
||||
Assemble page header
|
||||
|
||||
@param d: parameter dictionary
|
||||
@rtype: string
|
||||
@return: page header html
|
||||
"""
|
||||
html = [ self.emit_custom_html(self.cfg.page_header1),
|
||||
u'<div id="mainContent">', self.logo(), ]
|
||||
if d['page'].page_name != 'VieCrans':
|
||||
html += [u'<h1 id="title">', self.title(d), u'</h1>']
|
||||
html += [ self.msg(d), self.startPage() ]
|
||||
|
||||
return u'\n'.join(html)
|
||||
|
||||
editorheader = header
|
||||
|
||||
def footer(self, d, **keywords):
|
||||
""" Assemble wiki footer
|
||||
|
||||
@param d: parameter dictionary
|
||||
@keyword ...:...
|
||||
@rtype: unicode
|
||||
@return: page footer html
|
||||
"""
|
||||
|
||||
page = d['page']
|
||||
|
||||
html = [
|
||||
#self.pageinfo(page),
|
||||
self.endPage(),
|
||||
self.menu(d),
|
||||
u'</div>',
|
||||
self.username(d),
|
||||
self.badges(d)
|
||||
]
|
||||
return u'\n'.join(html)
|
||||
|
||||
def menu(self, d):
|
||||
""" assemble all the navigation aids for the page
|
||||
"""
|
||||
liens = []
|
||||
for titre, lien in self.menu_links:
|
||||
liens.append(u'<li><a href="%s">%s</a></li>' % (lien, titre))
|
||||
html = [
|
||||
u'<div id="menuNavigation">',
|
||||
u'<ul>',
|
||||
u'\n'.join(liens),
|
||||
u'<li>%s</li>' % self.searchform(d),
|
||||
u'</ul>',
|
||||
u'</div>',
|
||||
]
|
||||
return u''.join(html)
|
||||
|
||||
def badges(self,d ):
|
||||
badges_html = []
|
||||
for page, image, alt_text in self.support_badges:
|
||||
badges_html.append(u'<li><a href="%(href)s" title="%(alt)s"><img src="%(path)s%(image)s" alt="%(alt)s"></a></li>' % {'href':page, 'path':self.badgesPath, 'image':image, 'alt':alt_text})
|
||||
html = [
|
||||
u'<div id="supportBadges">\n '
|
||||
u'<ul>\n ',
|
||||
u'\n '.join(badges_html),
|
||||
u'\n </ul>\n</div>\n\n',
|
||||
]
|
||||
return ''.join(html)
|
||||
|
||||
|
||||
def execute(request):
|
||||
""" Generate and return a theme object
|
||||
|
||||
@param request: the request object
|
||||
@rtype: MoinTheme
|
||||
@return: Theme object
|
||||
"""
|
||||
return Theme(request)
|
123
wiki/theme/crans.py
Executable file
123
wiki/theme/crans.py
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
MoinMoin monobook theme.
|
||||
|
||||
Author: Antoine Durand-Gasselin <adg@crans.org>
|
||||
"""
|
||||
|
||||
import datetime
|
||||
from MoinMoin.theme import ThemeBase
|
||||
|
||||
class Theme(ThemeBase):
|
||||
|
||||
name = "crans"
|
||||
today = datetime.date.today()
|
||||
def wikipanel(self, d):
|
||||
""" Create wiki panel """
|
||||
_ = self.request.getText
|
||||
html = [
|
||||
u'<div class="sidepanel">',
|
||||
u'<h1>%s</h1>' % _("Wiki"),
|
||||
self.navibar(d),
|
||||
u'</div>',
|
||||
]
|
||||
return u'\n'.join(html)
|
||||
|
||||
def pagepanel(self, d):
|
||||
""" Create page panel """
|
||||
_ = self.request.getText
|
||||
if self.shouldShowEditbar(d['page']):
|
||||
html = [
|
||||
u'<div class="sidepanel">',
|
||||
u'<h1>%s</h1>' % _("Page"),
|
||||
self.editbar(d),
|
||||
u'</div>',
|
||||
]
|
||||
return u'\n'.join(html)
|
||||
return ''
|
||||
|
||||
def userpanel(self, d):
|
||||
""" Create user panel """
|
||||
_ = self.request.getText
|
||||
|
||||
html = [
|
||||
u'<div class="sidepanel">',
|
||||
u'<h1>%s</h1>' % _("User"),
|
||||
self.username(d),
|
||||
u'</div>'
|
||||
]
|
||||
return u'\n'.join(html)
|
||||
|
||||
def header(self, d):
|
||||
"""
|
||||
Assemble page header
|
||||
|
||||
@param d: parameter dictionary
|
||||
@rtype: string
|
||||
@return: page header html
|
||||
"""
|
||||
_ = self.request.getText
|
||||
|
||||
if self.today.month == 10 and self.today.day == 31:
|
||||
extra_style = 'class="halloween"'
|
||||
elif self.today.month == 12 and self.today.day == 24:
|
||||
extra_style = 'class="noel"'
|
||||
else: extra_style = ''
|
||||
|
||||
html = [
|
||||
# Custom html above header
|
||||
self.emit_custom_html(self.cfg.page_header1),
|
||||
|
||||
u'<div id="titleBar" %s>' % extra_style,
|
||||
u'<h1 id="title">', self.title(d), u'</h1>',
|
||||
u'</div>',
|
||||
self.msg(d),
|
||||
self.startPage()
|
||||
]
|
||||
|
||||
return u'\n'.join(html)
|
||||
|
||||
editorheader = header
|
||||
|
||||
def footer(self, d, **keywords):
|
||||
""" Assemble wiki footer
|
||||
|
||||
@param d: parameter dictionary
|
||||
@keyword ...:...
|
||||
@rtype: unicode
|
||||
@return: page footer html
|
||||
"""
|
||||
|
||||
page = d['page']
|
||||
|
||||
html = [
|
||||
self.pageinfo(page),
|
||||
self.endPage(),
|
||||
|
||||
# Sidebar
|
||||
u'<div id="rightSidebar">',
|
||||
self.userpanel(d), self.wikipanel(d), self.pagepanel(d),
|
||||
self.searchform(d), self.credits(d), self.showversion(d, **keywords),
|
||||
u'</div>',
|
||||
|
||||
# # Pre footer custom html (not recommended!)
|
||||
# self.emit_custom_html(self.cfg.page_footer1),
|
||||
#
|
||||
# # Footer
|
||||
# u'<div id="footer">',
|
||||
# u'</div>',
|
||||
#
|
||||
# # Post footer custom html
|
||||
# self.emit_custom_html(self.cfg.page_footer2),
|
||||
]
|
||||
return u'\n'.join(html)
|
||||
|
||||
def execute(request):
|
||||
""" Generate and return a theme object
|
||||
|
||||
@param request: the request object
|
||||
@rtype: MoinTheme
|
||||
@return: Theme object
|
||||
"""
|
||||
return Theme(request)
|
Loading…
Add table
Add a link
Reference in a new issue