~ubuntu-it-wiki/wiki-ubuntu-it/wiki-repo

« back to all changes in this revision

Viewing changes to data/plugin/theme/light.py

  • Committer: Leo Iannacone
  • Date: 2011-06-01 19:48:26 UTC
  • Revision ID: l3on@ubuntu.com-20110601194826-a8zt6and1d9gqmfu
Update light theme to ubuntu-it style

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: iso-8859-1 -*-
2
1
"""
3
 
    MoinMoin ubuntu theme
4
 
 
5
 
    @copyright: (c) 2003-2004 by Nir Soffer, Thomas Waldmann
6
 
    @license: GNU GPL, see COPYING for details.
7
 
 
8
 
    Borrows heavily from modern, a bit from Classic, and has a few 
9
 
    things of its own.
 
2
MoinMoin ubuntu-it theme
 
3
 
 
4
@copyright: (c) 
 
5
        2003-2004 by Nir Soffer, Thomas Waldmann
 
6
        2008  Ubuntu-it - Modified by Milo Casagrande <milo@ubuntu.com>, Leo Iannacone <l3on@ubuntu.com>, Alessio Treglia <quadrispro@ubuntu.com>
 
7
        2011  Ubuntu-it - Modified by Leo Iannacone <l3on@ubuntu.com>, Giuseppe Terrasi <peppe84@ubuntu-it.org>
 
8
@license: GNU GPL, see COPYING for details.
 
9
 
 
10
Is essentially a massive rip-off of the Ubuntu theme, hacked up to make it fit nicer with the ubuntu-it top bar. (Matthew East)
 
11
    
 
12
This is the base of *ubuntu-it.py themes (Leo Iannacone).
10
13
"""
11
14
 
12
15
from MoinMoin.theme import ThemeBase
13
16
from MoinMoin import wikiutil
14
17
from MoinMoin.Page import Page
15
 
 
 
18
from datetime import date
16
19
 
17
20
class Theme(ThemeBase):
18
 
 
 
21
        
19
22
    name = 'light'
20
23
 
21
24
# Overriding theme/__init__.py #########################################
22
 
 
23
 
    # fake _ function to get gettext recognize those texts:
 
25
# fake _ function to get gettext recognize those texts:
24
26
    _ = lambda x: x
25
 
       
 
27
 
26
28
    # TODO: remove icons that are not used any more.
