Example #1
0
File: admin.py Project: rwos/psblog
def del_comment(post_id, cid):
    """ Delete a comment. """
    p = psblog.get_post(post_id)
    del p["comments"][cid]
    rm_post(post_id)
    add_post(
        p["meta"]["heading"],
        p["meta"]["category"],
        p["text"],
        p["meta"]["datetime"],
        p["comments"])
    psblog.compile_everything()
Example #2
0
File: admin.py Project: rwos/psblog
def save_single(path, params):
    """ Save a single post, replacing the old one. """
    old = psblog.get_post(path)
    old_date = old["meta"]["datetime"]
    old_comments = old["comments"]
    rm_post(path)
    print("old page deleted<br>")
    add_post(
        params["heading"].value,
        params["category"].value,
        params["text"].value,
        old_date,
        old_comments)
    psblog.compile_everything()
    print("new page added<br>")
Example #3
0
if "text" not in my_form or len(my_form["text"].value) < 1:
    print("Content-Type: text/html\n\n")
    print("nothing to see here")
else:
    try:
        # TODO: proper form handling
        name = cgi.escape(my_form["name"].value)
        if "mail" in my_form:
            mail = cgi.escape(my_form["mail"].value)
        else:
            mail = ""
        if "url" in my_form:
            url = cgi.escape(my_form["url"].value)
        else:
            url = ""
        text = cgi.escape(my_form["text"].value)
        if "href" in text:
            psblog.log_err("rejecting comment: "
               +str([name, mail, url, text]))
            print("Content-Type: text/html\n\n")
            print("no html hyperlinks, please use markdown syntax")
        else:
            post_id = cgi.escape(my_form["post_id"].value)
            add_comment(name, mail, url, text, post_id)
            psblog.compile_everything()
            print("Location: "+my_form["post_url"].value+"\n\n")
    except KeyError:
        print("Content-Type: text/html\n\n")
        print("Sorry, but that didn't work...")