add user page markup
This commit is contained in:
@ -68,11 +68,23 @@ app:get("thread", "/:slug", function(self)
|
||||
return {status = 404}
|
||||
end
|
||||
self.thread = thread
|
||||
|
||||
if self.params.after then
|
||||
local after_id = tonumber(self.params.after)
|
||||
local post_position = Posts:count(db.clause({
|
||||
thread_id = thread.id,
|
||||
{"id <= ?", after_id},
|
||||
}))
|
||||
self.page = math.floor((post_position - 1) / POSTS_PER_PAGE) + 1
|
||||
else
|
||||
self.page = tonumber(self.params.page) or 1
|
||||
end
|
||||
|
||||
local post_count = Posts:count(db.clause({
|
||||
thread_id = thread.id
|
||||
}))
|
||||
self.pages = math.ceil(post_count / POSTS_PER_PAGE)
|
||||
self.page = tonumber(self.params.page) or 1
|
||||
-- self.page = math.max(1, math.min(self.page, self.pages))
|
||||
local posts = db.query([[
|
||||
SELECT
|
||||
posts.id, posts.created_at, post_history.content, post_history.edited_at, users.username, users.status, avatars.file_path AS avatar_path
|
||||
@ -93,9 +105,9 @@ app:get("thread", "/:slug", function(self)
|
||||
self.topic = Topics:find(thread.topic_id)
|
||||
self.me = util.get_logged_in_user_or_transient(self)
|
||||
self.posts = posts
|
||||
|
||||
|
||||
self.page_title = thread.title
|
||||
|
||||
|
||||
return {render = "threads.thread"}
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user