27
29
    icons = {
28
30
        # key         alt                        icon filename      w   h
29
 
        # ------------------------------------------------------------------
30
 
        # navibar
31
 
        'help':       ("%(page_help_contents)s", "s-help.png",         20, 20),
32
 
        'find':       ("%(page_find_page)s",     "s-search.png",       20, 20),
33
 
        'diff':       (_("Diffs"),               "u-diff.png",         22, 22),
34
 
        'info':       (_("Info"),                "u-info.png",         22, 22),
35
 
        'edit':       (_("Edit"),                "u-edit.png",         20, 20),
36
 
        'unsubscribe':(_("Unsubscribe"),         "u-unsubscribe.png",  23, 21),
37
 
        'subscribe':  (_("Subscribe"),           "u-subscribe_dk.png", 23, 21),
38
 
        'raw':        (_("Raw"),                 "u-raw.png",          21, 23),
39
 
        'xml':        (_("XML"),                 "moin-xml2.png",      36, 14),
40
 
        'print':      (_("Print"),               "u-print.png",        20, 20),
41
 
        'view':       (_("View"),                "u-show.png",         20, 20),
42
 
        'home':       (_("Home"),                "u-home.png",         20, 20),
43
 
        'up':         (_("Up"),                  "u-parent.png",       20, 20),
44
31
        # FileAttach
45
 
        'attach':     ("%(attach_count)s",       "moin-attach.png",  7, 15),
 
32
        'attach':     ("%(attach_count)s",       "icons/moin-attach.png",   16, 16),
 
33
        'info':       ("[INFO]",                 "icons/moin-info.png",     16, 16),
 
34
        'attachimg':  (_("[ATTACH]"),            "icons/attach.png",        32, 32),
46
35
        # RecentChanges
47
 
        'rss':        (_("[RSS]"),               "moin-rss.png",    36, 14),
48
 
        'deleted':    (_("[DELETED]"),           "u-deleted.png",      22, 22),
49
 
        'updated':    (_("[UPDATED]"),           "u-updated.png",      22, 22),
50
 
        'new':        (_("[NEW]"),               "u-new.png",          22, 22),
51
 
        'diffrc':     (_("[DIFF]"),              "u-diff.png",         22, 22),
 
36
        'rss':        (_("[RSS]"),               "icons/moin-rss.png",      16, 16),
 
37
        'deleted':    (_("[DELETED]"),           "icons/moin-deleted.png",  16, 16),
 
38
        'updated':    (_("[UPDATED]"),           "icons/moin-updated.png",  16, 16),
 
39
        'renamed':    (_("[RENAMED]"),           "icons/moin-renamed.png",  16, 16),
 
40
        'conflict':   (_("[CONFLICT]"),          "icons/moin-conflict.png", 16, 16),
 
41
        'new':        (_("[NEW]"),               "icons/moin-new.png",      16, 16),
 
42
        'diffrc':     (_("[DIFF]"),              "icons/moin-diff.png",     16, 16),
 
43
        'diff':     (_("[DIFF]"),                "icons/moin-diff.png",     16, 16),
52
44
        # General
53
 
        'bottom':     (_("[BOTTOM]"),            "u-bottom.png",       14, 10),
54
 
        'top':        (_("[TOP]"),               "u-top.png",          14, 10),
55
 
        'www':        ("[WWW]",                  "u-www.png",          16, 16),
56
 
        'mailto':     ("[MAILTO]",               "u-email.png",        23, 13),
57
 
        'news':       ("[NEWS]",                 "u-news.png",         16, 16),
58
 
        'telnet':     ("[TELNET]",               "u-telnet.png",       16, 16),
59
 
        'ftp':        ("[FTP]",                  "u-ftp.png",          16, 16),
60
 
        'file':       ("[FILE]",                 "u-ftp.png",          16, 16),
 
45
        'bottom':     (_("[BOTTOM]"),            "icons/icons/moin-bottom.png",   16, 16),
 
46
        'top':        (_("[TOP]"),               "icons/moin-top.png",      16, 16),
 
47
        'www':        ("[WWW]",                  "icons/moin-www.png",      16, 16),
 
48
        'mailto':     ("[MAILTO]",               "icons/moin-email.png",    16, 16),
 
49
        'news':       ("[NEWS]",                 "icons/moin-news.png",     16, 16),
 
50
        'telnet':     ("[TELNET]",               "icons/moin-telnet.png",   16, 16),
 
51
        'ftp':        ("[FTP]",                  "icons/moin-ftp.png",      16, 16),
 
52
        'file':       ("[FILE]",                 "icons/moin-ftp.png",      16, 16),
61
53
        # search forms
62
 
        'searchbutton': ("[?]",                  "s-search.png",       20, 20),
63
 
        'interwiki':  ("[%(wikitag)s]",          "u-inter.png",        16, 16),
64
 
        # smileys
65
 
        'X-(': ("Angry X-(","icon_mad.png",16,16),
66
 
        ':D': ("Big Grin :)","icon_biggrin.png",16,16),
67
 
        '<:(': ("Sad <:(","icon_sad.png",16,16),
68
 
        ':o': ("Surprised :o","icon_surprised.png",16,16),
69
 
        ':(': ("Sad :(","icon_sad.png",16,16),
70
 
        ':)': ("Smile :)","icon_smile.png",16,16),
71
 
        'B)': ("Awesome! B)","icon_cool.png",16,16),
72
 
        ':))': ("Funny :))","icon_razz.png",16,16),
73
 
        ';)': ("Wink ;)","icon_wink.png",16,16),
74
 
        '/!\\': ("Warning /!\\","icon_eek.png",16,16),
75
 
        '<!>': ("Info <!>","icon_cool.png",16,16),
76
 
        '(!)': ("Info (!)","icon_cool.png",16,16),
77
 
        ':-?': ("Tongue out :-?","icon_razz.png",16,16),
78
 
        '>:>': ("Angry >:>","icon_mad.png",16,16),#think this is meant to be devilish or something
79
 
        '|)': ("Smile |)","icon_smile.png",16,16),
80
 
        ':-(': ("Sad :-(","icon_sad.png",16,16),
81
 
        ':-)': ("Smile :-)","icon_smile.png",16,16),
82
 
        'B-)': ("Awesome B-)","icon_cool.png",16,16),
83
 
        ':\\': ("Confused :\\","icon_confused.png",16,16),
84
 
        ':-))': ("Funny :))","icon_razz.png",16,16),
85
 
        ';-)': ("Wink ;-)","icon_wink.png",16,16),
86
 
        '|-)': ("Smile |-)","icon_smile.png",16,16),
87
 
        '{*}': ("Ubuntu","icon_cof.png", 16,16),
88
 
        'renamed': ("Renamed","moin-renamed.png", 60,12),
89
 
        'conflict': ("Conflict","moin-conflict.png", 60,12),
90
 
        '(./)': ("(./)","checkmark.png", 16,16),
91
 
        '{OK}': ("(OK)","thumbs-up.png", 16,16),
92
 
        '{X}': ("(X)","icon-error.png", 16,16),
93
 
        '{i}': ("(i)","icon-info.png", 16,16), 
94
 
        '{1}': ("(1)","prio1.png", 16,16),
95
 
        '{2}': ("(2)","prio2.png", 16,16),
96
 
        '{3}': ("(3)","prio3.png", 16,16),
97
 
        '{o}': ("(o)","star_off.png", 16,16),
 
54
        'searchbutton': ("[?]",                  "icons/moin-search.png",   16, 16),
 
55
        'interwiki':  ("[%(wikitag)s]",          "icons/moin-inter.png",    16, 16),
 
56
 
 
57
        # smileys (this is CONTENT, but good looking smileys depend on looking
 
58
        # adapted to the theme background color and theme style in general)
 
59
        #vvv    ==      vvv  this must be the same for GUI editor converter
 
60
        'X-(':        ("X-(",                    'icons/angry.png',         16, 16),
 
61
        ':D':         (":D",                     'icons/biggrin.png',       16, 16),
 
62
        '<:(':        ("<:(",                    'icons/frown.png',         16, 16),
 
63
        ':o':         (":o",                     'icons/redface.png',       16, 16),
 
64
        ':(':         (":(",                     'icons/sad.png',           16, 16),
 
65
        ':)':         (":)",                     'icons/smile.png',         16, 16),
 
66
        'B)':         ("B)",                     'icons/smile2.png',        16, 16),
 
67
        ':))':        (":))",                    'icons/smile3.png',        16, 16),
 
68
        ';)':         (";)",                     'icons/smile4.png',        16, 16),
 
69
        '/!\\':       ("/!\\",                   'icons/alert.png',         16, 16),
 
70
        '<!>':        ("<!>",                    'icons/attention.png',     16, 16),
 
71
        '(!)':        ("(!)",                    'icons/idea.png',          16, 16),
 
72
        ':-?':        (":-?",                    'icons/tongue.png',        16, 16),
 
73
        ':\\':        (":\\",                    'icons/ohwell.png',        16, 16),
 
74
        '>:>':        (">:>",                    'icons/devil.png',         16, 16),
 
75
        '|)':         ("|)",                     'icons/tired.png',         16, 16),
 
76
        ':-(':        (":-(",                    'icons/sad.png',           16, 16),
 
77
        ':-)':        (":-)",                    'icons/smile.png',         16, 16),
 
78
        'B-)':        ("B-)",                    'icons/smile2.png',        16, 16),
 
79
        ':-))':       (":-))",                   'icons/smile3.png',        16, 16),
 
80
        ';-)':        (";-)",                    'icons/smile4.png',        16, 16),
 
81
        '|-)':        ("|-)",                    'icons/tired.png',         16, 16),
 
82
        '(./)':       ("(./)",                   'icons/checkmark.png',     16, 16),
 
83
        '{OK}':       ("{OK}",                   'icons/thumbs-up.png',     16, 16),
 
84
        '{X}':        ("{X}",                    'icons/icon-error.png',    16, 16),
 
85
        '{i}':        ("{i}",                    'icons/icon-info.png',     16, 16),
 
86
        '{1}':        ("{1}",                    'icons/prio1.png',         15, 13),
 
87
        '{2}':        ("{2}",                    'icons/prio2.png',         15, 13),
 
88
        '{3}':        ("{3}",                    'icons/prio3.png',         15, 13),
 
89
        '{*}':        ("{*}",                    'icons/star_on.png',       16, 16),
 
90
        '{o}':        ("{o}",                    'icons/star_off.png',      16, 16),
98
91
    }
