changeset 5190:130276d62314

merge main
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 07 Oct 2009 19:29:45 +0200
parents 3ff40732d217 (diff) 4b452d8cb18b (current diff)
children c82ca74830a4 6af8509c5917
files
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/theme/__init__.py	Wed Oct 07 18:12:27 2009 +0200
+++ b/MoinMoin/theme/__init__.py	Wed Oct 07 19:29:45 2009 +0200
@@ -6,6 +6,8 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import StringIO
+
 from MoinMoin import i18n, wikiutil, config, version, caching
 from MoinMoin.action import get_available_actions
 from MoinMoin.Page import Page
@@ -1821,6 +1823,29 @@
         #request.write('<!-- auth_method == %s -->' % repr(request.user.auth_method))
         request.write('</body>\n</html>\n\n')
 
+    def sidebar(self, d, **keywords):
+        """ Display page called SideBar as an additional element on every page
+
+        @param d: parameter dictionary
+        @rtype: string
+        @return: sidebar html
+        """
+
+        # Check which page to display, return nothing if doesn't exist.
+        sidebar = self.request.getPragma('sidebar', u'SideBar')
+        page = Page(self.request, sidebar)
+        if not page.exists():
+            return u""
+        # Capture the page's generated HTML in a buffer.
+        buffer = StringIO.StringIO()
+        self.request.redirect(buffer)
+        try:
+            page.send_page(content_only=1, content_id="sidebar")
+        finally:
+            self.request.redirect()
+        return u'<div class="sidebar">%s</div>' % buffer.getvalue()
+
+
 class ThemeNotFound(Exception):
     """ Thrown if the supplied theme could not be found anywhere """