Example #1
0
def page(name):
    if util.page_exists(PAGES_DIR, name):
        page = open(os.path.join(PAGES_DIR, name), "r")
        document = markdown2.markdown(unicode("".join(page.readlines()), "utf-8", "ignore"))
        return template("page.html", name=name, content=document)
    elif name == "start":
        start_text = """\
##A Mercurial Wiki##

This is a wiki built on top of Mercurial. You can use the [markdown markup](https://github.com/trentm/python-markdown2) to layout your wiki pages. 

Start creating some content!"""
        util.write_to_file(REPO_DIR, PAGES_DIR, os.path.join(PAGES_DIR, name), start_text)
        util.commit_to_repo(REPO_DIR, [os.path.join(PAGES_DIR, name)], name)
        document = markdown2.markdown(start_text)
        return template("page.html", name=name, content=document)
    else:
        redirect("/edit/" + name)
Example #2
0
def update_page(name):
    util.write_to_file(REPO_DIR, PAGES_DIR, os.path.join(PAGES_DIR, name), request.forms.get("content"))
    file_list = [os.path.join(PAGES_DIR, name)]
    util.commit_to_repo(REPO_DIR, file_list, name)
    redirect(name)