def pre_render_template(name): """ Replace config strings in the template and return the result. """ template = psblog.readfile(name) for opt, val in config.options().items(): if type(val) is not str: val = str(val) template = template.replace("%%%"+opt+"%%%", val) return template
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))