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

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

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

    Wiki

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

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

    The CentOS Project

    d6e8d8

    The Community Enterprise Operating System.

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