add thread view
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Porom</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<% content_for("inner") %>
|
||||
|
27
views/common/pagination.etlua
Normal file
27
views/common/pagination.etlua
Normal file
@ -0,0 +1,27 @@
|
||||
<% local left_start = math.max(1, current_page - 5) %>
|
||||
<% local right_end = math.min(page_count, current_page + 5) %>
|
||||
|
||||
<div class="pager">
|
||||
<span>Page:</span>
|
||||
<% if current_page > 5 then %>
|
||||
<a href="?page=1" class="pagebutton">1</a>
|
||||
<% if left_start > 2 then %>
|
||||
<span class="currentpage">…</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% for i = left_start, current_page - 1 do%>
|
||||
<a href="?page=<%= i %>" class="pagebutton"><%= i %></a>
|
||||
<% end %>
|
||||
<% if page_count > 0 then %>
|
||||
<span class="currentpage"><%= current_page %></span>
|
||||
<% end %>
|
||||
<% for i = current_page + 1, right_end do %>
|
||||
<a href="?page=<%= i %>" class="pagebutton"><%= i %></a>
|
||||
<% end %>
|
||||
<% if right_end < page_count then %>
|
||||
<% if right_end < page_count - 1 then %>
|
||||
<span class="currentpage">…</span>
|
||||
<% end %>
|
||||
<a href="?page=<%= page_count %>" class="pagebutton"><%= page_count %></a>
|
||||
<% end %>
|
||||
</div>
|
26
views/threads/post.etlua
Normal file
26
views/threads/post.etlua
Normal file
@ -0,0 +1,26 @@
|
||||
<div class="post" id="post-<%= post.id %>">
|
||||
<div class="usercard">
|
||||
<a href="<%= url_for("user", {username = post.username}) %>" style="display: contents;">
|
||||
<img src="<%= post.avatar_path or "/avatars/default.webp" %>" class="avatar">
|
||||
</a>
|
||||
<a href="<%= url_for("user", {username = post.username}) %>" class="username-link"><%= post.username %></a>
|
||||
<% if post.status ~= "" then %>
|
||||
<em class="user-status"><%= post.status %></em>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="post-content-container"<%= is_latest and 'id=latest-post' or "" %>>
|
||||
<div class="post-info">
|
||||
<div><a href="<%= "#post-" .. post.id %>" title="Permalink"><i>
|
||||
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
||||
Edited at <%= os.date("%c", post.edited_at) %>
|
||||
<% else -%>
|
||||
Posted at <%= os.date("%c", post.created_at) %>
|
||||
<% end -%>
|
||||
</i></a></div>
|
||||
<div><button>Reply</button></div>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
<%- post.content %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -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>
|
||||
|
Reference in New Issue
Block a user