|
|
f2e824 |
# -*- coding: iso-8859-1 -*-
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
MoinMoin - Modern Theme
|
|
|
f2e824 |
|
|
|
f2e824 |
Created for the CentOS Project Wiki. This is a
|
|
|
f2e824 |
modification of the MoinMoin's modern default
|
|
|
f2e824 |
wiki theme, and a continuation of previous
|
|
|
f2e824 |
modern-CentOS theme.
|
|
|
f2e824 |
|
|
|
f2e824 |
@copyright: 2008 by The CentOS ArtWork SIG.
|
|
|
f2e824 |
@license: GNU GPL, see COPYING for details.
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
from MoinMoin.theme import ThemeBase
|
|
|
f2e824 |
from MoinMoin import wikiutil
|
|
|
f2e824 |
|
|
|
f2e824 |
class Theme(ThemeBase):
|
|
|
f2e824 |
|
|
|
f2e824 |
name = "Modern"
|
|
|
f2e824 |
|
|
|
f2e824 |
def header(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
Assemble page header
|
|
|
f2e824 |
|
|
|
f2e824 |
@param d: parameter dictionary
|
|
|
f2e824 |
@rtype: string
|
|
|
f2e824 |
@return: page header html
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
html = [
|
|
|
f2e824 |
# Custom html above header
|
|
|
f2e824 |
self.emit_custom_html(self.cfg.page_header1),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Header
|
|
|
f2e824 |
u'
|
|
|
f2e824 |
self.logo(),
|
|
|
f2e824 |
self.navigation(d),
|
|
|
f2e824 |
self.errormsg(d),
|
|
|
f2e824 |
#self.googleads(d),
|
|
|
f2e824 |
#self.trail(d),
|
|
|
f2e824 |
#self.navibar(d),
|
|
|
f2e824 |
#u' ',
|
|
|
f2e824 |
#self.editbar(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
|
|
|
f2e824 |
# Custom html below header (not recomended!)
|
|
|
f2e824 |
#self.emit_custom_html(self.cfg.page_header2),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Page
|
|
|
f2e824 |
self.msg(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
self.startPage(),
|
|
|
f2e824 |
]
|
|
|
f2e824 |
return u'\n'.join(html)
|
|
|
f2e824 |
|
|
|
f2e824 |
def editorheader(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
Assemble page header for editor
|
|
|
f2e824 |
|
|
|
f2e824 |
@param d: parameter dictionary
|
|
|
f2e824 |
@rtype: string
|
|
|
f2e824 |
@return: page header html
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
html = [
|
|
|
f2e824 |
# Custom html above header
|
|
|
f2e824 |
self.emit_custom_html(self.cfg.page_header1),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Header
|
|
|
f2e824 |
u'
|
|
|
f2e824 |
self.logo(),
|
|
|
f2e824 |
self.navigation(d),
|
|
|
f2e824 |
self.errormsg(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
|
|
|
f2e824 |
# Custom html below header (not recomended!)
|
|
|
f2e824 |
# self.emit_custom_html(self.cfg.page_header2),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Page
|
|
|
f2e824 |
self.msg(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
self.title(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
self.startPage(),
|
|
|
f2e824 |
]
|
|
|
f2e824 |
return u'\n'.join(html)
|
|
|
f2e824 |
|
|
|
f2e824 |
def footer(self, d, **keywords):
|
|
|
f2e824 |
""" Assemble wiki footer
|
|
|
f2e824 |
|
|
|
f2e824 |
@param d: parameter dictionary
|
|
|
f2e824 |
@keyword ...:...
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: page footer html
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
page = d['page']
|
|
|
f2e824 |
html = [
|
|
|
f2e824 |
# End of page
|
|
|
f2e824 |
self.pageinfo(page),
|
|
|
f2e824 |
self.endPage(),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Pre footer custom html (not recommended!)
|
|
|
f2e824 |
# self.emit_custom_html(self.cfg.page_footer1),
|
|
|
f2e824 |
|
|
|
f2e824 |
# Footer
|
|
|
f2e824 |
u'
|
|
|
f2e824 |
self.navibar(d),
|
|
|
f2e824 |
self.editbar(d),
|
|
|
f2e824 |
self.credits(d),
|
|
|
f2e824 |
#self.showversion(d, **keywords),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
|
|
|
f2e824 |
# Post footer custom html
|
|
|
f2e824 |
# self.emit_custom_html(self.cfg.page_footer2),
|
|
|
f2e824 |
]
|
|
|
f2e824 |
return u'\n'.join(html)
|
|
|
f2e824 |
|
|
|
f2e824 |
def navigation (self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
assemble HTML code for CentOS Global Navigation
|
|
|
f2e824 |
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: CentOS Global Navigation
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
html = u'''
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
Home
|
|
|
f2e824 |
Downloads
|
|
|
f2e824 |
Docs
|
|
|
f2e824 |
Wiki
|
|
|
f2e824 |
Lists
|
|
|
f2e824 |
Bugs
|
|
|
f2e824 |
Forums
|
|
|
f2e824 |
Projects
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
''' % d
|
|
|
f2e824 |
return html
|
|
|
f2e824 |
|
|
|
f2e824 |
def errormsg(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
assemble HTML code for CentOS Identification
|
|
|
f2e824 |
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: CentOS Global Identification
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
html = [
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
self.username(d),
|
|
|
f2e824 |
self.editbar(d),
|
|
|
f2e824 |
self.searchform(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
u'Wiki',
|
|
|
f2e824 |
self.navibar(d),
|
|
|
f2e824 |
self.interwiki(d),
|
|
|
f2e824 |
self.trail(d),
|
|
|
f2e824 |
self.title(d),
|
|
|
f2e824 |
u'',
|
|
|
f2e824 |
]
|
|
|
f2e824 |
return u'\n'.join(html)
|
|
|
f2e824 |
|
|
|
f2e824 |
def googleads(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
assemble HTML code for the Google Ads
|
|
|
f2e824 |
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: Google Ads
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
html = u'''
|
|
|
f2e824 |
|
|
|
f2e824 |
<script type="text/javascript">
|
|
|
f2e824 |
google_ad_client = "pub-6973128787810819";
|
|
|
f2e824 |
google_ad_width = 468;
|
|
|
f2e824 |
google_ad_height = 68;
|
|
|
f2e824 |
google_ad_format = "468x60_as";
|
|
|
f2e824 |
google_ad_type = "text_image";
|
|
|
f2e824 |
google_ad_channel = "";
|
|
|
f2e824 |
google_color_border = "204c8d";
|
|
|
f2e824 |
google_color_bg = "345c97";
|
|
|
f2e824 |
google_color_link = "0000FF";
|
|
|
f2e824 |
google_color_text = "FFFFFF";
|
|
|
f2e824 |
google_color_url = "008000";
|
|
|
f2e824 |
//-->
|
|
|
f2e824 |
</script>
|
|
|
f2e824 |
|
|
|
f2e824 |
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
|
|
|
f2e824 |
</script>
|
|
|
f2e824 |
|
|
|
f2e824 |
''' % d
|
|
|
f2e824 |
return html
|
|
|
f2e824 |
|
|
|
f2e824 |
def credits(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
assemble HTML code for the credits.
|
|
|
f2e824 |
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: Creative Common Reference
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
|
|
|
f2e824 |
html = u'''
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
This wiki is licensed under a
|
|
|
f2e824 |
Creative Commons Attribution-Share Alike 3.0 Unported License.
|
|
|
f2e824 |
|
|
|
f2e824 |
The CentOS Project
|
|
|
f2e824 |
The Community Enterprise Operating System.
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
''' % d
|
|
|
f2e824 |
return html
|
|
|
f2e824 |
|
|
|
f2e824 |
def searchform(self, d):
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
assemble HTML code for the search forms
|
|
|
f2e824 |
|
|
|
f2e824 |
@param d: parameter dictionary
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: search form html
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
_ = self.request.getText
|
|
|
f2e824 |
form = self.request.form
|
|
|
f2e824 |
updates = {
|
|
|
f2e824 |
'search_label' : _('Search:'),
|
|
|
f2e824 |
'search_value': wikiutil.escape(form.get('value', [''])[0], 1),
|
|
|
f2e824 |
'search_full_label' : _('Text', formatted=False),
|
|
|
f2e824 |
'search_title_label' : _('Titles', formatted=False),
|
|
|
f2e824 |
}
|
|
|
f2e824 |
d.update(updates)
|
|
|
f2e824 |
|
|
|
f2e824 |
html = u'''
|
|
|
f2e824 |
<form id="searchform" method="get" action="">
|
|
|
f2e824 |
|
|
|
f2e824 |
<input type="hidden" name="action" value="fullsearch">
|
|
|
f2e824 |
<input type="hidden" name="context" value="180">
|
|
|
f2e824 |
<label for="searchinput">%(search_label)s</label>
|
|
|
f2e824 |
|
|
|
f2e824 |
onfocus="searchFocus(this)" onblur="searchBlur(this)"
|
|
|
f2e824 |
onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">
|
|
|
f2e824 |
|
|
|
f2e824 |
value="%(search_full_label)s" alt="Search Full Text">
|
|
|
f2e824 |
|
|
|
f2e824 |
value="%(search_title_label)s" alt="Search Titles">
|
|
|
f2e824 |
|
|
|
f2e824 |
</form>
|
|
|
f2e824 |
<script type="text/javascript">
|
|
|
f2e824 |
|
|
|
f2e824 |
var f = document.getElementById('searchform');
|
|
|
f2e824 |
f.getElementsByTagName('label')[0].style.display = 'none';
|
|
|
f2e824 |
var e = document.getElementById('searchinput');
|
|
|
f2e824 |
searchChange(e);
|
|
|
f2e824 |
searchBlur(e);
|
|
|
f2e824 |
//-->
|
|
|
f2e824 |
</script>
|
|
|
f2e824 |
''' % d
|
|
|
f2e824 |
return html
|
|
|
f2e824 |
|
|
|
f2e824 |
|
|
|
f2e824 |
# The following code make the navibar visible to users with
|
|
|
f2e824 |
# write access right ONLY!.
|
|
|
f2e824 |
|
|
|
f2e824 |
def shouldShowEditbar(self, page):
|
|
|
f2e824 |
""" Hide the edit bar if you can't edit """
|
|
|
f2e824 |
if self.request.user.may.write(page.page_name):
|
|
|
f2e824 |
return ThemeBase.shouldShowEditbar(self, page)
|
|
|
f2e824 |
return False
|
|
|
f2e824 |
|
|
|
f2e824 |
# The follwing code is just to use class instead of id in
|
|
|
f2e824 |
# the navibar element. It is not recommended by CCS v2.1
|
|
|
f2e824 |
# standard the use of two equals id elements on the same
|
|
|
f2e824 |
# page.
|
|
|
f2e824 |
|
|
|
f2e824 |
def navibar(self, d):
|
|
|
f2e824 |
""" Assemble the navibar
|
|
|
f2e824 |
|
|
|
f2e824 |
@param d: parameter dictionary
|
|
|
f2e824 |
@rtype: unicode
|
|
|
f2e824 |
@return: navibar html
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
request = self.request
|
|
|
f2e824 |
found = {} # pages we found. prevent duplicates
|
|
|
f2e824 |
items = [] # navibar items
|
|
|
f2e824 |
item = u'%s'
|
|
|
f2e824 |
current = d['page_name']
|
|
|
f2e824 |
|
|
|
f2e824 |
# Process config navi_bar
|
|
|
f2e824 |
if request.cfg.navi_bar:
|
|
|
f2e824 |
for text in request.cfg.navi_bar:
|
|
|
f2e824 |
pagename, link = self.splitNavilink(text)
|
|
|
f2e824 |
if pagename == current:
|
|
|
f2e824 |
cls = 'wikilink current'
|
|
|
f2e824 |
else:
|
|
|
f2e824 |
cls = 'wikilink'
|
|
|
f2e824 |
items.append(item % (cls, link))
|
|
|
f2e824 |
found[pagename] = 1
|
|
|
f2e824 |
|
|
|
f2e824 |
# Add user links to wiki links, eliminating duplicates.
|
|
|
f2e824 |
userlinks = request.user.getQuickLinks()
|
|
|
f2e824 |
for text in userlinks:
|
|
|
f2e824 |
# Split text without localization, user knows what he wants
|
|
|
f2e824 |
pagename, link = self.splitNavilink(text, localize=0)
|
|
|
f2e824 |
if not pagename in found:
|
|
|
f2e824 |
if pagename == current:
|
|
|
f2e824 |
cls = 'userlink current'
|
|
|
f2e824 |
else:
|
|
|
f2e824 |
cls = 'userlink'
|
|
|
f2e824 |
items.append(item % (cls, link))
|
|
|
f2e824 |
found[pagename] = 1
|
|
|
f2e824 |
|
|
|
f2e824 |
# Add current page at end
|
|
|
f2e824 |
if not current in found:
|
|
|
f2e824 |
title = d['page'].split_title(request)
|
|
|
f2e824 |
title = self.shortenPagename(title)
|
|
|
f2e824 |
link = d['page'].link_to(request, title)
|
|
|
f2e824 |
cls = 'current'
|
|
|
f2e824 |
items.append(item % (cls, link))
|
|
|
f2e824 |
|
|
|
f2e824 |
# Assemble html
|
|
|
f2e824 |
items = u''.join(items)
|
|
|
f2e824 |
html = u'''
|
|
|
f2e824 |
|
|
|
f2e824 |
%s
|
|
|
f2e824 |
|
|
|
f2e824 |
''' % items
|
|
|
f2e824 |
return html
|
|
|
f2e824 |
|
|
|
f2e824 |
def execute(request):
|
|
|
f2e824 |
""" Generate and return a theme object
|
|
|
f2e824 |
|
|
|
f2e824 |
@param request: the request object
|
|
|
f2e824 |
@rtype: MoinTheme
|
|
|
f2e824 |
@return: Theme object
|
|
|
f2e824 |
"""
|
|
|
f2e824 |
return Theme(request)
|