Factor out most of the Exodus theme.
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 19 Nov 2008 17:43:40 +0000 (18:43 +0100)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 19 Nov 2008 17:43:40 +0000 (18:43 +0100)
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.

plugin/theme/exodus.py
plugin/theme/site.py [new file with mode: 0644]

index 479a258c31c52ce7858eaddbe5fb070f30b3904b..f8d9bb466ea9812af943846146fb0eb1f854ca4d 100644 (file)
     @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'<div id="header">',
-            #self.logo(),
-            self.searchform(d),
-            #self.username(d),
-            u'<div id="locationline">',
-            #self.interwiki(d),
-            self.title(d),
-            u'</div>',
-            self.trail(d),
-            #self.navibar(d),
-            #u'<hr id="pageline">',
-            #u'<div id="pageline"><hr style="display:none;"></div>',
-            self.msg(d),
-            self.editbar(d),
-            u'</div>',
-
-            # 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'<div id="header">',
-            self.title(d),
-            self.msg(d),
-            u'</div>',
-
-            # 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'<div id="footer">',
-            self.username(d),
-            #self.editbar(d),
-            #self.credits(d),
-            #self.showversion(d, **keywords),
-            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
@@ -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 (file)
index 0000000..e934485
--- /dev/null
@@ -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'<div id="header">',
+            #self.logo(),
+            self.searchform(d),
+            #self.username(d),
+            u'<div id="locationline">',
+            #self.interwiki(d),
+            self.title(d),
+            u'</div>',
+            self.trail(d),
+            #self.navibar(d),
+            #u'<hr id="pageline">',
+            #u'<div id="pageline"><hr style="display:none;"></div>',
+            self.msg(d),
+            self.editbar(d),
+            u'</div>',
+
+            # 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'<div id="header">',
+            self.title(d),
+            self.msg(d),
+            u'</div>',
+
+            # 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'<div id="footer">',
+            self.username(d),
+            #self.editbar(d),
+            #self.credits(d),
+            #self.showversion(d, **keywords),
+            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)
+