add user page markup

This commit is contained in:
2025-05-20 17:05:45 +03:00
parent 3bd474d7fe
commit 2eddb70d63
7 changed files with 186 additions and 42 deletions

View File

@ -71,8 +71,7 @@ app:get("user", "/:username", function(self)
self.session.flash = {}
end
-- local me = validate_session(self.session.session_key) or TransientUser
local me = util.get_logged_in_user(self) or util.TransientUser
local me = util.get_logged_in_user_or_transient(self)
self.user = user
self.me = me
@ -84,7 +83,24 @@ app:get("user", "/:username", function(self)
end
end
self.page_title = user.username
self.latest_posts = db.query([[
SELECT
posts.id, posts.created_at, post_history.content, post_history.edited_at, threads.title AS thread_title, topics.name as topic_name, threads.slug as thread_slug
FROM
posts
JOIN
post_history ON posts.current_revision_id = post_history.id
JOIN
threads ON posts.thread_id = threads.id
JOIN
topics ON threads.topic_id = topics.id
WHERE
posts.user_id = ?
ORDER BY posts.created_at DESC
LIMIT 10
]], user.id)
self.page_title = user.username .. "'s profile"
return {render = "user.user"}
end)