コード例 #1
0
    def inline_nowiki_repl(self,
                           stack,
                           nowiki,
                           nowiki_text=None,
                           nowiki_text_pre=None,
                           pre_args='',
                           nowiki_text_code=None,
                           nowiki_text_tt=None):
        text = None

        if nowiki_text is not None:
            text = nowiki_text
            stack.top_append(moin_page.code(children=[text]))
        elif nowiki_text_code is not None:
            text = nowiki_text_code
            stack.top_append(moin_page.code(children=[text]))
        elif nowiki_text_tt is not None:
            text = nowiki_text_tt
            stack.top_append(moin_page.code(children=[text]))
        # Remove empty backtick nowiki samples
        elif nowiki_text_pre:
            # TODO: pre_args parsing
            text = nowiki_text_pre
            stack.top_append(moin_page.blockcode(children=[text]))
        else:
            return
コード例 #2
0
ファイル: mediawiki_in.py プロジェクト: pombredanne/moin2
    def inline_nowiki_repl(
        self,
        stack,
        nowiki,
        nowiki_text=None,
        nowiki_text_pre=None,
        pre_args="",
        nowiki_text_code=None,
        nowiki_text_tt=None,
    ):
        text = None

        if nowiki_text is not None:
            text = nowiki_text
            stack.top_append(moin_page.code(children=[text]))
        elif nowiki_text_code is not None:
            text = nowiki_text_code
            stack.top_append(moin_page.code(children=[text]))
        elif nowiki_text_tt is not None:
            text = nowiki_text_tt
            stack.top_append(moin_page.code(children=[text]))
        # Remove empty backtick nowiki samples
        elif nowiki_text_pre:
            # TODO: pre_args parsing
            text = nowiki_text_pre
            stack.top_append(moin_page.blockcode(children=[text]))
        else:
            return
コード例 #3
0
 def inline_nowiki_repl(self, stack, nowiki, nowiki_text=None, nowiki_text_backtick=None):
     text = None
     if nowiki_text is not None:
         return stack.top_append(moin_page.samp(children=[nowiki_text]))
     # we must pass empty strings for moinwiki in > out conversions (@``DATE@ must not be converted to @DATE@)
     elif nowiki_text_backtick is not None:
         return stack.top_append(moin_page.code(children=[nowiki_text_backtick]))
コード例 #4
0
    def macro(self, content, arguments, page_url, alternative):
        # TODO new arg parsing is not compatible, splits at blanks
        try:
            email = arguments[0]
        except IndexError:
            raise ValueError("You need to give an (obfuscated) email address")

        try:
            text = arguments[1]
        except IndexError:
            text = u''

        from MoinMoin.mail.sendmail import decodeSpamSafeEmail

        if flaskg.user.valid:
            # decode address and generate mailto: link
            email = decodeSpamSafeEmail(email)
            result = moin_page.a(attrib={xlink.href: u'mailto:{0}'.format(email)}, children=[text or email])
        else:
            # unknown user, maybe even a spambot, so just return text as given in macro args
            if text:
                text += " "
            result = moin_page.code(children=[text, "<{0}>".format(email)])

        return result
コード例 #5
0
    def macro(self):
        request = self.request

        groups = []
        for groupname in defaultconfig.options:
            groups.append((groupname, True, defaultconfig.options))
        for groupname in defaultconfig.options_no_group_name:
            groups.append(
                (groupname, False, defaultconfig.options_no_group_name))
        groups.sort()

        result = moin_page.div()

        for groupname, addgroup, optsdict in groups:
            heading, desc, opts = optsdict[groupname]
            result.append(
                moin_page.h(attrib={moin_page.outline_level: '1'},
                            children=[heading]))
            if desc:
                result.append(moin_page.p(children=[desc]))
            table = moin_page.table()
            result.append(table)

            header = moin_page.table_header()
            table.append(header)

            row = moin_page.table_row()
            header.append(row)
            for text in [
                    _('Variable name'),
                    _('Default'),
                    _('Description'),
            ]:
                strong_text = moin_page.strong(children=[text])
                row.append(moin_page.table_cell(children=[strong_text]))

            body = moin_page.table_body()
            table.append(body)

            opts = list(opts)
            opts.sort()
            for name, default, description in opts:
                if addgroup:
                    name = groupname + '_' + name
                if isinstance(default, defaultconfig.DefaultExpression):
                    default_txt = default.text
                else:
                    default_txt = '%r' % (default, )
                    if len(default_txt) > 30:
                        default_txt = moin_page.span(
                            attrib={moin_page.title: default_txt},
                            children=['...'])
                    description = _(description or '')
                row = moin_page.table_row()
                body.append(row)
                row.append(moin_page.table_cell(children=[name]))
                default = moin_page.code(children=[default_txt])
                row.append(moin_page.table_cell(children=[default]))
                row.append(moin_page.table_cell(children=[description]))
        return result