99
92
    del _
 
93
    linkSchemas = ['http://', 'https://', 'ftp://', 'irc://', 'mailto:',]
100
94
 
101
95
# Public functions #####################################################
102
96
 
108
102
        @return: page header html
109
103
        """
110
104
        html = [
 
105
            
111
106
            # Pre header custom html
112
107
            self.emit_custom_html(self.cfg.page_header1),
113
 
            
114
 
            # Header
115
 
            u"""
116
 
    <div id="leftbanner">
117
 
    </div>
118
 
    <div id="rightbanner">
119
 
    </div>
120
 
    <div id="container">
121
 
        <div id="container-inner">
122
 
            <div id="header">
123
 
                <h1 id="ubuntu-header"><a href="http://www.ubuntu.com/">Ubuntu</a></h1>
124
 
                <ul id="main-menu">
125
 
                    <li><a href="http://www.ubuntu.com/desktop">Desktop</a></li>
126
 
                    <li><a href="http://www.ubuntu.com/netbook">Netbook</a></li>
127
 
                    <li><a href="http://www.ubuntu.com/server">Server</a></li>
128
 
                    <li><a href="http://www.ubuntu.com/cloud">Cloud</a></li>
129
 
                    <li><a href="http://www.ubuntu.com/support">Support</a></li>
130
 
                    <li><a href="http://www.ubuntu.com/project">Project</a></li>
131
 
                    <li class="active menuparent"><a href="http://www.ubuntu.com/community" class="active">Community</a></li>
132
 
                    <li><a href="http://www.ubuntu.com/partners">Partners</a></li>
133
 
                    <li><a href="http://shop.canonical.com/">Shop</a></li>
134
 
                </ul>
135
 
            </div>
136
 
            <div id="menu-search">
137
 
                <div id="subheader"> 
138
 
                    <div class="subheader-menu"> 
139
 
                        <div id="second-nav">""",
140
 
            self.username(d),
141
 
            """ </div> 
142
 
    <div id="user-info"> 
