
(on rajoute des accents partout :) darcs-hash:20081004175702-bd074-cf32f0e641d84d78ea6a7a8d3a2ed5902ca514b4.gz
168 lines
5.3 KiB
Python
168 lines
5.3 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.crans.org/wiki/common/js/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 = '\n<link rel="search" type="application/opensearchdescription+xml" href="%(page)s?action=opensearch&searchtype=Titres" title="%(sitename)s, Rechercher dans les titres" />\n<link rel="search" type="application/opensearchdescription+xml" href="%(page)s?action=opensearch&searchtype=Texte" title="%(sitename)s, Rechercher dans le texte" />' % {'page':d['page'].request.script_name, 'sitename':d['sitename']}
|
|
if (d['page'].isWritable() and
|
|
self.request.user.may.write(d['page'].page_name)):
|
|
edit_link = "/" + wikiutil.quoteWikinameURL(d['page'].page_name) + '?action=edit&editor=text'
|
|
wiki_rel = '<link rel="alternate" \
|
|
type="application/x-wiki" title="Modifier" \
|
|
href="%s" />\n' % edit_link
|
|
else:
|
|
wiki_rel = ""
|
|
|
|
|
|
classic_head = ThemeBase.html_head(self, d)
|
|
|
|
return classic_head + open_search_desc + wiki_rel
|
|
|
|
def headscript(self, d):
|
|
html = []
|
|
# 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)
|