add threads n posts
This commit is contained in:
13
views/threads/create.etlua
Normal file
13
views/threads/create.etlua
Normal file
@ -0,0 +1,13 @@
|
||||
<h1>New thread</h1>
|
||||
<form method="post">
|
||||
<label for="topic_id">Topic:</label>
|
||||
<select name="topic_id", id="topic_id" autocomplete="off">
|
||||
<% for _, topic in ipairs(all_topics) do %>
|
||||
<option value="<%= topic.id %>" <%- params.topic_id == tostring(topic.id) and "selected" or "" %>><%= topic.name %></value>
|
||||
<% end %>
|
||||
</select><br>
|
||||
<label for="title">Thread title:</label>
|
||||
<input type="text" id="title" name="title" required><br>
|
||||
<textarea id="initial_post" name="initial_post" placeholder="Post body" required></textarea><br>
|
||||
<input type="submit" value="Create thread">
|
||||
</form>
|
20
views/threads/thread.etlua
Normal file
20
views/threads/thread.etlua
Normal file
@ -0,0 +1,20 @@
|
||||
<% for _, post in ipairs(posts) do %>
|
||||
<div>
|
||||
<img src="<%= post.avatar_path or "/avatars/default.webp" %>">
|
||||
<div><%= post.username %></div>
|
||||
<div><p><%- require("lapis.html").escape(post.content):gsub("\n", "<br>") %></p></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if not user:is_guest() then %>
|
||||
<h1>Respond to "<%= thread.title %>"</h1>
|
||||
<form method="post">
|
||||
<textarea id="post_content" name="post_content" placeholder="Response body" required></textarea><br>
|
||||
<input type="submit" value="Reply">
|
||||
</form>
|
||||
<% end %>
|
||||
<% if next_cursor then %>
|
||||
<a href="<%= url_for('thread', {slug = thread.slug}, {cursor = next_cursor}) %>">
|
||||
Older posts →
|
||||
</a>
|
||||
<% end %>
|
@ -6,7 +6,7 @@
|
||||
<ul>
|
||||
<% for i, v in ipairs(topic_list) do %>
|
||||
<li>
|
||||
<a href=<%= v.slug %>><%= v.name %></a> - <%= v.description %>
|
||||
<a href=<%= url_for("topic", {slug = v.slug}) %>><%= v.name %></a> - <%= v.description %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
Reference in New Issue
Block a user