Exemple #1
0
def edit_do(request, id_, **kwargs):
    content = request.form.get("content", "")
    action = request.form.get("action", "")
    action = action.lower()

    if action == "delete":
        deldata = document.delete(notedb(), xapdb, id_)
        if deldata is None:
            return notfound()
    else:
        updatedata = document.update(notedb(), xapdb, id_, content)
        if updatedata is None:
            return notfound()

    return redirect("document.index")
Exemple #2
0
def latest(**kwargs):
    docs = document.latest(notedb())
    return jsonresponse([{
        "id": doc[0],
        "text": doc[1],
        "date": doc[2]
    } for doc in docs], indent=4)
Exemple #3
0
def edit(id_, **kwargs):
    doc = document.get(notedb(), id_)
    if doc is None:
        return notfound()
    
    return templateresponse("/page/editor.mako", 
        id_=id_,
        content=doc[1])
Exemple #4
0
def search(request, **kwargs):
    query = request.args.get("q", "")
    result = document.search(notedb(), xapdb, query)
    return jsonresponse(result)
Exemple #5
0
def create_do(request, **kwargs):
    content = request.form.get("content", "")
    document.create(notedb(), xapdb, content)
    return redirect("document.index")