scripts/wiki/theme/crans.py
Grgoire Dtrez b6a8b6baf1 Save a developper...
darcs-hash:20080403153435-69ccb-43686e86a0a1d3fe4ce68910413ef9728e425a72.gz
2008-04-03 17:34:35 +02:00

158 lines
4.9 KiB
Python

# -*- coding: iso-8859-1 -*-
"""
MoinMoin monobook theme. Uses the css sheet from
http://wikipedia.org, adapting the moin output to fit it.
Adapted by Jim Clark <jim AT clarkster DOT co DOT uk>
Adapted for CR@NS by Nicolas Salles <salles AT crans DOT org>
@license: GNU GPL, see COPYING for details.
"""
import datetime
from MoinMoin.theme import ThemeBase
from MoinMoin import wikiutil, i18n
from MoinMoin.Page import Page
class ThemeCrans(ThemeBase):
name = "crans"
# Standard set of style sheets
stylesheets = (
# media basename
('all', 'common'),
('screen', 'crans'),
('print', 'print'),
('projection', 'projection'),
)
# Standard set of scripts
scripts = (
'crans',
)
# Public functions #####################################################
def header(self, d, **kw):
""" Assemble wiki header
Here we don't add any menu bars, search bars, etc - instead wait
until the footer. This keeps the HTML cleaner and more accessible,
making sure the main content arrives first.
"""
if datetime.date.today().month == 10:
extra_style = " class=\"halloween\""
elif (datetime.date.today().month == 12) and (datetime.date.today().day <= 24):
extra_style = " class=\"noel\""
else:
extra_style = ""
parent = d['page'].getParentPage()
html = [
u'<div id="globalWrapper"%s>' % extra_style,
u'<div id="main-content">',
u'<div id="titleBarre">',
'<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
"""
html = [
# End of page
self.pageinfo(d['page']),
self.endPage(),
u'</div>', # fin du div main-content
self.rightcolumn(d),
u'</div>', # fin du div globalWrapper
u'<script src="http://www.savethedevelopers.org/say.no.to.ie.6.js"></script>', # Campagne "Save A Developer. Upgrade Your Browser."
]
return u'\n'.join(html)
def rightcolumn(self, d):
""" assemble all the navigation aids for the page
"""
_ = self.request.getText
page = d['page']
html = [
u'<div id="column-one">',
u"<h5>Personnel</h5>",
self.username(d),
u"<h5>Navigation</h5>",
self.navibar(d),
# hack : c1 and V1 or v2 c'est comme le code C : c1? v1 : V2
# (si c1 est vrai alors prends la valeur V1 sinon prend la valeur c2
self.shouldShowEditbar(d['page']) and u"<h5>%s</h5>" % _("Page") or u" ",
self.editbar(d),
u"<h5>%s</h5>" % _('Search'),
self.searchform(d),
#self.actionmenu(d),
#self.pageinfo(page),
self.credits(d),
]
return u'\n'.join(html)
def html_head(self, d):
""" add opensearch description to html head
"""
# common prefix for static content
prefix = self.cfg.url_prefix
open_search_desc = '<link rel="search" type="application/opensearchdescription+xml" href="%(page)s?action=opensearch&amp;searchtype=Titres" title="%(sitename)s, Rechercher dans les titres" />\n<link rel="search" type="application/opensearchdescription+xml" href="%(page)s?action=opensearch&amp;searchtype=Texte" title="%(sitename)s, Rechercher dans le texte" />' % {'page':d['page'].request.script_name, 'sitename':d['sitename']}
classic_head = ThemeBase.html_head(self, d)
return classic_head + open_search_desc
def headscript(self, d):
# Check mode
if d.get('print_mode'):
link = ""
else:
# Create stylesheets links
link = '<script type="text/javascript" src="%s"></script>'
prefix = self.cfg.url_prefix
csshref = '%s/%s/js' % (prefix, self.name)
html = []
for basename in self.scripts:
href = '%s/%s.js' % (csshref, basename)
html.append(link % href )
return ThemeBase.headscript(self, d) + u"\n".join(html)
class Theme(ThemeCrans):
name = "crans"
# Standard set of style sheets
stylesheets = (
# media basename
('all', 'common'),
('screen', 'layout'),
('screen', 'crans'),
('print', 'print'),
('projection', 'projection'),
)
def execute(request):
"""
Generate and return a theme object
@param request: the request object
@rtype: MoinTheme
@return: Theme object
"""
return Theme(request)