Blame Identity/Webenv/Moin/1.5.7-1.el5.rf/Modern.py

ef5584
# -*- coding: iso-8859-1 -*-
ef5584
"""
ef5584
    MoinMoin - Modern Theme
ef5584
ef5584
    Created for the CentOS Project Wiki. This is a
ef5584
    modification of the MoinMoin's modern default
ef5584
    wiki theme, and a continuation of previous
ef5584
    modern-CentOS theme.
ef5584
ef5584
    @copyright: 2008 by The CentOS ArtWork SIG.
ef5584
    @license: GNU GPL, see COPYING for details.  
ef5584
"""
ef5584
ef5584
from MoinMoin.theme import ThemeBase
ef5584
from MoinMoin import wikiutil
ef5584
ef5584
class Theme(ThemeBase):
ef5584
ef5584
    name = "Modern"
ef5584
ef5584
    def header(self, d):
ef5584
        """
ef5584
        Assemble page header
ef5584
        
ef5584
        @param d: parameter dictionary
ef5584
        @rtype: string
ef5584
        @return: page header html
ef5584
        """
ef5584
ef5584
        html = [
ef5584
            # Custom html above header
ef5584
            self.emit_custom_html(self.cfg.page_header1),
ef5584
ef5584
            # Header
ef5584
            u'
ef5584
            self.logo(),
ef5584
	    self.navigation(d),
ef5584
	    self.errormsg(d),
ef5584
            #self.googleads(d),
ef5584
            #self.trail(d),
ef5584
	    #self.navibar(d),
ef5584
	    #u'

',
ef5584
 	    #self.editbar(d),
ef5584
            u'',
ef5584
ef5584
            # Custom html below header (not recomended!)
ef5584
            #self.emit_custom_html(self.cfg.page_header2),
ef5584
ef5584
            # Page
ef5584
            self.msg(d),
ef5584
            u'
',
ef5584
            u'',
ef5584
            self.startPage(),
ef5584
            ]
ef5584
        return u'\n'.join(html)
ef5584
ef5584
    def editorheader(self, d):
ef5584
        """
ef5584
        Assemble page header for editor
ef5584
        
ef5584
        @param d: parameter dictionary
ef5584
        @rtype: string
ef5584
        @return: page header html
ef5584
        """
ef5584
ef5584
        html = [
ef5584
            # Custom html above header
ef5584
            self.emit_custom_html(self.cfg.page_header1),
ef5584
ef5584
            # Header
ef5584
            u'
ef5584
            self.logo(),
ef5584
	    self.navigation(d),
ef5584
	    self.errormsg(d),
ef5584
            u'',
ef5584
ef5584
            # Custom html below header (not recomended!)
ef5584
            # self.emit_custom_html(self.cfg.page_header2),
ef5584
            
ef5584
            # Page
ef5584
            self.msg(d),
ef5584
            u'
',
ef5584
	    self.title(d),
ef5584
            u'',
ef5584
            self.startPage(),
ef5584
            ]
ef5584
        return u'\n'.join(html)
ef5584
ef5584
    def footer(self, d, **keywords):
ef5584
        """ Assemble wiki footer
ef5584
        
ef5584
        @param d: parameter dictionary
ef5584
        @keyword ...:...
ef5584
        @rtype: unicode
ef5584
        @return: page footer html
ef5584
        """
ef5584
        page = d['page']
ef5584
        html = [
ef5584
            # End of page
ef5584
            self.pageinfo(page),
ef5584
            self.endPage(),
ef5584
ef5584
            # Pre footer custom html (not recommended!)
ef5584
            # self.emit_custom_html(self.cfg.page_footer1),
ef5584
ef5584
            # Footer
ef5584
	    u'
ef5584
            self.navibar(d),
ef5584
            self.editbar(d),
ef5584
            self.credits(d),
ef5584
            #self.showversion(d, **keywords),
ef5584
            u'',
ef5584
            
ef5584
            # Post footer custom html
ef5584
            # self.emit_custom_html(self.cfg.page_footer2),
ef5584
            ]
ef5584
        return u'\n'.join(html)
ef5584
ef5584
    def navigation (self, d): 