143
 
    </div>
144
 
 
145
 
 
146
 
                            
147
 
                        </div> 
148
 
                    </div> 
149
 
 
150
 
 
151
 
                    <div id="search-box">""",
 
108
            # Google Analytics
 
109
            u'''<script type="text/javascript">
 
110
                        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
 
111
                        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
 
112
                </script>
 
113
                <script type="text/javascript">
 
114
                        try {
 
115
                                var pageTracker = _gat._getTracker("UA-8147493-1");
 
116
                                pageTracker._trackPageview();
 
117
                        } catch(err) {}
 
118
                </script>''',
 
119
            # IE sucks if its version is less or equal to 6.0 
 
120
            u'''<!--[if lte IE 6]>
 
121
        <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="/htdocs/common/css/msie6.css"> 
 
122
        <div align="center" style="clear:both;">
 
123
          <font color="#fff">
 
124
            <b> La visualizzazione di questo sito &egrave; 
 
125
            ottimizzata per IE7 e Firefox
 
126
            </b>
 
127
          </font>
 
128
        </div>
 
129
      
 
130
      
 
131
      <![endif]-->''',
 
132
      
 
133
      # Header
 
134
      '''
 
135
      <div id="fixed-header">
 
136
        <!-- Header -->
 
137
        <div id="header" class="shadowed curved-bottom">
 
138
          <div class="container">
 
139
 
 
140
            <ul class="links">
 
141
                <li><a href="http://ubuntu-it.org" title="Homepage">Home</a></li>
 
142
                <li><a href="/scopri-ubuntu" title="Desktop">Scopri Ubuntu</a></li>
 
143
                <li class="active-trail"><a href="/supporto" title="Supporto">Supporto</a></li>
 
144
                <li><a href="/comunita" title="Comunit&agrave;">Comunit&agrave;</a></li>
 
145
                <li><a href="/progetto" title="Progetto">Progetto</a></li>
 
146
                <li><a href="/derivate" title="Derivate">Derivate</a></li>
 
147
                <li><a href="/contatti" title="Contatti">Contatti</a></li>
 
148
            </ul>            
 
149
 
 
150
        <div id="logo">  
 
151
            <a href="http://ubuntu-it.org" title="Ubuntu Italia"></a>
 
152
        </div>            
 
153
                
 
154
            <div class="buttons">
 
155
              <div id="accessibility" title="Maggiore focus ai contenuti" onclick='accessibility_toggle();'></div>
 
156
            </div>
 
157
            <div id="ubuntu-it-sites">
 
158
                <a id="" href="http://wiki.ubuntu-it.org">documentazione</a>
 
159
                <a id="" href="http://forum.ubuntu-it.org">forum</a>
 
160
                <a id="" href="http://planet.ubuntu-it.org">planet</a>
 
161
            </div>
 
162
 
 
163
          </div>
 
164
        </div>
 
165
        <!-- Sub Header -->
 
166
          <div id="subheader">
 
167
            <div class="container">
 
168
              <div class="container-inside">
 
169
                  <ul class="links secondary-links">
 
170
                        <li class="active"><a href="http://wiki.ubuntu-it.org" title="Documentazione">Documentazione</a></li>
 
171
                        <li><a href="http://forum.ubuntu-it.org" title="Forum di supporto">Forum</a></li>
 
172
                        <li><a href="/supporto/screencast" title="Screencast" class="active">Screencast</a></li>
 
173
                        </ul>                                                
 
174
              </div>
 
175
            </div>
 
176
          </div>
 
177
            </div>    
 
178
    <!-- Content -->
 
179
    <div id="content">
 
180
      <div id="content-top"> </div>
 
181
      <div class="container">
 
182
      <div>
 
183
      ''',            
 
184
            self.msg(d),
 
185
            #Search
 
186
            u'<div id="search">',
152
187
            self.searchform(d),
153
 
            """
154
 
                    </div>
155
 
                </div>
156
 
                <div id="title"><h1>""",
157
 
                self.breadcrumb(d),
158
 
            u"""</h1>
159
 
                </div>
160
 
            <div id="cwt-nav3">""",
161
 
            self.editbar(d),
162
 
            """ <hr class="clear" />
163
 
            </div>
164
 
                <div id="cwt-content" class="clearfix content-area">""",
165
 
                self.msg(d),
166
 
            
 
188
            u'</div>',
 
189
            # Post header custom html (not recommended)
 
190
            self.emit_custom_html(self.cfg.page_header2),
167
191
            # Start of page
168
192
            self.startPage(),
169
 
            #self.title(d),
 
193
            self.title(d),
 
194
            u'<div id="edit-extra">',
 
195
            self.editbar(d),
 
196
            self.extranav(d),
 
197
            u'</div>',
 
198
 
 
199
 
170
200
        ]
171
201
        return u'\n'.join(html)
172
202
 
173
203
    editorheader = header
 
204
 
 
205
    # Added by Milo for testing purposes
 
206
 
 
207
    def pageLastName(self, name):
 
208
        """ This should be in the Page class, but its not """
 
209
        return name[name.rfind('/') + 1:]
 
210
 
 
211
    def shortenPagename(self, name):
 
212
        """ Shorten page names
