コード例 #1
0
ファイル: main.py プロジェクト: milkmeat/zbox_wiki
def wp_edit(req_path):
    full_path = req_path_to_full_path(req_path)

    if conf.button_mode_path:
        buf = commons.text_path2btns_path("/%s" % req_path)
        title = commons.md2html(buf)
    else:
        title = req_path

    if os.path.isfile(full_path):
        content = commons.cat(full_path)

    elif os.path.isdir(full_path):
        content = get_dot_idx_content_by_full_path(full_path)

    elif not os.path.exists(full_path):
        content = ""

    else:
        raise Exception("invalid path '%s'" % req_path)

    static_files = get_global_static_files(auto_toc = False,
                            highlight = False,
                            reader_mode = False)

    return tpl_render.editor(req_path, title, content, static_files=static_files)
コード例 #2
0
ファイル: main.py プロジェクト: milkmeat/zbox_wiki
def wp_read(req_path, show_full_path, auto_toc, highlight, pages_path,
            show_quick_links, show_source_button):
    full_path = req_path_to_full_path(req_path)

    if conf.button_mode_path:
        buf = commons.text_path2btns_path("/%s" % req_path)
        button_path = commons.md2html(buf)
    else:
        button_path = None

    if os.path.isfile(full_path):
        work_full_path = os.path.dirname(full_path)
        static_file_prefix = os.path.join("/static/pages", os.path.dirname(req_path))

        content = commons.cat(full_path)
        content = commons.strip_bom(content)

        HOME_PAGE = "home"
        if req_path == HOME_PAGE:
            button_path = None
        else:
            show_quick_links = False

    elif os.path.isdir(full_path):
        work_full_path = full_path
        static_file_prefix = os.path.join("/static/pages", req_path)

        buf1 = get_dot_idx_content_by_full_path(full_path) or ""
        buf2 = get_page_file_list_by_req_path(req_path)

        if buf2:
            buf2 = sequence_to_unorder_list(buf2.split("\n"), show_full_path = show_full_path)
        else:
            buf2 = ""

        content = buf1 + "\n" + "----" + "\n" + buf2

    else:
        if req_path == "home" and (not os.path.exists(full_path)):
            return web.seeother("~all")
        else:
            return web.seeother("/%s?action=edit" % req_path)

    content = zw_macro2md(text = content, show_full_path = show_full_path, pages_path = pages_path)

    content = commons.md2html(text = content,
                              work_full_path = work_full_path,
                              static_file_prefix = static_file_prefix)

    static_files = get_the_same_folders_cssjs_files(req_path)
    if not static_files:
        static_files = get_global_static_files(auto_toc = auto_toc, highlight = highlight) + "\n"

    return tpl_render.canvas(conf = conf,
                           req_path = req_path,
                           button_path = button_path,
                           content = content,
                           static_files = static_files,
                           show_quick_links = show_quick_links,
                           show_source_button = show_source_button)