Exemplo n.º 1
0
    def __init__(self, request):
        ThemeParent.__init__(self, request)
        sheetsnames = ['stylesheets', 'stylesheets_print', 'stylesheets_projection']

        # include css and icon files from this theme when in inherited theme
        if self.name is not NAME:
            for sheetsname in sheetsnames:
                theme_sheets = getattr(self, sheetsname)
                parent_sheets = []
                for sheet in theme_sheets:
                    link = (sheet[0], THEME_PATH + "/css/" + sheet[1])
                    parent_sheets.append(link)

                # remove css files that are not defined in css_files of the inherited theme
                theme_sheets = [sheet for sheet in theme_sheets if sheet[1] in self.css_files]
                setattr(self, sheetsname, tuple(parent_sheets + theme_sheets))

            for key, val in self.icons.items():
                val = list(val)
                val[1] = THEME_PATH + "/img/" + val[1]
                self.icons[key] = tuple(val)

        # bootstrap css file should be before themes
        for sheet in reversed(BOOTSTRAP_THEME_CSS):
            link = (sheet[0], "../../bootstrap/css/" + sheet[1])
            self.stylesheets = (link,) + self.stylesheets

        actions = get_available_actions(request.cfg,
                                        request.page,
                                        request.user)

        excluded = self.EXCLUDED_ACTIONS + getattr(request.cfg, 'actions_excluded', [])
        included = getattr(request.cfg, 'actions_included', [])
        self.available_actions = [action for action in actions
                                  if action in included or action not in excluded]
Exemplo n.º 2
0
    def send_closing_html(self):
        if not self.is_mobile:
            return ThemeBase.send_closing_html(self)

        request = self.request
        d = request.themedict
        if d['editor_mode']:
            request.write('''
<script>
document.getElementById('editor-help').style.display = "none";
(function() {
    // auto grow text area
    var textarea = document.getElementById('editor-textarea'),
        timer;
    textarea.onfocus = function() {
        timer = setInterval(function() {
            var scrollHeight = textarea.scrollHeight,
                clientHeight = textarea.clientHeight;
            if(clientHeight < scrollHeight) {
                textarea.style.height = scrollHeight + 50 + 'px';
            }
        }, 100);
    };
    textarea.onblur = function() {
        clearInterval(timer);
    };
})();
</script>
''')
        request.write('</body>\n</html>\n\n')
Exemplo n.º 3
0
    def send_footer(self, pagename, **keywords):
        if not self.is_mobile:
            return ThemeBase.send_footer(self, pagename, **keywords)

        request = self.request
        d = request.themedict
        request.write(self.footer(d, **keywords))
Exemplo n.º 4
0
    def logo(self):
        mylogo = ThemeParent.logo(self)
        if not mylogo:
            mylogo = u'''<span>%s</span>''' % \
                     wikiutil.escape(self.cfg.sitename, True)

        return mylogo
Exemplo n.º 5
0
    def send_title(self, text, **keywords):
        if 'editor_mode' in keywords:
            if 'body_attr' in keywords:
                keywords['body_attr'] += 'id="page-editor"'
            else:
                keywords['body_attr'] = 'id="page-editor"'

        return _Theme.send_title(self, text, **keywords)
Exemplo n.º 6
0
    def username(self, d):
        """ Assemble the username / userprefs link

        @param d: parameter dictionary
        @rtype: unicode
        @return: username html
        """

        if not self.is_mobile:
            return ThemeBase.username(self, d)

        request = self.request
        _ = request.getText

        if self.request.cfg.show_interwiki:
            page = wikiutil.getFrontPage(self.request)
            text = self.request.cfg.interwikiname or 'Self'
            link = page.link_to(self.request, text=text, rel='nofollow')
            # html = u'<span id="interwiki">%s<span class="sep">: </span></span>' % link
            userlinks = [link]
        else:
            userlinks = []

        # Add username/homepage link for registered users. We don't care
        # if it exists, the user can create it.
        if request.user.valid and request.user.name:
            interwiki = wikiutil.getInterwikiHomePage(request)
            name = request.user.name
            aliasname = request.user.aliasname
            if not aliasname:
                aliasname = name
            title = "%s @ %s" % (aliasname, interwiki[0])
            # link to (interwiki) user homepage
            homelink = (request.formatter.interwikilink(1, title=title, id="userhome", generated=True, *interwiki) +
                        request.formatter.text(name) +
                        request.formatter.interwikilink(0, title=title, id="userhome", *interwiki))
            userlinks.append(homelink)
            # link to userprefs action
            if 'userprefs' not in self.request.cfg.actions_excluded:
                userlinks.append(d['page'].link_to(request, text=_('Settings'),
                                               querystr={'action': 'userprefs'}, id='userprefs', rel='nofollow'))

        if request.user.valid:
            if request.user.auth_method in request.cfg.auth_can_logout:
                userlinks.append(d['page'].link_to(request, text=_('Logout'),
                                                   querystr={'action': 'logout', 'logout': 'logout'}, id='logout', rel='nofollow'))
        else:
            query = {'action': 'login'}
            # special direct-login link if the auth methods want no input
            if request.cfg.auth_login_inputs == ['special_no_input']:
                query['login'] = '******'
            if request.cfg.auth_have_login:
                userlinks.append(d['page'].link_to(request, text=_("Login"),
                                                   querystr=query, id='login', rel='nofollow'))

        userlinks_html = u'<span class="sep"> | </span>'.join(userlinks)
        html = u'<div id="username">%s</div>' % userlinks_html
        return html