174
213
        
175
 
    def breadcrumb(self, d):
176
 
        """ Build the breadcrumb
177
 
 
178
 
        @param d: parameter dectionary
179
 
        @return: breacrumb html
 
214
        This is a modified copy from theme/__init__.py. Modified to
 
215
        show only the last name of a page, even if there is room for
 
216
        the full name.
180
217
        """
181
 
        page_path = d['page'].split_title(self.request).split('/')
182
 
        page_path[0:0] = [self.request.cfg.sitename]
183
 
        if len(page_path) == 1:
184
 
            page_path[1] = u'' 
185
 
            # I don't think this should be needed but it's here
186
 
            # in case moin has some secret pages w/ no name
187
 
        # there's a diff between these two
188
 
        #  d['page'].split_title():
189
 
        #  wikiutil.escape(d['title_text']))
190
 
        return u'%s <span>%s</span>' % (page_path[-2], page_path[-1])
 
218
        name = self.pageLastName(name)
 
219
        maxLength = self.maxPagenameLength()
 
220
        if len(name) > maxLength:
 
221
            half, left = divmod(maxLength - 3, 2)
 
222
            name = u'%s...%s' % (name[:half + left], name[-half:])
 
223
        return name
 
224
 
 
225
    # End of added section
191
226
 
192
227
    def footer(self, d, **keywords):
193
228
        """ Assemble wiki footer
199
234
        """
200
235
        page = d['page']
201
236
        html = [
 
237
            
 
238
            # End #content .container
 
239
            u'</div></div></div>',
 
240
            u'<div id="content-bottom"></div>',
 
241
            # End #content
 
242
            u'</div>'
202
243
            # End of page
 
244
            #self.pageinfo(page),
 
245
 
 
246
            u'<div id="footer">',
 
247
            u'<div class="container">',
 
248
            # Footer
 
249
            self.footerlinks(), 
 
250
            self.showversion(d, **keywords),
 
251
 
203
252
            self.endPage(),
204
253
            
205
 
            
206
 
            # Footer
207
 
            u"""
208
 
            </div>""",
209
 
            self.pageinfo(page),
210
 
            """</div>
211
 
            
212
 
            <div id="footer" class="clearfix">
213
 
                <div class="footer-div">
214
 
                    <p class="footer-title">Desktop</p>
215
 
                    <ul>
216
 
                        <li><a href="http://www.ubuntu.com/desktop/features">Features</a></li>
217
 
                        <li><a href="http://www.ubuntu.com/desktop/get-ubuntu">Get Ubuntu Desktop Edition</a></li>
218
 
                        <li><a href="http://www.ubuntu.com/desktop/services">Services</a></li>
219
 
                    </ul>
220
 
                </div>
221
 
                <div class="footer-div">
222
 
                    <p class="footer-title">Netbook</p>
223
 
                    <ul>
224
 
                        <li><a href="http://www.ubuntu.com/netbook/features">Features</a></li>
225
 
                        <li><a href="http://www.ubuntu.com/netbook/get-ubuntu">Get Ubuntu Netbook Edition</a></li>
226
 
                    </ul>
227
 
                </div>
228
 
                <div class="footer-div">
229
 
                    <p class="footer-title">Server</p>
230
 
                    <ul>
231
 
                        <li><a href="http://www.ubuntu.com/server/features">Features</a></li>
232
 
                        <li><a href="http://www.ubuntu.com/server/get-ubuntu">Get Ubuntu Server Edition</a></li>
233
 
                        <li><a href="http://www.ubuntu.com/server/services">Services</a></li>
234
 
                        <li><a href="http://www.ubuntu.com/server/technical-resources">Technical resources</a></li>
235
 
                    </ul>
236
 
                </div>
237
 
                <div class="footer-div">
238
 
                    <p class="footer-title">Cloud</p>
239
 
                    <ul>
240
 
                        <li><a href="http://www.ubuntu.com/cloud/why-ubuntu">Why Ubuntu?</a></li>
241
 
                        <li><a href="http://www.ubuntu.com/cloud/private">Private cloud</a></li>
242
 
                        <li><a href="http://www.ubuntu.com/cloud/public">Public cloud</a></li>
243
 
                        <li><a href="http://www.ubuntu.com/cloud/services">Services</a></li>
244
 
                    </ul>
245
 
                </div>
246
 
                <div class="footer-div">
247
 
                    <p class="footer-title">Support</p>
248
 
                    <ul>
249
 
                        <li><a href="http://www.ubuntu.com/support/community">Community</a></li>
250
 
                        <li><a href="http://www.ubuntu.com/support/training">Training</a></li>
251
 
                        <li><a href="http://www.ubuntu.com/support/services">Services</a></li>
252
 
                        <li><a href="http://www.ubuntu.com/usn">Security notices</a></li>
253
 
                    </ul>
254
 
                </div>
255
 
                <div class="footer-div">
256
 
                    <p class="footer-title">Project</p>
257
 
                    <ul>
258
 
                        <li><a href="http://www.ubuntu.com/project/about-ubuntu">About Ubuntu</a></li>
259
 
                        <li><a href="http://www.ubuntu.com/project/canonical-and-ubuntu">Canonical and Ubuntu</a></li>
260
 
                        <li><a href="http://www.ubuntu.com/project/open-source">Open source</a></li>
261
 
                        <li><a href="http://www.ubuntu.com/project/case-studies">Case studies</a></li>
262
 
                        <li><a href="http://www.ubuntu.com/project/derivatives">Derivatives</a></li>
263
 
                    </ul>
264
 
                </div>
265
 
                <div class="footer-div">
266
 
                    <p class="footer-title">Community</p>
267
 
                    <ul>
268
 
                        <li><a href="http://www.ubuntu.com/community/conduct">Code of conduct</a></li>
269
 
                        <li><a href="http://www.ubuntu.com/community/get-involved">Get involved</a></li>
270
 
                        <li><a href="http://www.ubuntu.com/community/report-problem">Report a problem</a></li>
271
 
                        <li><a href="http://www.ubuntu.com/community/ubuntu-and-debian">Ubuntu and Debian</a></li>
272
 
                    </ul>
273
 
                </div>
274
 
                <div class="footer-div">
275
 
                    <p class="footer-title">Partners</p>
276
 
                    <ul>
277
 
                        <li><a href="http://www.ubuntu.com/partners/programme">Partner programme</a></li>
278
 
                        <li><a href="http://partners.canonical.com/">Find a partner</a></li>
279
 
                        <li><a href="https://certification.canonical.com/">Certified Hardware</a></li>
280
 
                    </ul>
281
 
                </div>
282
 
                <div class="footer-div">
283
 
                    <p class="footer-title">Further Information</p>
284
 
                    <ul>
285
 
                        <li><a href="http://www.ubuntu.com/contact-us">Contact us</a></li>
286
 
                        <li><a href="http://www.ubuntu.com/trademarkpolicy">Trademark policy</a></li>
287
 
                        <li><a href="http://www.ubuntu.com/legal">Legal information</a></li>
288
 
                        <li><a href="http://www.canonical.com/about-canonical/careers">Careers</a></li>
289
 
                        <li><a href="http://www.ubuntu.com/rss.xml" class="newsfeed">Canonical news feed</a></li>
290
 
                    </ul>
291
 
                </div>
292
 
            </div>
293
 
            <div id="copyright">
294
 
                <p>&copy; 2010 Canonical Ltd. Ubuntu and Canonical are registered trademarks of Canonical Ltd.
295
 
                <a href="http://www.ubuntu.com/"><img src="/assets/light/images/footer_logo.png" alt="Ubuntu" /></a></p>
296
 
            </div>
297
 
        </div>"""
298
 
        ]
 
