include "page.wl" let posts = $query("SELECT title, content FROM Posts WHERE id=?", $post_id) let comments = $query("SELECT C.id, U.username, C.content, C.parent_post, C.parent_comment FROM Comments as C, Users as U WHERE C.parent_post=? AND U.id == C.author", $post_id) let lookup = {} for comment in comments: { comment.child = [] lookup[comment.id] = comment } let roots = [] for comment in comments: { if comment.parent_comment == none: roots << comment else lookup[comment.parent_comment].child << comment } comments = roots let post = posts[0] let style = procedure render_comment(parent)
\parent.username

\parent.content

\if $login_user_id != none:
\for child in parent.child: render_comment(child)
let main =

\post.title

\post.content

\if len comments == 0: No comments yet! else for comment in comments: render_comment(comment)
page(post.title, $login_user_id, style, main)