コード例 #6
0
    def macro(self, content, arguments, page_url, alternative):
        """
        Invocation: <<MailTo(user AT example DOT org, write me)>>
        where 2nd parameter is optional.
        """
        if arguments:
            arguments = arguments[0].split(',')
        try:
            assert len(arguments) > 0 and len(arguments) < 3
            email = arguments[0]
            assert len(email) >= 5
        except (AttributeError, AssertionError):
            raise ValueError(
                _("MailTo: invalid format, try: <<MailTo(user AT example DOT org, write me)>>"
                  ))

        try:
            text = arguments[1]
        except IndexError:
            text = u''

        if flaskg.user.valid:
            # decode address and generate mailto: link
            email = decodeSpamSafeEmail(email)
            result = moin_page.a(
                attrib={xlink.href: u'mailto:{0}'.format(email)},
                children=[text or email])
        else:
            # unknown user, maybe even a spambot, so just return text as given in macro args
            if text:
                text += " "
            result = moin_page.code(children=[text, "<{0}>".format(email)])

        return result
コード例 #7
0
    def macro(self):
        iwlist = app.cfg.interwiki_map.items()
        iwlist.sort()

        iw_list = moin_page.list()
        for tag, url in iwlist:
            href = join_wiki(url, 'RecentChanges')
            link = moin_page.a(attrib={xlink.href: href}, children=[tag])
            label = moin_page.code(children=[link])
            iw_item_label = moin_page.list_item_label(children=[label])
            if '$PAGE' not in url:
                link = moin_page.a(attrib={xlink.href: url}, children=[url])
            else:
                link = url
            body = moin_page.code(children=[link])
            iw_item_body = moin_page.list_item_body(children=[body])
            iw_item = moin_page.list_item(children=[iw_item_label, iw_item_body])
            iw_list.append(iw_item)
        return iw_list
コード例 #8
0
    def inline_nowiki_repl(self, stack, nowiki, nowiki_text=None, nowiki_text_backtick=None):
        text = None
        if nowiki_text is not None:
            text = nowiki_text
        # Remove empty backtick nowiki samples
        elif nowiki_text_backtick:
            text = nowiki_text_backtick
        else:
            return

        stack.top_append(moin_page.code(children=[text]))
コード例 #9
0
ファイル: moinwiki_in.py プロジェクト: yask123/moin-2.0
    def inline_nowiki_repl(self, stack, nowiki, nowiki_text=None, nowiki_text_backtick=None):
        text = None
        if nowiki_text is not None:
            text = nowiki_text
        # Remove empty backtick nowiki samples
        elif nowiki_text_backtick:
            text = nowiki_text_backtick
        else:
            return

        stack.top_append(moin_page.code(children=[text]))
コード例 #10
0
 def create_number_pagelink_list(self, num_pagenames, ordered=False):
     """ creates an ET with a list of pagelinks from a list of pagenames """
     num_page_list = moin_page.list(attrib={moin_page.item_label_generate: ordered and 'ordered' or 'unordered'})
     for num, pagename in num_pagenames:
         num_code = moin_page.code(children=["{0:6d} ".format(num)])
         # This link can never reach pagelinks
         url = unicode(iri.Iri(scheme=u'wiki', authority=u'', path=u'/' + pagename))
         pagelink = moin_page.a(attrib={xlink.href: url}, children=[pagename])
         item_body = moin_page.list_item_body(children=[num_code, pagelink])
         item = moin_page.list_item(children=[item_body])
         num_page_list.append(item)
     return num_page_list