254
            # Pre footer custom html (not recommended!)
 
255
            self.emit_custom_html(self.cfg.page_footer1),
 
256
 
 
257
 
 
258
            # Post footer custom html
 
259
            self.emit_custom_html(self.cfg.page_footer2),
 
260
            u'</div></div>',
 
261
            u'</body></html>',
 
262
 
 
263
            ]
299
264
        return u'\n'.join(html)
300
265
 
301
266
    def extranav(self, d):
302
267
        """ Assemble the helpful extra navigation
303
268
 
304
 
    Of course in a normal theme these come from wikiconfig.py 
 
269
        Of course in a normal theme these come from wikiconfig.py 
305
270
        
306
271
        @param d: parameter dictionary
307
272
        @rtype: unicode
309
274
        """
310
275
        request = self.request
311
276
        _ = request.getText
312
 
        changesPage = wikiutil.getSysPage(request, 'RecentChanges')
313
 
        #changesPage = wikiutil.getLocalizedPage(request, 'UserPreferences')
314
 
        findPage = wikiutil.getSysPage(request, 'FindPage')
315
 
        #findPage = wikiutil.getLocalizedPage(request, 'FindPage')
316
 
        
 
277
        #preferencesPage = wikiutil.getLocalizedPage(request, 'UserPreferences')
 
278
        changesPage = wikiutil.getLocalizedPage(request, 'RecentChanges')
 
279
        indexPage = wikiutil.getLocalizedPage(request, 'Documentazione/Indice')
 
280
 
317
281
        extralinks = []
318
 
        # Set page to localized RC page
319
 
        title = changesPage.split_title(request)
320
 
        extralinks.append(changesPage.link_to(request, text=title))
321
 
        # Set page to localized find page
322
 
        title = findPage.split_title(request)
323
 
        extralinks.append(findPage.link_to(request, text=title))
324
 
            
 
282
 
 
283
        # If user is logged in, give them the Preferences link, if not, don't.
 
284
        if request.user.valid and request.user.name:
 
285
            # Set the Logut action
 
