From: Matthijs Kooijman Date: Wed, 19 Nov 2008 17:43:40 +0000 (+0100) Subject: Factor out most of the Exodus theme. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=de9df7d614654bfc9399dfd3055a03833ab51f48;p=matthijs%2Fprojects%2Fwipi.git Factor out most of the Exodus theme. Most of the Exodus theme was only stuff to make the wipi look more like a website and less like a wipi, this should be reusable. --- diff --git a/plugin/theme/exodus.py b/plugin/theme/exodus.py index 479a258..f8d9bb4 100644 --- a/plugin/theme/exodus.py +++ b/plugin/theme/exodus.py @@ -6,116 +6,12 @@ @license: GNU GPL, see COPYING for details. """ -from MoinMoin.theme import ThemeBase +from site import SiteTheme -class Theme(ThemeBase): +class Theme(SiteTheme): name = "exodus" - def editbar(self, d): - if self.request.user.valid: - return ThemeBase.editbar(self, d) - else: - return '' - - def searchform(self, d): - if self.request.user.valid: - return ThemeBase.searchform(self, d) - else: - return '' - - def header(self, d, **kw): - """ Assemble wiki header - - @param d: parameter dictionary - @rtype: unicode - @return: page header html - """ - html = [ - # Pre header custom html - self.emit_custom_html(self.cfg.page_header1), - - # Header - u'', - - # Post header custom html (not recommended) - self.emit_custom_html(self.cfg.page_header2), - - # Start of page - self.startPage(), - ] - return u'\n'.join(html) - - def editorheader(self, d, **kw): - """ Assemble wiki header for editor - - @param d: parameter dictionary - @rtype: unicode - @return: page header html - """ - html = [ - # Pre header custom html - self.emit_custom_html(self.cfg.page_header1), - - # Header - u'', - - # Post header custom html (not recommended) - self.emit_custom_html(self.cfg.page_header2), - - # Start of page - self.startPage(), - ] - return u'\n'.join(html) - - def footer(self, d, **keywords): - """ Assemble wiki footer - - @param d: parameter dictionary - @keyword ...:... - @rtype: unicode - @return: page footer html - """ - page = d['page'] - html = [ - # End of page - self.pageinfo(page), - self.endPage(), - - # Pre footer custom html (not recommended!) - self.emit_custom_html(self.cfg.page_footer1), - - # Footer - u'', - - # 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 @@ -125,4 +21,3 @@ def execute(request): @return: Theme object """ return Theme(request) - diff --git a/plugin/theme/site.py b/plugin/theme/site.py new file mode 100644 index 0000000..e934485 --- /dev/null +++ b/plugin/theme/site.py @@ -0,0 +1,129 @@ +# -*- coding: iso-8859-1 -*- +""" + Evolution Events, website theme + + This theme is meant for wiki's that are meant to function as a website, + meaning nothing fancy and wiki-ish (at least when you're not logged in). + + This theme is meant to be subclassed. Subclasses should at least define a + name, and possibly override other stuff. +""" + +from MoinMoin.theme import ThemeBase + +class SiteTheme(ThemeBase): + + def editbar(self, d): + if self.request.user.valid: + return ThemeBase.editbar(self, d) + else: + return '' + + def searchform(self, d): + if self.request.user.valid: + return ThemeBase.searchform(self, d) + else: + return '' + + def header(self, d, **kw): + """ Assemble wiki header + + @param d: parameter dictionary + @rtype: unicode + @return: page header html + """ + html = [ + # Pre header custom html + self.emit_custom_html(self.cfg.page_header1), + + # Header + u'', + + # Post header custom html (not recommended) + self.emit_custom_html(self.cfg.page_header2), + + # Start of page + self.startPage(), + ] + return u'\n'.join(html) + + def editorheader(self, d, **kw): + """ Assemble wiki header for editor + + @param d: parameter dictionary + @rtype: unicode + @return: page header html + """ + html = [ + # Pre header custom html + self.emit_custom_html(self.cfg.page_header1), + + # Header + u'', + + # Post header custom html (not recommended) + self.emit_custom_html(self.cfg.page_header2), + + # Start of page + self.startPage(), + ] + return u'\n'.join(html) + + def footer(self, d, **keywords): + """ Assemble wiki footer + + @param d: parameter dictionary + @keyword ...:... + @rtype: unicode + @return: page footer html + """ + page = d['page'] + html = [ + # End of page + self.pageinfo(page), + self.endPage(), + + # Pre footer custom html (not recommended!) + self.emit_custom_html(self.cfg.page_footer1), + + # Footer + u'', + + # 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) +