some things
This commit is contained in:
parent
5ec458702a
commit
85b1319c79
@ -64,6 +64,10 @@ app:get("thread", "/:slug", function(self)
|
|||||||
return {status = 404}
|
return {status = 404}
|
||||||
end
|
end
|
||||||
self.thread = thread
|
self.thread = thread
|
||||||
|
local post_count = Posts:count(db.clause({
|
||||||
|
thread_id = thread.id
|
||||||
|
}))
|
||||||
|
local pages = math.floor(post_count / 20)
|
||||||
local posts = db.query([[
|
local posts = db.query([[
|
||||||
SELECT
|
SELECT
|
||||||
posts.id, post_history.content, users.username, avatars.file_path AS avatar_path
|
posts.id, post_history.content, users.username, avatars.file_path AS avatar_path
|
||||||
@ -81,6 +85,7 @@ app:get("thread", "/:slug", function(self)
|
|||||||
posts.created_at ASC
|
posts.created_at ASC
|
||||||
LIMIT 20
|
LIMIT 20
|
||||||
]], thread.id, tonumber(self.params.cursor or 0))
|
]], thread.id, tonumber(self.params.cursor or 0))
|
||||||
|
self.topic = Topics:find(thread.topic_id)
|
||||||
self.user = util.get_logged_in_user_or_transient(self)
|
self.user = util.get_logged_in_user_or_transient(self)
|
||||||
self.posts = posts
|
self.posts = posts
|
||||||
self.next_cursor = #posts > 0 and posts[#posts].id or nil
|
self.next_cursor = #posts > 0 and posts[#posts].id or nil
|
||||||
|
@ -62,9 +62,7 @@ app:get("topic", "/:slug", function(self)
|
|||||||
return {status = 404}
|
return {status = 404}
|
||||||
end
|
end
|
||||||
self.topic = topic
|
self.topic = topic
|
||||||
self.threads_list = Threads:select(db.clause({
|
self.threads_list = db.query("SELECT * FROM threads WHERE topic_id = ? ORDER BY is_stickied DESC, created_at DESC", topic.id)
|
||||||
topic_id = topic.id
|
|
||||||
}))
|
|
||||||
local user = util.get_logged_in_user_or_transient(self)
|
local user = util.get_logged_in_user_or_transient(self)
|
||||||
print(topic.is_locked, type(topic.is_locked))
|
print(topic.is_locked, type(topic.is_locked))
|
||||||
self.user = user
|
self.user = user
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
<h1><%= thread.title %></h1>
|
||||||
|
<p>Posted under <a href="<%= url_for("topic", {slug = topic.slug}) %>"><%= topic.name %></a>
|
||||||
<% for _, post in ipairs(posts) do %>
|
<% for _, post in ipairs(posts) do %>
|
||||||
<div>
|
<div>
|
||||||
<img src="<%= post.avatar_path or "/avatars/default.webp" %>">
|
<img src="<%= post.avatar_path or "/avatars/default.webp" %>"><br>
|
||||||
<div><%= post.username %></div>
|
<a href="<%= url_for("user", {username = post.username}) %>"><%= post.username %></a>
|
||||||
<div><p><%- post.content %></p></div>
|
<div><p><%- post.content %></p></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
<h2><%= topic.description %></h2>
|
<h2><%= topic.description %></h2>
|
||||||
<% if #threads_list == 0 then %>
|
<% if #threads_list == 0 then %>
|
||||||
<p>There are no threads in this topic.</p>
|
<p>There are no threads in this topic.</p>
|
||||||
|
<% else %>
|
||||||
|
<ul>
|
||||||
|
<% for _, thread in ipairs(threads_list) do %>
|
||||||
|
<li>
|
||||||
|
<a href="<%= url_for("thread", {slug = thread.slug}) %>"><%= thread.title %></a><% if ntob(thread.is_stickied) then %> - pinned<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if thread_create_error == ThreadCreateError.OK then %>
|
<% if thread_create_error == ThreadCreateError.OK then %>
|
||||||
|
@ -13,6 +13,6 @@
|
|||||||
</form>
|
</form>
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<label for="status">Status</label>
|
<label for="status">Status</label>
|
||||||
<input type="text" id="status" name="status" value="<%= user.status %>" maxlength="10"><br>
|
<input type="text" id="status" name="status" value="<%= user.status %>" maxlength="30"><br>
|
||||||
<input type="submit" value="Save">
|
<input type="submit" value="Save">
|
||||||
</form>
|
</form>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
<h2>You are a guest. An administrator needs to approve your account before you will be able to post.</h2>
|
<h2>You are a guest. An administrator needs to approve your account before you will be able to post.</h2>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if user_is_me then %>
|
<% if user_is_me then %>
|
||||||
|
<a href="<%= url_for("user_settings", {username = user.username}) %>">Settings</a>
|
||||||
<form method="post" action="<%= url_for("user_logout", {user_id = me.id}) %>">
|
<form method="post" action="<%= url_for("user_logout", {user_id = me.id}) %>">
|
||||||
<input type="submit" value="Log out">
|
<input type="submit" value="Log out">
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user