コード例 #11
0
ファイル: _base.py プロジェクト: pombredanne/moin2
 def create_number_pagelink_list(self, num_pagenames, ordered=False):
     """ creates an ET with a list of pagelinks from a list of pagenames """
     num_page_list = moin_page.list(attrib={moin_page.item_label_generate: ordered and 'ordered' or 'unordered'})
     for num, pagename in num_pagenames:
         num_code = moin_page.code(children=["{0:6d} ".format(num)])
         # This link can never reach pagelinks
         url = unicode(iri.Iri(scheme=u'wiki', authority=u'', path=u'/' + pagename))
         pagelink = moin_page.a(attrib={xlink.href: url}, children=[pagename])
         item_body = moin_page.list_item_body(children=[num_code, pagelink])
         item = moin_page.list_item(children=[item_body])
         num_page_list.append(item)
     return num_page_list
コード例 #12
0
ファイル: creole_in.py プロジェクト: rciorba/moin-2.0-mirror
 def inline_nowiki_repl(self, stack, nowiki, nowiki_text):
     stack.top_append(moin_page.code(children=(nowiki_text,)))
コード例 #13
0
ファイル: creole_in.py プロジェクト: lmgsanm/moin-2.0
 def inline_nowiki_repl(self, stack, nowiki, nowiki_text):
     stack.top_append(moin_page.code(children=(nowiki_text, )))
コード例 #14
0
ファイル: rst_in.py プロジェクト: YelaSeamless/moin-2.0
 def visit_literal(self, node):
     self.open_moin_page_node(moin_page.code())
     self.open_moin_page_node(node.astext())
     node.children = []
     self.close_moin_page_node()
     self.close_moin_page_node()
コード例 #15
0
ファイル: rst_in.py プロジェクト: ThomasWaldmann/moin-2.0-dev
 def visit_literal(self, node):
     self.open_moin_page_node(moin_page.code())
     self.open_moin_page_node(node.astext())
     node.children = []
     self.close_moin_page_node()
     self.close_moin_page_node()
コード例 #16
0
    def macro(self):
        if not flaskg.user or not flaskg.user.isSuperUser():
            return ''

        settings = {}
        for groupname in defaultconfig.options:
            heading, desc, opts = defaultconfig.options[groupname]
            for name, default, description in opts:
                name = groupname + '_' + name
                if isinstance(default, defaultconfig.DefaultExpression):
                    default = default.value
                settings[name] = default
        for groupname in defaultconfig.options_no_group_name:
            heading, desc, opts = defaultconfig.options_no_group_name[
                groupname]
            for name, default, description in opts:
                if isinstance(default, defaultconfig.DefaultExpression):
                    default = default.value
                settings[name] = default

        result = moin_page.div()

        result.append(
            moin_page.h(attrib={moin_page.outline_level: '1'},
                        children=[_("Wiki configuration")]))

        desc = _(
            "This table shows all settings in this wiki that do not have default values. "
            "Settings that the configuration system doesn't know about are shown in italic, "
            "those may be due to third-party extensions needing configuration or settings that "
            "were removed from Moin.")
        result.append(moin_page.p(children=[desc]))

        table = moin_page.table()
        result.append(table)

        header = moin_page.table_header()
        table.append(header)

        row = moin_page.table_row()
        header.append(row)
        for text in [
                _('Variable name'),
                _('Setting'),
        ]:
            strong_text = moin_page.strong(children=[text])
            row.append(moin_page.table_cell(children=[strong_text]))

        body = moin_page.table_body()
        table.append(body)

        def iter_vnames(cfg):
            dedup = {}
            for name in cfg.__dict__:
                dedup[name] = True
                yield name, cfg.__dict__[name]
            for cls in cfg.__class__.mro():
                if cls == defaultconfig.ConfigFunctionality:
                    break
                for name in cls.__dict__:
                    if not name in dedup:
                        dedup[name] = True
                        yield name, cls.__dict__[name]

        found = []
        for vname, value in iter_vnames(app.cfg):
            if hasattr(defaultconfig.ConfigFunctionality, vname):
                continue
            if vname in settings and settings[vname] == value:
                continue
            found.append((vname, value))

        found.sort()
        for vname, value in found:
            if not vname in settings:
                vname = moin_page.emphasis(children=[vname])
            vtxt = '%r' % (value, )
            row = moin_page.table_row()
            body.append(row)
            row.append(moin_page.table_cell(children=[vname]))
            vtxt_code = moin_page.code(children=[vtxt])
            row.append(moin_page.table_cell(children=[vtxt_code]))
        return result