ef5584
    	"""
ef5584
	assemble HTML code for CentOS Global Navigation
ef5584
        
ef5584
        @rtype: unicode
ef5584
        @return: CentOS Global Navigation
ef5584
        """
ef5584
ef5584
	html = u'''
ef5584
    
ef5584
    
    ef5584
                
  • Home
  • ef5584
                
  • Downloads
  • ef5584
                
  • Docs
  • ef5584
                
  • Wiki
  • ef5584
                
  • Lists
  • ef5584
                
  • Bugs
  • ef5584
                
  • Forums
  • ef5584
                
  • Projects
  • ef5584
        
    ef5584
        
    ef5584
    ''' % d
    ef5584
            return html
    ef5584
    ef5584
        def errormsg(self, d): 
    ef5584
        	"""
    ef5584
    	assemble HTML code for CentOS Identification
    ef5584
            
    ef5584
            @rtype: unicode
    ef5584
            @return: CentOS Global Identification
    ef5584
            """
    ef5584
            html = [
    ef5584
                u'
    ',
    ef5584
    	    u'Wiki',
    ef5584
    	    u'
    ef5584
    	    self.username(d),
    ef5584
                self.editbar(d),
    ef5584
    	    self.searchform(d),
    ef5584
    	    u'',
    ef5584
                u'

    Wiki

    ',
    ef5584
                self.navibar(d),
    ef5584
                self.interwiki(d),
    ef5584
                self.trail(d),
    ef5584
                self.title(d),
    ef5584
                u'',
    ef5584
                ]
    ef5584
            return u'\n'.join(html)
    ef5584
    ef5584
        def googleads(self, d):
    ef5584
            """
    ef5584
            assemble HTML code for the Google Ads
    ef5584
            
    ef5584
            @rtype: unicode
    ef5584
            @return: Google Ads
    ef5584
            """
    ef5584
    ef5584
            html = u'''
    ef5584
    ef5584
    <script type="text/javascript">
    ef5584
    google_ad_client = "pub-6973128787810819";
    ef5584
    google_ad_width = 468;
    ef5584
    google_ad_height = 68;
    ef5584
    google_ad_format = "468x60_as";
    ef5584
    google_ad_type = "text_image";
    ef5584
    google_ad_channel = "";
    ef5584
    google_color_border = "204c8d";
    ef5584
    google_color_bg = "345c97";
    ef5584
    google_color_link = "0000FF";
    ef5584
    google_color_text = "FFFFFF";
    ef5584
    google_color_url = "008000";
    ef5584
    //-->
    ef5584
    </script>
    ef5584
    ef5584
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    ef5584
    </script>
    ef5584
    ef5584
    ''' % d
    ef5584
            return html
    ef5584
    ef5584
        def credits(self, d):
    ef5584
            """
    ef5584
            assemble HTML code for the credits.
    ef5584
            
    ef5584
            @rtype: unicode
    ef5584
            @return: Creative Common Reference
    ef5584
            """
    ef5584
    ef5584
            html = u'''
    ef5584
    ef5584
    ef5584
    Creative Commons License
    ef5584
    ef5584

    This wiki is licensed under a
    ef5584
    Creative Commons Attribution-Share Alike 3.0 Unported License.
    ef5584
    ef5584

    The CentOS Project

    ef5584

    The Community Enterprise Operating System.

    ef5584
    ef5584
    ef5584
    ''' % d
    ef5584
            return html
    ef5584
    ef5584
        def searchform(self, d):
    ef5584
            """
    ef5584
            assemble HTML code for the search forms
    ef5584
            
    ef5584
            @param d: parameter dictionary
    ef5584
            @rtype: unicode
    ef5584
            @return: search form html
    ef5584
            """
    ef5584
            _ = self.request.getText
    ef5584
            form = self.request.form
    ef5584
            updates = {
    ef5584
                'search_label' : _('Search:'),
    ef5584
                'search_value': wikiutil.escape(form.get('value', [''])[0], 1),
    ef5584
                'search_full_label' : _('Text', formatted=False),
    ef5584
                'search_title_label' : _('Titles', formatted=False),
    ef5584
                }
    ef5584
            d.update(updates)
    ef5584
    ef5584
            html = u'''
    ef5584
    <form id="searchform" method="get" action="">
    ef5584
    ef5584
    <input type="hidden" name="action" value="fullsearch">
    ef5584
    <input type="hidden" name="context" value="180">
    ef5584
    <label for="searchinput">%(search_label)s</label>
    ef5584
    ef5584
        onfocus="searchFocus(this)" onblur="searchBlur(this)"
    ef5584
        onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">
    ef5584
    ef5584
        value="%(search_full_label)s" alt="Search Full Text">
    ef5584
    ef5584
        value="%(search_title_label)s" alt="Search Titles">
    ef5584
    ef5584
    </form>
    ef5584
    <script type="text/javascript">
    ef5584
    ef5584
    var f = document.getElementById('searchform');
    ef5584
    f.getElementsByTagName('label')[0].style.display = 'none';
    ef5584
    var e = document.getElementById('searchinput');
    ef5584
    searchChange(e);
    ef5584
    searchBlur(e);
    ef5584
    //-->
    ef5584
    </script>
    ef5584
    ''' % d
    ef5584
            return html
    ef5584
    ef5584
    ef5584
    # The following code make the navibar visible to users with
    ef5584
    # write access right ONLY!.
    ef5584
    ef5584
        def shouldShowEditbar(self, page):
    ef5584
            """ Hide the edit bar if you can't edit """
    ef5584
            if self.request.user.may.write(page.page_name):
    ef5584
                return ThemeBase.shouldShowEditbar(self, page)
    ef5584
            return False
    ef5584
    ef5584
    # The follwing code is just to use class instead of id in
    ef5584
    # the navibar element. It is not recommended by CCS v2.1
    ef5584
    # standard the use of two equals id elements on the same
    ef5584
    # page.
    ef5584
    ef5584
        def navibar(self, d):
    ef5584
            """ Assemble the navibar
    ef5584
    ef5584
            @param d: parameter dictionary
    ef5584
            @rtype: unicode
    ef5584
            @return: navibar html
    ef5584
            """
    ef5584
            request = self.request
    ef5584
            found = {} # pages we found. prevent duplicates
    ef5584
            items = [] # navibar items
    ef5584
            item = u'
  • %s
  • '
    ef5584
            current = d['page_name']
    ef5584
    ef5584
            # Process config navi_bar
    ef5584
            if request.cfg.navi_bar:
    ef5584
                for text in request.cfg.navi_bar:
    ef5584
                    pagename, link = self.splitNavilink(text)
    ef5584
                    if pagename == current:
    ef5584
                        cls = 'wikilink current'
    ef5584
                    else:
    ef5584
                        cls = 'wikilink'
    ef5584
                    items.append(item % (cls, link))
    ef5584
                    found[pagename] = 1
    ef5584
    ef5584
            # Add user links to wiki links, eliminating duplicates.
    ef5584
            userlinks = request.user.getQuickLinks()
    ef5584
            for text in userlinks:
    ef5584
                # Split text without localization, user knows what he wants
    ef5584
                pagename, link = self.splitNavilink(text, localize=0)
    ef5584
                if not pagename in found:
    ef5584
                    if pagename == current:
    ef5584
                        cls = 'userlink current'
    ef5584
                    else:
    ef5584
                        cls = 'userlink'
    ef5584
                    items.append(item % (cls, link))
    ef5584
                    found[pagename] = 1
    ef5584
    ef5584
            # Add current page at end
    ef5584
            if not current in found:
    ef5584
                title = d['page'].split_title(request)
    ef5584
                title = self.shortenPagename(title)
    ef5584
                link = d['page'].link_to(request, title)
    ef5584
                cls = 'current'
    ef5584
                items.append(item % (cls, link))
    ef5584
    ef5584
            # Assemble html
    ef5584
            items = u''.join(items)
    ef5584
            html = u'''
    ef5584
      ef5584
      %s
      ef5584
      ef5584
      ''' % items
      ef5584
              return html
      ef5584
      ef5584
      def execute(request):
      ef5584
          """ Generate and return a theme object
      ef5584
              
      ef5584
          @param request: the request object
      ef5584
          @rtype: MoinTheme
      ef5584
          @return: Theme object
      ef5584
          """
      ef5584
          return Theme(request)