add thread view

This commit is contained in:
2025-05-20 12:30:41 +03:00
parent 9b689a08e2
commit 8609c33f00
10 changed files with 229 additions and 31 deletions

View File

@ -1,13 +1,26 @@
<h1><%= thread.title %></h1>
<p>Posted under <a href="<%= url_for("topic", {slug = topic.slug}) %>"><%= topic.name %></a>
<% for _, post in ipairs(posts) do %>
<div id="post-<%= post.id %>">
<img src="<%= post.avatar_path or "/avatars/default.webp" %>"><br>
<a href="<%= url_for("user", {username = post.username}) %>"><%= post.username %></a>
<div><p><%- post.content %></p></div>
<a href="#post-<%= post.id %>">permalink</a>
</div>
<% end %>
<nav id="topnav">
<span>
<% if user:is_logged_in() then -%>
Welcome, <a href="<%= url_for("user", {username = user.username}) %>"><%= user.username %></a>
<% else -%>
Welcome, guest. Please <a href="<%= url_for("user_login") %>">log in</a>
<% end -%>
</span>
</nav>
<main>
<nav id="threadnav">
<h1 class="thread-title"><%= thread.title %></h1>
<span>Posted in <a href="<%= url_for("topic", {slug = topic.slug}) %>"><%= topic.name %></a></span>
</nav>
<% for i, post in ipairs(posts) do %>
<% render("views.threads.post", {post = post, is_latest = i == #posts}) %>
<% end %>
</main>
<nav id="bottomnav">
<% render("views.common.pagination", {page_count = pages, current_page = page}) %>
</nav>
<% if not user:is_guest() then %>
<h1>Respond to "<%= thread.title %>"</h1>
@ -16,12 +29,3 @@
<input type="submit" value="Reply">
</form>
<% end %>
<span>
<% for i = 1, math.max(pages, 1) do %>
<% if i == page then %>
<%= tostring(i)%>
<% else %>
<a href="?page=<%= i %>"><%= tostring(i)%></a>
<% end %>
<% end %>
</span>