web/wiki/kindofblue kindofblue.py,NONE,1.1

Dimitris Glezos (glezos) fedora-websites-list at redhat.com
Wed Jun 6 11:59:31 UTC 2007


Author: glezos

Update of /cvs/fedora/web/wiki/kindofblue
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32287/wiki/kindofblue

Added Files:
	kindofblue.py 
Log Message:
Adding wiki directory, holding kindofblue (moved from /cvs/fedora/web)
and common dir of moin



--- NEW FILE kindofblue.py ---
# -*- coding: iso-8859-1 -*-
"""MoinMoin theme "kindofblue" by Hrishikesh Ballal, Diana Fong

Credits to "Haran" who published his sinorca-design at www.oswd.org
Heavily modified by Hrishikesh Ballal for Fedoraproject.org website. 
last update :- 7/28 @ 21.50

"""

from MoinMoin import wikiutil
from MoinMoin.Page import Page
from MoinMoin.theme import ThemeBase

class Theme(ThemeBase):
    """ here are the functions generating the html responsible for
        the look and feel of your wiki site
    """

    name = "kindofblue"

    def iconbar(self, d):
        """
        Assemble the iconbar
        
        @param d: parameter dictionary
        @rtype: string
        @return: iconbar html
        """
        iconbar = []
        if self.cfg.page_iconbar and self.request.user.show_toolbar and d['page_name']:
            iconbar.append('<ul id="iconbar">\n')
            icons = self.cfg.page_iconbar[:]
            for icon in icons:
                if icon == "up":
                    if d['page_parent_page']:
                        iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
                elif icon == "subscribe":
                    iconbar.append('<li>%s</li>\n' % self.make_iconlink(
                        ["subscribe", "unsubscribe"][self.request.user.isSubscribedTo([d['page_name']])], d))
                elif icon == "home":
                    if d['page_home_page']:
                        iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
                else:
                    iconbar.append('<li>%s</li>\n' % self.make_iconlink(icon, d))
            iconbar.append('</ul>\n')
        return ''.join(iconbar)

    def editbar(self, d):
        """ Assemble the page edit bar.

        Display on existing page. Replace iconbar, showtext, edit text,
        refresh cache and available actions.
        
        @param d: parameter dictionary
        @rtype: unicode
        @return: iconbar html
        """
        page = d['page']       
        if not self.shouldShowEditbar(page):
            return ''

        # Use cached editbar if possible.
        cacheKey = 'editbar'
        cached = self._cache.get(cacheKey)
        if cached:
            return cached

        # Make new edit bar
        request = self.request
        _ = self.request.getText
        link = wikiutil.link_tag
        quotedname = wikiutil.quoteWikinameURL(page.page_name)
        links = []
        add = links.append
	add(self.subscribeLink(page))
        
        # Parent page
        #parent = page.getParentPage()
        #if parent:
        #   add(parent.link_to(request, _("Show Parent", formatted=False))) 
        
        # Page actions
        if page.isWritable() and request.user.may.write(page.page_name):
            add(link(request, quotedname + '?action=edit', _('Edit')))
        else:
            add(_('     Immutable Page', formatted=False))              
        
        add(link(request, quotedname + '?action=info', 
                 _('Get Info', formatted=False)))
        add(self.actionsMenu(page))
        
        # Format
        items = '\n'.join(['<li>%s</li>' % item for item in self.editbarItems(page) if item])
        html = u'<ul class="editbar">\n%s\n</ul>\n' % items
        
        # cache for next call
        self._cache[cacheKey] = html
        return html
   
    def wikipanel(self, d):
        """ Create wiki panel """
        _ = self.request.getText
        html = [
            u'<div class="sidepanel">',
            u'  <p class="sideBarTitle">%s</p>' % _("Navigation"),
            self.navibar(d),
            u'</div>',
            ]
        return u'\n'.join(html)
    
    def pagepanel(self, d):
        """ Create page panel """
        _ = self.request.getText
        if self.shouldShowEditbar(d['page']):
            html = [

                u'<div class="sidepanel">',
                u'  <p class="sideBarTitle">%s</p>' % _("Page"),
                self.editbar(d),
                u'</div>',
                ]
            return u'\n'.join(html)
        return ''   
        
    def userpanel(self, d):
        """ Create user panel """
        _ = self.request.getText

        html = [
        
            u'<div class="sidepanel">',
            u'  <p class="sideBarTitle">%s</p>' %  _("User"),
            self.username(d),
            u'</div>'
            ]
        return u'\n'.join(html)

    def logo(self):
        """ Assemble logo with link to front page

        adds h1-tags for sinorca
        """
        if self.cfg.logo_string:
            pagename = wikiutil.getFrontPage(self.request).page_name
            pagename = wikiutil.quoteWikinameURL(pagename)
            logo = wikiutil.link_tag(self.request, pagename, self.cfg.logo_string)
            html = u'''<div id="logo"> <h1 class="            headerTitle">%s</h1></div>''' % logo
            return html
        return u''

    def header(self, d):
        """
        Assemble page header
        
        @param d: parameter dictionary
        @rtype: string
        @return: page header html
        """
        _ = self.request.getText

        trail = self.trail(d)

        html = [
            # Header
            u'<div id="header">',
            # Custom html super-header
            self.emit_custom_html(self.cfg.page_header1),
            u'  <div class="midHeader">',
            
         u' <a href="/wiki/" title="Start page"><img src="%s/kindofblue/img/logos/wiki02nw.png"  alt="Fedoraproject.org" border="1" style="position: absolute; top: 0px; left: 0px; " /></a>' % self.cfg.url_prefix,
            
           # self.logo(),
            u'  </div>',
            # Custom html below header (not recomended!)
            self.emit_custom_html(self.cfg.page_header2),
            # trail,
            u'</div>',
            
            # Iconbar
           # self.iconbar(d),

            # Sidebar   
            u'<!-- ##### Side Bar ##### -->',
            u'<div id="sidebar">',
       		u'<div><img id="sidebar-header" src="%s/kindofblue/img/logos/wiki-sidebar-header.png" alt="" height="71" width="100%%"></div>' % self.cfg.url_prefix,
           # u'<div class="sidepanel">',
            #u'  <p class="sideBarTitle">Search in %s</p>' % _(self.cfg.sitename),
            #self.searchform(d),
            #u'</div>',

            self.wikipanel(d),
            self.pagepanel(d),
            self.userpanel(d),         
           
            u'</div>',

            
            # u'<div class="sidepanel">',
            
            #u'</div>',
            # Page
            self.startPage(),            
            self.searchform(d),
            self.title(d),
				self.msg(d),
          # self.credits(d),
            ]
        return u'\n'.join(html)
    
    def footer(self, d, **keywords):
        """ Assemble page footer
        
        @param d: parameter dictionary
        @keyword ...:...
        @rtype: string
        @return: page footer html
        """
        page = d['page']
        html = [
            # Page end
            # Used to extend the page to the bottom of the sidebar
          #  u'<div id="pagebottom">',
            #self.pageinfo(page), 
            #self.credits(d),
           self.endPage(),
          # u'</div>',
            # Custom html above footer
           # self.emit_custom_html(self.cfg.page_footer1),
              u'<div id="footer">',
				  u'<table width="100%"><tr><td width="50%">',
             self.pageinfo(page), 
              u'</td><td width="*">',
             self.credits(d),
            u'</td></tr></table></div>',
            # And bellow
           # self.emit_custom_html(self.cfg.page_footer2),
            ]
        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 = [
			self.header(d)
        ]
        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)





More information about the Fedora-websites-list mailing list