comparison MoinMoin/theme/__init__.py @ 5189:3ff40732d217

add the sidebar() method from Mandarin and Gugiel themes to ThemeBase
author Radomir Dopieralski <moindev@sheep.art.pl>
date Wed, 07 Oct 2009 19:28:18 +0200
parents d887cc013e76
children 6af8509c5917
comparison
equal deleted inserted replaced
5187:b766ab8f2009 5189:3ff40732d217
3 MoinMoin - Theme Package 3 MoinMoin - Theme Package
4 4
5 @copyright: 2003-2008 MoinMoin:ThomasWaldmann 5 @copyright: 2003-2008 MoinMoin:ThomasWaldmann
6 @license: GNU GPL, see COPYING for details. 6 @license: GNU GPL, see COPYING for details.
7 """ 7 """
8
9 import StringIO
8 10
9 from MoinMoin import i18n, wikiutil, config, version, caching 11 from MoinMoin import i18n, wikiutil, config, version, caching
10 from MoinMoin.action import get_available_actions 12 from MoinMoin.action import get_available_actions
11 from MoinMoin.Page import Page 13 from MoinMoin.Page import Page
12 from MoinMoin.util import pysupport 14 from MoinMoin.util import pysupport
1819 request.write('<li>%s</li>\n' % t) 1821 request.write('<li>%s</li>\n' % t)
1820 request.write('</ul>\n') 1822 request.write('</ul>\n')
1821 #request.write('<!-- auth_method == %s -->' % repr(request.user.auth_method)) 1823 #request.write('<!-- auth_method == %s -->' % repr(request.user.auth_method))
1822 request.write('</body>\n</html>\n\n') 1824 request.write('</body>\n</html>\n\n')
1823 1825
1826 def sidebar(self, d, **keywords):
1827 """ Display page called SideBar as an additional element on every page
1828
1829 @param d: parameter dictionary
1830 @rtype: string
1831 @return: sidebar html
1832 """
1833
1834 # Check which page to display, return nothing if doesn't exist.
1835 sidebar = self.request.getPragma('sidebar', u'SideBar')
1836 page = Page(self.request, sidebar)
1837 if not page.exists():
1838 return u""
1839 # Capture the page's generated HTML in a buffer.
1840 buffer = StringIO.StringIO()
1841 self.request.redirect(buffer)
1842 try:
1843 page.send_page(content_only=1, content_id="sidebar")
1844 finally:
1845 self.request.redirect()
1846 return u'<div class="sidebar">%s</div>' % buffer.getvalue()
1847
1848
1824 class ThemeNotFound(Exception): 1849 class ThemeNotFound(Exception):
1825 """ Thrown if the supplied theme could not be found anywhere """ 1850 """ Thrown if the supplied theme could not be found anywhere """
1826 1851
1827 def load_theme(request, theme_name=None): 1852 def load_theme(request, theme_name=None):
1828 """ Load a theme for this request. 1853 """ Load a theme for this request.