示例#1
0
文件: admin.py 项目: rwos/psblog
def show_list():
    """ Show a list of all posts. """
    posts = psblog.get_all_posts()
    ls_data = []
    for p in posts:
        ls_data.append("".join([
              p["meta"]["datetime"].strftime("%x")," - ",
              html.a("?page=single&id="+psblog.post_id(p["meta"]),
              p["meta"]["heading"]), " - ", 
              str(len(p["comments"])), " comment(s)"]))
    print(html.render_admin(html.block(html.ul(ls_data))))
示例#2
0
文件: admin.py 项目: rwos/psblog
def show_overview():
    """ Show an overview over the blog. """
    posts = psblog.get_all_posts()
    comments_num = 0
    for p in posts:
        comments_num += len(p["comments"])
    o = [html.h(2, "Overview"),
         html.p(html.a("?page=list", str(len(posts))+" Posts")),
         html.p(html.a("#TODO", str(comments_num)+" Comments")),
         html.p(html.a("?page=add_new", "Add New Post")),
         html.p(html.a("?page=compile", "Re-Compile"))]
    o = html.block("".join(o))
    o += html.block(html.p("last compile log:"+html.pre(
            psblog.readfile(config.log_dir+"compile.log"))))
    log_ls = psblog.readfile(config.log_dir+"psblog.log").splitlines()
    log_ls.reverse()
    o += html.block(html.p("blog log:"+html.pre("\n".join(log_ls))))
    print(html.render_admin(o))