Exemplo n.º 7
0
    def username(self, d):
        html = _Theme.username(self, d)
        first_tag = html.index('>') + 1

        page = wikiutil.getFrontPage(self.request)

        return u'{} {} <span class="sep"> | </span> {}'.format(
            html[:first_tag], page.link_to_raw(self.request, "Home"),
            html[first_tag:])
Exemplo n.º 8
0
    def editorheader(self, d, **kw):
        if not self.is_mobile:
            return ThemeBase.editorheader(self, d, **kw)

        html = [
            u'<div id="header">',
            u'<h1 id="locationline">',
            self.title_with_separators(d),
            u'</h1>',
            self.msg(d),
            u'</div>',
        ]
        return u'\n'.join(html)
Exemplo n.º 9
0
    def footer(self, d, **keywords):
        if not self.is_mobile:
            return ThemeBase.footer(self, d, **keywords)

        page = d['page']
        html = [
            self.pageinfo(page),
            self.endPage(),
            # u'<div id="footer">',
            #self.credits(d),
            # self.showversion(d, **keywords),
            # u'</div>',
            ]
        return u'\n'.join(html)
Exemplo n.º 10
0
    def recentchanges_entry(self, d):
        """
        Assemble a single recentchanges entry (table row)

        @param d: parameter dictionary
        @rtype: string
        @return: recentchanges entry html
        """
        if not self.is_mobile:
            return ThemeBase.recentchanges_entry(self, d)

        _ = self.request.getText
        html = []
        html.append('<tr>\n')

        # html.append('<td class="rcicon1">%(icon_html)s</td>\n' % d)

        html.append('<td class="rcpagelink" colspan="1">%(icon_html)s %(pagelink_html)s\n<small><i>' % d)
        if d['time_html']:
            html.append("%(time_html)s\n" % d)

        # html.append('<td class="rcicon2">%(info_html)s</td>\n' % d)

        if d['editors']:
            html.append('<div style="float:right;">')
            html.append(','.join(d['editors']))
            html.append('</div>')
        html.append('<i></small></td>\n')

        # html.append('<td class="rccomment">')
        # if d['comments']:
        #     if d['changecount'] > 1:
        #         notfirst = 0
        #         for comment in d['comments']:
        #             html.append('%s<tt>#%02d</tt>&nbsp;%s' % (
        #                 notfirst and '<br>' or '', comment[0], comment[1]))
        #             notfirst = 1
        #     else:
        #         comment = d['comments'][0]
        #         html.append('%s' % comment[1])
        # html.append('</td>\n')

        html.append('</tr>\n')

        return ''.join(html)
Exemplo n.º 11
0
 def universal_edit_button(self, d, **k):
     return u'\n'.join([
         ('<meta name="viewport" content="width=device-width, '
          'initial-scale=1" />'),
         ('<link rel="shortcut icon" href="/WikiStatic?'
          'action=AttachFile&do=get&target=favicon.ico">'),
         ('<link rel="apple-touch-icon-precomposed" href="/WikiStatic?'
          'action=AttachFile&do=get&target=iphone-icon.png"/>'),
         ('<link rel="stylesheet" type="text/css" charset="utf-8" '
          'media="all" href="/WikiStatic?'
          'action=AttachFile&do=get&target=mcrute.css">'),
         ('<script type="text/javascript" src="/WikiStatic?'
          'action=AttachFile&do=get&target=dnd-upload.js">'
          '</script>'),
         ('<script type="text/javascript" src="/WikiStatic?'
          'action=AttachFile&do=get&target=features.js">'
          '</script>'),
     ]) + _Theme.universal_edit_button(self, d, **k)
