include "pages/page.wl" let posts = $query("SELECT U.username, P.title, P.content FROM Posts as P, Users as U WHERE P.id=? AND U.id=P.author", $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 root_comments = [] for comment in comments: { if comment.parent_comment == none: root_comments << comment else lookup[comment.parent_comment].child << comment } let post = posts[0] let style = let main =
\post.title
submitted 3 hours ago by \post.username | \len comments
\post.content
reply
\procedure render_comment(comment)
\comment.username 2 hours ago
\comment.content
\if $login_user_id != none:
reply
\for child in comment.child: render_comment(child)
\if len root_comments == 0:
No comments
else for comment in root_comments: render_comment(comment)
page(post.title, $login_user_id, style, main)