Beispiel #1
0
def list_pages(pages):
    logging.debug(u'Listing %u pages.' % len(pages))

    def link_line(title):
        return ('    ' * title.count('/')) + '- ' + (
            '[' + title + '](/' + title + ')' if ':' in title else '[[' +
            title + ']]')

    lines = []
    for page in pages:
        title = page.title
        if '/' in title:
            parent = title[:title.rfind('/')]
            if not lines or lines[-1][0] != parent:
                parent_path = parent.split('/')
                for depth in xrange(1, len(parent_path) + 1):
                    target = '/'.join(parent_path[:depth])
                    if not lines or not lines[-1][0].startswith(target):
                        lines.append((target, link_line(target)))
        lines.append((title, link_line(title)))
    return render(
        'index.html', {
            'pages':
            pages,
            'html':
            util.wikify(
                util.parse_markdown('\n'.join(line[1] for line in lines))),
        })
Beispiel #2
0
def list_pages(pages):
    logging.debug(u"Listing %u pages." % len(pages))

    def link_line(title):
        return (
            ("    " * title.count("/"))
            + "- "
            + ("[" + title + "](/" + title + ")" if ":" in title else "[[" + title + "]]")
        )

    lines = []
    for page in pages:
        title = page.title
        if "/" in title:
            parent = title[: title.rfind("/")]
            if not lines or lines[-1][0] != parent:
                parent_path = parent.split("/")
                for depth in xrange(1, len(parent_path) + 1):
                    target = "/".join(parent_path[:depth])
                    if not lines or not lines[-1][0].startswith(target):
                        lines.append((target, link_line(target)))
        lines.append((title, link_line(title)))
    return render(
        "index.html", {"pages": pages, "html": util.wikify(util.parse_markdown("\n".join(line[1] for line in lines)))}
    )
Beispiel #3
0
def list_pages(pages):
    logging.debug(u'Listing %u pages.' % len(pages))
    def link_line(title):
        return ('    ' * title.count('/')) + '- ' + ('[' + title + '](/' + title + ')' if ':' in title else '[[' + title + ']]')
    lines = []
    for page in pages:
        title = page.title
        if '/' in title:
            parent = title[:title.rfind('/')]
            if not lines or lines[-1][0] != parent:
                parent_path = parent.split('/')
                for depth in xrange(1, len(parent_path)+1):
                    target = '/'.join(parent_path[:depth])
                    if not lines or not lines[-1][0].startswith(target):
                        lines.append((target, link_line(target)))
        lines.append((title, link_line(title)))
    return render('index.html', {
        'pages': pages,
        'html': util.wikify(util.parse_markdown('\n'.join(line[1] for line in lines))),
    })
Beispiel #4
0
def markdown(text):
    return util.parse_markdown(text)
Beispiel #5
0
def markdown(text):
    return util.parse_markdown(text)
Beispiel #6
0
 def test_empty_links(self):
     text = util.parse_markdown("[]()")
     self.assertEquals(text, "<p>[]()</p>")
Beispiel #7
0
 def test_markdown_extensions(self):
     self.assertEquals(util.parse_markdown('# foo'), '<h1>foo</h1>')
Beispiel #8
0
 def get_trade_partners_wiki(self):
     profile_md = self.get_wiki().content_md
     return parse_markdown(profile_md, Source())
Beispiel #9
0
 def test_empty_links(self):
     text = util.parse_markdown("[]()")
     self.assertEquals(text, "<p>[]()</p>")
Beispiel #10
0
 def test_markdown_extensions(self):
     self.assertEquals(util.parse_markdown('# foo'), '<h1>foo</h1>')
Beispiel #11
0
def get_author_points(pkl_name="current_records"):
    author_points = load_obj(pkl_name)
    if author_points:
        return author_points
    print('Generating author points')
    return parse_markdown(get_records_page().content_md, Trader())