diff --git a/apioforum/templates/view_post.html b/apioforum/templates/view_post.html index 5155a67..df27040 100644 --- a/apioforum/templates/view_post.html +++ b/apioforum/templates/view_post.html @@ -6,7 +6,7 @@ {% if not revision %} viewing post #{{post.id}} {% else %} - viewing revision #{{revision.id}} of #{{post.id}} + viewing revision #{{revision.rev_index}} of #{{post.id}} {% endif %} {%endblock%} @@ -24,18 +24,21 @@

revision history

{% for rev in history %} +{% set is_current = (not revision and loop.index==1) or (rev.rev_index == revision.rev_index) %} + - + {% if rev.comment %}{%endif%} {% endfor %}
{{disp_user(rev.editor)}} - {% if rev.rev_index == revision.rev_index or (loop.index == 1 and not revision) %} - {{ts(rev.time)}} ago + {% if is_current %} + #{{post.id}}/{{rev.rev_index}} {% else %} - {{ts(rev.time)}} ago - + post_id=post.id, revision=rev.rev_index if loop.index!=1 else None, + _anchor=None)}}"> + #{{post.id}}/{{rev.rev_index}} {% endif %} + {{disp_user(rev.editor)}} + {{ts(rev.time)}}{{rev.comment}}
diff --git a/apioforum/thread.py b/apioforum/thread.py index 26e89e9..0db693f 100644 --- a/apioforum/thread.py +++ b/apioforum/thread.py @@ -422,35 +422,35 @@ def view_post(post_id): rev = None if 'revision' in request.args: - rev_idx = None + rev_index = None try: - rev_idx = int(request.args['revision']) + rev_index = int(request.args['revision']) except ValueError: abort(404) if not can_view_history: abort(403) rev = db.execute( "SELECT * FROM past_revisions WHERE post=? and rev_index=?;", - (post_id,rev_idx)).fetchone() + (post_id,rev_index)).fetchone() if not rev: abort(404) post = dict(post) post['content'] = rev['content'] post['updated'] = rev['time'] + post['rev_index'] = rev['rev_index'] history = None if can_view_history: history = db.execute(""" - SELECT editor, time, comment, rev_index FROM past_revisions WHERE post = ? ORDER BY rev_index DESC; + SELECT editor, time, comment, rev_index + FROM past_revisions WHERE post = ? ORDER BY rev_index DESC; """,(post_id,)).fetchall() - history.insert(0, db.execute( - """SELECT + history.insert(0, db.execute("""SELECT coalesce(editor,author) as editor, coalesce(updated, created) as "time [timestamp]", - comment, NULL as rev_index + comment, rev_index FROM posts WHERE id=?""",(post_id,)).fetchone()) - return render_template("view_post.html",post=post,revision=rev,history=history) def apply_selected_tags(thread, form): -- cgit v1.2.3