def inline_emphstrong_repl(self, stack, emphstrong, emphstrong_follow=''):
     if len(emphstrong) == 5:
         if stack.top_check('emphasis'):
             stack.pop()
             if stack.top_check('strong'):
                 stack.pop()
             else:
                 stack.push(moin_page.strong())
         elif stack.top_check('strong'):
             if stack.top_check('strong'):
                 stack.pop()
             else:
                 stack.push(moin_page.strong())
         else:
             if len(emphstrong_follow) == 3:
                 stack.push(moin_page.emphasis())
                 stack.push(moin_page.strong())
             else:
                 stack.push(moin_page.strong())
                 stack.push(moin_page.emphasis())
     elif len(emphstrong) == 3:
         if stack.top_check('strong'):
             stack.pop()
         else:
             stack.push(moin_page.strong())
     elif len(emphstrong) == 2:
         if stack.top_check('emphasis'):
             stack.pop()
         else:
             stack.push(moin_page.emphasis())
Exemple #2
0
 def inline_emphstrong_repl(self, stack, emphstrong, emphstrong_follow=''):
     if len(emphstrong) == 5:
         if stack.top_check('emphasis'):
             stack.pop()
             if stack.top_check('strong'):
                 stack.pop()
             else:
                 stack.push(moin_page.strong())
         elif stack.top_check('strong'):
             stack.pop()
             if stack.top_check('emphasis'):
                 stack.pop()
             else:
                 stack.push(moin_page.emphasis())
         else:
             if len(emphstrong_follow) == 3:
                 stack.push(moin_page.emphasis())
                 stack.push(moin_page.strong())
             else:
                 stack.push(moin_page.strong())
                 stack.push(moin_page.emphasis())
     elif len(emphstrong) == 3:
         if stack.top_check('strong'):
             stack.pop()
         else:
             stack.push(moin_page.strong())
     elif len(emphstrong) == 2:
         if stack.top_check('emphasis'):
             stack.pop()
         else:
             stack.push(moin_page.emphasis())
Exemple #3
0
    def recurse(self, elem):
        new_childs = []

        for child in elem:
            if isinstance(child, unicode):
                pos = 0

                # Restrict it to our own namespace for now
                if elem.tag.uri == moin_page.namespace:
                    for match in self.re.finditer(child):
                        text = child[pos:match.start()]
                        new_childs.append(text)

                        text = child[match.start():match.end()]
                        attrib = {html.class_: 'moin-highlight'}
                        e = moin_page.strong(attrib=attrib, children=[text])
                        new_childs.append(e)

                        pos = match.end()

                new_childs.append(child[pos:])
            else:
                self.recurse(child)
                new_childs.append(child)

        # Use inline replacement to avoid a complete tree copy
        if len(new_childs) > len(elem):
            elem[:] = new_childs
Exemple #4
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
Exemple #5
0
    def recurse(self, elem):
        new_childs = []

        for child in elem:
            if isinstance(child, unicode):
                pos = 0

                # Restrict it to our own namespace for now
                if elem.tag.uri == moin_page.namespace:
                    for match in self.re.finditer(child):
                        text = child[pos:match.start()]
                        new_childs.append(text)

                        text = child[match.start():match.end()]
                        attrib = {html.class_: 'moin-highlight'}
                        e = moin_page.strong(attrib=attrib, children=[text])
                        new_childs.append(e)

                        pos = match.end()

                new_childs.append(child[pos:])
            else:
                self.recurse(child)
                new_childs.append(child)

        # Use inline replacement to avoid a complete tree copy
        if len(new_childs) > len(elem):
            elem[:] = new_childs
 def visit_author(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Author:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #7
0
 def visit_copyright(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Copyright:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #8
0
 def visit_version(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Version:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #9
0
 def visit_author(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Author:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #10
0
 def visit_copyright(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Copyright:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #11
0
 def visit_version(self, node):
     self.open_moin_page_node(moin_page.table_row())
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     # TODO: i18n for docutils:
     self.open_moin_page_node(u"Version:")
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.close_moin_page_node()
     self.open_moin_page_node(moin_page.table_cell())
Exemple #12
0
 def inline_strong_repl(self, stack, strong):
     if not stack.top_check("strong"):
         stack.push(moin_page.strong())
     else:
         stack.pop_name("strong")
Exemple #13
0
 def inline_strong_repl(self, stack, strong):
     if not stack.top_check('strong'):
         stack.push(moin_page.strong())
     else:
         stack.pop_name('strong')
Exemple #14
0
 def visit_strong(self, node):
     self.open_moin_page_node(moin_page.strong())
Exemple #15
0
 def visit_strong(self, node):
     self.open_moin_page_node(moin_page.strong())
Exemple #16
0
 def visit_field_name(self, node):
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     self.open_moin_page_node(u'%s:' % node.astext())
     node.children = []
     self.close_moin_page_node()
Exemple #17
0
 def visit_field_name(self, node):
     self.open_moin_page_node(moin_page.table_cell())
     self.open_moin_page_node(moin_page.strong())
     self.open_moin_page_node(u'{0}:'.format(node.astext()))
     node.children = []
     self.close_moin_page_node()
    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