Exemplo n.º 12
0
    def recentchanges_daybreak(self, d):
        """
        Assemble a rc daybreak indication (table row)

        @param d: parameter dictionary
        @rtype: string
        @return: recentchanges daybreak html
        """
        if not self.is_mobile:
            return ThemeBase.recentchanges_daybreak(self, d)

        if d['bookmark_link_html']:
            set_bm = '&nbsp; %(bookmark_link_html)s' % d
        else:
            set_bm = ''
        return ('<tr class="rcdaybreak"><td colspan="%d">'
                '<strong>%s</strong>'
                '%s'
                '</td></tr>\n') % (1, d['date'], set_bm)
Exemplo n.º 13
0
    def editbarItems(self, page):
        actions = _Theme.editbarItems(self, page)

        # Add quick link actions for starting/stopping activities
        if page.pi['format'] == 'timecsv':
            actions.insert(
                len(actions) - 1,
                page.link_to(self.request,
                             text='Start Activity',
                             querystr={'action': 'StartActivity'},
                             rel='nofollow'))

            actions.insert(
                len(actions) - 1,
                page.link_to(self.request,
                             text='Stop Activity',
                             querystr={'action': 'StopActivity'},
                             rel='nofollow'))

        return actions
Exemplo n.º 14
0
    def header(self, d, **kw):
        if not self.is_mobile:
            return ThemeBase.header(self, d, **kw)

        html = [
            u'<div id="header">',
            self.logo(),
            self.username(d),
            u'<h1 id="locationline">',
            self.title_with_separators(d),
            u'</h1>',
            self.navibar(d),
            u'<div id="pageline"><hr style="display:none;"></div>',
            self.msg(d),
            self.editbar(d),
            u'</div>',
            # Start of page
            self.startPage(),
        ]
        return u'\n'.join(html)
Exemplo n.º 15
0
    def send_title(self, text, **keywords):
        if not self.is_mobile:
            return ThemeBase.send_title(self, text, **keywords)

        request = self.request

        if keywords.has_key('page'):
            page = keywords['page']
            pagename = page.page_name
        else:
            pagename = keywords.get('pagename', '')
            page = Page(request, pagename)

        request.content_type = "text/html; charset=%s" % (config.charset, )

        user_head = []
        user_head.append('''<meta http-equiv="Content-Type" content="%s;charset=%s">\n''' % (page.output_mimetype, page.output_charset))
        user_head.append('<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=yes"/>')

        output = []
        output.append("""\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
%s
%s
%s
<style tyle='text/css'>
img.external_image {
    max-width: 100%%;
}
img.attachment {
    max-width: 100%%;
}
</style>
""" % (
            ''.join(user_head),
            self.html_head({
                'page': page,
                'title': text,
                'sitename': request.cfg.html_pagetitle or request.cfg.sitename,
                'print_mode': keywords.get('print_mode', False),
                'media': keywords.get('media', 'screen'),
            }),
            keywords.get('html_head', ''),
        ))
        output.append("</head>\n")

        bodyattr = []
        output.append('\n<body%s>\n' % ''.join(bodyattr))

        d = {
            'theme': self.name,
            'title_text': text,
            'page': page,
            'page_name': pagename or '',
            'user_name': request.user.name,
            'user_valid': request.user.valid,
            'msg': self._status,
            'editor_mode': keywords.get('editor_mode', 0),
        }
        request.themedict = d
        if keywords.get('editor_mode', 0):
            output.append(self.editorheader(d))
        else:
            output.append(self.header(d))

        request.write(''.join(output))
        self._send_title_called = True
Exemplo n.º 16
0
    def __init__(self, request):
        ThemeBase.__init__(self, request)

        import re
        self.is_mobile = re.search(r"android.+mobile|iphone|ipod", request.http_user_agent, re.I|re.M) is not None
Exemplo n.º 17
0
    def guiworks(self, page):
        if not self.is_mobile:
            return ThemeBase.guiworks(self, page)

        return False