286
            extralinks.append(d['page'].link_to(request, text=_('Esci', formatted=False),
 
287
                    querystr={'action': 'logout', 'logout': 'logout'}, id="logout"))
 
288
            # Set pref page to localized Preferences page
 
289
            #title = preferencesPage.split_title(request)
 
290
            #extralinks.append(preferencesPage.link_to(request, text=title))
 
291
            userprefs = _("PreferenzeUtente")
 
292
            extralinks.append("""<a href="?action=userprefs">%s</a>""" % userprefs)
 
293
            # Set page to localized RC page
 
294
            title = changesPage.split_title(request)
 
295
            extralinks.append(changesPage.link_to(request, text=title))
 
296
            # Set user's personal page
 
297
            interwiki = wikiutil.getInterwikiHomePage(request)
 
298
            name = request.user.name
 
299
            aliasName = request.user.aliasname
 
300
            if not aliasName:
 
301
                aliasName = name
 
302
            title = "%s @ %s" % (aliasName, interwiki[0])
 
303
            homelink = (request.formatter.interwikilink(1, title=title, id="userhome", *interwiki) +
 
304
                        request.formatter.text(name) +
 
305
                        request.formatter.interwikilink(0, title=title, id="userhome", *interwiki)
 
306
                        )
 
307
            extralinks.append(homelink)
 
308
        else:
 
309
            pass
 
310
 
 
311
        # Set the index link
 
312
        extralinks.append(indexPage.link_to(request, text='Indice'))
 
313
 
325
314
        extralinks = [u'<li>%s</li>\n' % link for link in extralinks]
326
315
        html = u'<ul class="extranav">\n%s</ul>' % ''.join(extralinks)
327
316
        return html
328
317
 
329
 
    def navibar(self, d):
330
 
        """ Assemble the navibar
331
 
 
332
 
        @param d: parameter dictionary
333
 
        @rtype: unicode
334
 
        @return: navibar html
335
 
        """
336
 
        request = self.request
337
 
        found = {} # pages we found. prevent duplicates
338
 
        items = [] # navibar items
339
 
        item = u'<li class="%s">%s</li>'
340
 
        current = d['page_name']
341
 
 
342
 
        # Add user links to wiki links, eliminating duplicates.
343
 
        userlinks = request.user.getQuickLinks()
344
 
        for text in userlinks:
345
 
            # Split text without localization, user know what she wants
346
 
            pagename, link = self.splitNavilink(text, localize=0)
347
 
            if not pagename in found:
348
 
                cls = 'userlink'
349
 
                if pagename == current:
350
 
                    cls = 'userlink current'
351
 
                items.append(item % (cls, link))
352
 
                found[pagename] = 1
353
 
 
354
 
        # Assemble html
355
 
        items = u'\n'.join(items)
356
 
        html = u'''
357
 
<ul id="navibar">
358
 
%s
359
 
</ul>
360
 
''' % items
361
 
        return html
362
 
 
363
 
    def username(self, d):
364
 
        """ Assemble the username / userprefs link
365
 
        
366
 
        @param d: parameter dictionary
367
 
        @rtype: unicode
368
 
        @return: username html
369
 
        """
370
 
        request = self.request
371
 
        _ = request.getText
372
 
        
373
 
        preferencesPage = wikiutil.getSysPage(request, 'UserPreferences')
374
 
        #preferencesPage = wikiutil.getLocalizedPage(request, 'UserPreferences')
375
 
 
376
 
        helpPage = wikiutil.getSysPage(request, 'HelpContents')
377
 
        #helpPage = wikiutil.getLocalizedPage(request, 'HelpContents')
378
 
        
379
 
        userlinks = []
380
 
        # Add username/homepage link for registered users. We don't care
381
 
        # if it exists, the user can create it.
382
 
        if request.user.valid:
383
 
            homepage = Page(request, self.request.cfg.page_front_page)
384
 
            homepage_link = homepage.link_to(request, text=self.request.cfg.sitename)
385
 
            userlinks.append(homepage_link)
386
 
            userpage = Page(request, request.user.name)
387
 
            title = userpage.split_title(request)
388
 
            homelink = preferencesPage.link_to(request, text=title)
389
 
            userlinks.append(homelink)
390
 
            # logout link
391
 
            logout = _("Logout")
392
 
            userlinks.append("""<a href="?action=logout&logout=logout">%s</a>""" % logout)
 
318
 
 
319
    def editbar(self, d):
 
320
        """ Assemble the page edit bar.
 
321
 
 
322
        Display on existing page. Replace iconbar, showtext, edit text,
 
323
        refresh cache and available actions.
 
324
        
 
325
        @param d: parameter dictionary
 
326
        @rtype: unicode
 
327
        @return: iconbar html
 
328
        """
 
329
        page = d['page']       
 
330
        if not self.shouldShowEditbar(page):
 
331
            return ''
 
332
 
 
333
        # Use cached editbar if possible.
 
334
        cacheKey = 'editbar'
 
