示例#1
0
 def inline_comment_repl(self, stack, comment, comment_begin=None, comment_end=None):
     if comment_begin:
         attrib = {moin_page('class'): 'comment'}
         elem = moin_page.span(attrib=attrib)
         stack.push(elem)
     else:
         stack.pop()
示例#2
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
示例#3
0
 def inline_comment_repl(self, stack, comment, comment_begin=None, comment_end=None):
     if comment_begin:
         attrib = {moin_page('class'): 'comment'}
         elem = moin_page.span(attrib=attrib)
         stack.push(elem)
     else:
         stack.pop()
示例#4
0
 def inline_size_repl(self, stack, size, size_begin=None, size_end=None):
     if size_begin:
         size = '120%' if size[1] == '+' else '85%'
         attrib = {moin_page.font_size: size}
         elem = moin_page.span(attrib=attrib)
         stack.push(elem)
     else:
         stack.pop()
示例#5
0
 def depart_term(self, node):
     # classifiers arrive as siblings of the term; search the parent and convert them to children
     for child in node.parent:
         if isinstance(child, docutils.nodes.classifier):
             classifier = u":" + child[0]
             self.open_moin_page_node(moin_page.span(children=[classifier]))
             self.close_moin_page_node()
     self.close_moin_page_node()
示例#6
0
 def inline_size_repl(self, stack, size, size_begin=None, size_end=None):
     if size_begin:
         size = '120%' if size[1] == '+' else '85%'
         attrib = {moin_page.font_size: size}
         elem = moin_page.span(attrib=attrib)
         stack.push(elem)
     else:
         stack.pop()
 def inline_strike_repl(self,
                        stack,
                        strike,
                        strike_begin=None,
                        strike_end=None):
     if strike_begin is not None:
         attrib = {moin_page.text_decoration: 'line-through'}
         stack.push(moin_page.span(attrib=attrib))
     elif strike_end is not None:
         stack.pop()
示例#8
0
    def visit_target(self, node):
        """
        Pass explicit anchor as a SPAN with no children, just an ID attribute

        .. _example:
        """
        anchor = node.get('refid')
        if anchor:
            self.open_moin_page_node(
                moin_page.span(attrib={moin_page.id: anchor}))
            self.close_moin_page_node()
示例#9
0
    def macro(self, content, arguments, page_url, alternative):
        request = self.request

        if arguments:
            item_count = int(arguments[0])
        else:
            item_count = 1

        rootitem = Item(request, u'')
        all_item_names = [i.name for i in rootitem.list_items()]

        # Now select random item from the full list, and if it exists and
        # we can read it, save.
        random_item_names = []
        found = 0
        while found < item_count and all_item_names:
            # Take one random item from the list
            item_name = random.choice(all_item_names)
            all_item_names.remove(item_name)

            # Filter out items the user may not read.
            try:
                item = Item.create(item_name)
                random_item_names.append(item_name)
                found += 1
            except AccessDeniedError:
                pass

        if not random_item_names:
            return

        random_item_names.sort()

        result = moin_page.span()
        for name in random_item_names:
            link = unicode(Iri(scheme=u'wiki', authority=u'', path=u'/' + name))
            result.append(moin_page.a(attrib={xlink.href: link}, children=[name]))
            result.append(", ")

        del result[-1] # kill last comma
        return result
示例#10
0
    def macro(self, content, arguments, page_url, alternative):
        if arguments:
            item_count = int(arguments[0])
        else:
            item_count = 1

        all_item_names = [i.name for i in flaskg.storage.iteritems()]

        # Now select random item from the full list, and if it exists and
        # we can read it, save.
        random_item_names = []
        found = 0
        while found < item_count and all_item_names:
            # Take one random item from the list
            item_name = random.choice(all_item_names)
            all_item_names.remove(item_name)

            # Filter out items the user may not read.
            try:
                item = Item.create(item_name)
                random_item_names.append(item_name)
                found += 1
            except AccessDenied:
                pass

        if not random_item_names:
            return

        random_item_names.sort()

        result = moin_page.span()
        for name in random_item_names:
            link = unicode(Iri(scheme=u'wiki', authority=u'', path=u'/' + name))
            result.append(moin_page.a(attrib={xlink.href: link}, children=[name]))
            result.append(", ")

        del result[-1]  # kill last comma
        return result
示例#11
0
    def macro(self, content, arguments, page_url, alternative):
        if not arguments:
            raise ValueError("Anchor: you need to specify an anchor name.")

        anchor = arguments[0]
        return moin_page.span(attrib={moin_page.id: anchor})
示例#12
0
 def _append(self, type, value, element):
     class_ = STANDARD_TYPES.get(type)
     if class_:
         value = moin_page.span(attrib={moin_page.class_: class_},
                                children=(value, ))
     element.append(value)
示例#13
0
 def inline_superscript_repl(self, stack, superscript, superscript_text):
     attrib = {moin_page.baseline_shift: 'super'}
     elem = moin_page.span(attrib=attrib, children=[superscript_text])
     stack.top_append(elem)
示例#14
0
 def inline_underline_repl(self, stack, underline):
     attrib = {moin_page.text_decoration: 'underline'}
     if stack.top_check('span', attrib=attrib):
         stack.pop()
     else:
         stack.push(moin_page.span(attrib=attrib))
示例#15
0
 def inline_strike_repl(self, stack, strike, strike_begin=None):
     if strike_begin is not None:
         attrib = {moin_page.text_decoration: 'line-through'}
         stack.push(moin_page.span(attrib=attrib))
     else:
         stack.pop()
示例#16
0
 def inline_underline_repl(self, stack, underline):
     if not stack.top_check("span"):
         attrib = {moin_page.text_decoration: "underline"}
         stack.push(moin_page.span(attrib=attrib))
     else:
         stack.pop()
示例#17
0
    def macro(self, anchor=unicode):
        if not anchor:
            raise ValueError("Anchor: you need to specify an anchor name.")

        return moin_page.span(attrib={moin_page.id: anchor})
示例#18
0
 def _append(self, type, value, element):
     class_ = STANDARD_TYPES.get(type)
     if class_:
         value = moin_page.span(attrib={moin_page.class_: class_}, children=(value, ))
     element.append(value)
示例#19
0
 def inline_underline_repl(self, stack, underline):
     attrib = {moin_page.text_decoration: 'underline'}
     if stack.top_check('span', attrib=attrib):
         stack.pop()
     else:
         stack.push(moin_page.span(attrib=attrib))
示例#20
0
 def visit_superscript(self, node):
     self.open_moin_page_node(
         moin_page.span(attrib={moin_page.baseline_shift: u'super'}))
示例#21
0
 def visit_superscript(self, node):
     self.open_moin_page_node(
         moin_page.span(
             attrib={moin_page.baseline_shift: u'super'}))
示例#22
0
 def inline_superscript_repl(self, stack, superscript, superscript_text):
     attrib = {moin_page.baseline_shift: 'super'}
     elem = moin_page.span(attrib=attrib, children=[superscript_text])
     stack.top_append(elem)
示例#23
0
    def macro(self, content, arguments, page_url, alternative):
        if not arguments:
            raise ValueError("Anchor: you need to specify an anchor name.")

        anchor = arguments[0]
        return moin_page.span(attrib={moin_page.id: anchor})