add topics
This commit is contained in:
6
views/topics/create.etlua
Normal file
6
views/topics/create.etlua
Normal file
@ -0,0 +1,6 @@
|
||||
<h1>Create topic</h1>
|
||||
<form method="post">
|
||||
<input type="text" name="name" id="name" placeholder="Topic name" required><br>
|
||||
<textarea id="description" name="description" placeholder="Topic description" required></textarea><br>
|
||||
<input type="submit" value="Create topic">
|
||||
</form>
|
12
views/topics/edit.etlua
Normal file
12
views/topics/edit.etlua
Normal file
@ -0,0 +1,12 @@
|
||||
<h1>Editing topic <%= topic.name %></h1>
|
||||
<form method="post">
|
||||
<input type="text" name="name" id="name" value="<%= topic.name %>" placeholder="Topic name" required><br>
|
||||
<textarea id="description" name="description" value="<%= topic.description %>" placeholder="Topic description"></textarea><br>
|
||||
<input type="checkbox" id="is_locked" name="is_locked" value="<%= ntob(topic.is_locked) %>">
|
||||
<label for="is_locked">Locked</label><br>
|
||||
<input type="submit" value="Save changes">
|
||||
</form>
|
||||
<form method="get" action="<%= url_for("topic", {slug = topic.slug}) %>">
|
||||
<input type="submit" value="Cancel">
|
||||
</form>
|
||||
<i>Note: to preserve history, you cannot change the topic URL.</i>
|
25
views/topics/topic.etlua
Normal file
25
views/topics/topic.etlua
Normal file
@ -0,0 +1,25 @@
|
||||
<h1><%= topic.name %></h1>
|
||||
<h2><%= topic.description %></h2>
|
||||
<% if #threads_list == 0 then %>
|
||||
<p>There are no threads in this topic.</p>
|
||||
<% end %>
|
||||
|
||||
<% if thread_create_error == ThreadCreateError.OK then %>
|
||||
<a href=<%= url_for("thread_create", nil, {topic_id = topic.id}) %>>New thread</a>
|
||||
<% elseif thread_create_error == ThreadCreateError.GUEST then %>
|
||||
<p>Your account is still pending confirmation by an administrator. You are not able to create a new thread or post at this time.</p>
|
||||
<% elseif thread_create_error == ThreadCreateError.LOGGED_OUT then %>
|
||||
<p>Only logged in users can create threads. <a href="<%= url_for("user_signup") %>">Sign up</a> or <a href="<%= url_for("user_login")%>">log in</a> to create a thread.</p>
|
||||
<% else %>
|
||||
<p>This topic is locked.</p>
|
||||
<% end %>
|
||||
|
||||
<% if user:is_admin() then %>
|
||||
<br>
|
||||
<a href="<%= url_for("topic_edit", {slug = topic.slug}) %>">Edit topic</a>
|
||||
<form method="post" action="<%= url_for("topic_edit", {slug = topic.slug}) %>">
|
||||
<input type="hidden" name="is_locked" value="<%= not ntob(topic.is_locked) %>">
|
||||
<p><%= "This topic is " .. (ntob(topic.is_locked) and "" or "un") .. "locked." %></p>
|
||||
<input type="submit" id="lock" value="<%= ntob(topic.is_locked) and "Unlock" or "Lock" %>">
|
||||
</form>
|
||||
<% end %>
|
16
views/topics/topics.etlua
Normal file
16
views/topics/topics.etlua
Normal file
@ -0,0 +1,16 @@
|
||||
<h1>Topics</h1>
|
||||
|
||||
<% if #topic_list == 0 then %>
|
||||
<p>There are no topics.</p>
|
||||
<% else %>
|
||||
<ul>
|
||||
<% for i, v in ipairs(topic_list) do %>
|
||||
<li>
|
||||
<a href=<%= v.slug %>><%= v.name %></a> - <%= v.description %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if user:is_admin() then %>
|
||||
<a href="<%= url_for("topic_create") %>">Create new topic</a>
|
||||
<% end %>
|
Reference in New Issue
Block a user