335
        cached = self._cache.get(cacheKey)
 
336
        if cached:
 
337
            return cached
 
338
 
 
339
        # Make new edit bar
 
340
        request = self.request
 
341
        _ = self.request.getText
 
342
        link = wikiutil.link_tag
 
343
        quotedname = wikiutil.quoteWikinameURL(page.page_name)
 
344
        links = []
 
345
        add = links.append
 
346
 
 
347
        #cercaPagina = wikiutil.getLocalizedPage(request, 'CercaPagina')
 
348
        #title = cercaPagina.split_title(request)
 
349
        #add(cercaPagina.link_to(request, text=title))
 
350
        
 
351
        # Parent page
 
352
        #parent = page.getParentPage()
 
353
        #if parent:
 
354
        #   add(parent.link_to(request, _("Pagina superiore", formatted=False))) 
 
355
       
 
356
        # Page actions
 
357
        if page.isWritable() and request.user.valid and request.user.may.write(page.page_name):
 
358
            #add(link(request, quotedname + '?action=edit', _('Edit')))
 
359
            #add(link(request, quotedname + '?action=info',
 
360
            #     _('Cronologia', formatted=False)))
 
361
            add(self.editorLink(page))
 
362
            add(d['page'].link_to(request, text=_('Allegati', formatted=False), querystr={'action':'AttachFile'}))
 
363
            add(self.infoLink(page))
 
364
            add(self.subscribeLink(page))
 
365
            add(self.actionsMenu(page))
 
366
        elif not request.user.valid:
 
367
                   add(d['page'].link_to(request, text=_("Login per modificare", 
 
368
               formatted=False), querystr={'action': 'login'}, id="login"))
393
369
        else:
394
 
            homepage = Page(request, self.request.cfg.page_front_page)
395
 
            homepage_link = homepage.link_to(request, text=self.request.cfg.sitename)
396
 
            userlinks.append(homepage_link)
397
 
            # Add prefpage links with title: Login
398
 
            login = _("Login")
399
 
            userlinks.append("""<a href="?action=login">%s</a>""" % login)
400
 
        userlinks.append(helpPage.link_to(request, text=_("Help")))
401
 
        userlinks = [u'<li>%s</li>\n' % link for link in userlinks]
402
 
        html = u'<ul id="username">\n%s</ul>' % ''.join(userlinks)
 
370
            add(_('Pagina non modificabile', formatted=False))             
 
371
 
 
372
        # Format
 
373
        items = '\n'.join(['<li>%s</li>' % item for item in links if item != ''])
 
374
        html = u'<ul class="editbar">\n%s\n</ul>\n' % items
 
375
        
 
376
        # cache for next call
 
377
        self._cache[cacheKey] = html
403
378
        return html
404
379
 
405
380
    def footerlinks(self):
411
386
        @return: extra footer html
412
387
        """
413
388
 
414
 
        html = u'''
415
 
  <div id="ubuntulinks">
416
 
     &copy; 2008 <a href="http://www.canonical.com">Canonical Ltd</a>. Ubuntu, Kubuntu, Edubuntu, Xubuntu and Canonical are registered trademarks of Canonical Ltd.<br />
417
 
     <a href="http://www.ubuntu.com/about-us">Feedback</a> &mdash; 
418
 
     <a href="http://www.ubuntu.com/legal">Legal</a> &mdash; 
419
 
     <a href="https://wiki.ubuntu.com/wiki/credits">Credits</a> &mdash; 
420
 
     <a href="http://www.ubuntu.com/sitemap">Site Map</a> &mdash;
421
 
     <a href="http://moinmoin.wikiwikiweb.de/">Powered By the MoinMoin Wiki Engine</a>
422
 
  </div>
423
 
<script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
424
 
</script>
425
 
<script type="text/javascript">
426
 
_uacct = "UA-1018242-7";
427
 
urchinTracker();
428
 
__utmSetVar('UbuntuWiki');
429
 
</script>
430
 
%s
431
 
''' % self.breadcrumb(d)
 
389
        html = u'''<div id="ubuntulinks">&copy; 2005 - %s <a href="http://www.canonical.com">Canonical Ltd.</a> Ubuntu e Canonical sono marchi registrati da Canonical Ltd.<br />
 
390
        <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.it"><img alt="Licenza Creative Commons" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/2.5/it/80x15.png" /></a>&nbsp;Questa <span xmlns:dc="http://purl.org/dc/elements/1.1/" href="http://purl.org/dc/dcmitype/Text" rel="dc:type">opera</span> &egrave; pubblicata sotto una <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/legalcode">licenza Creative Commons</a><br><br>
 
391
        </div>''' % date.today().year
 
392
        
432
393
        return html
433
394
        return u''
434
 
 
435
 
        
436
 
def execute(request):
437
 
    """
438
 
    Generate and return a theme object
439
 
        
440
 
    @param request: the request object
441
 
    @rtype: MoinTheme
442
 
    @return: Theme object
443
 
    """
444
 
    return Theme(request)
445