Compare commits
No commits in common. "cf66336e78fbbd75f7dcb9d5ca5967e7b7cb59e1" and "aa49d8e4b9b21af36c62e3a92781b4578ea87ebe" have entirely different histories.
cf66336e78
...
aa49d8e4b9
9
app.lua
9
app.lua
@ -17,13 +17,8 @@ app.layout = require "views.base"
|
||||
|
||||
app.cookie_attributes = function (self, name, value)
|
||||
if name == config.session_name then
|
||||
if not self.session.queue_delete then
|
||||
local expires = date(true):adddays(30):fmt("${http}")
|
||||
return "Expires="..expires.."; Path=/; HttpOnly; Secure"
|
||||
else
|
||||
local expires = date(true):addseconds(-30):fmt("${http}")
|
||||
return "Expires="..expires.."; Path=/; HttpOnly; Secure"
|
||||
end
|
||||
local expires = date(true):adddays(30):fmt("${http}")
|
||||
return "Expires="..expires.."; Path=/; HttpOnly; Secure"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -94,7 +94,6 @@ app:get("thread", "/:slug", function(self)
|
||||
"WHERE posts.thread_id = ? ORDER BY posts.created_at ASC LIMIT ? OFFSET ?")
|
||||
local posts = db.query(query, thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
|
||||
self.topic = Topics:find(thread.topic_id)
|
||||
self.other_topics = db.query("SELECT topics.id, topics.name FROM topics")
|
||||
self.me = util.get_logged_in_user_or_transient(self)
|
||||
self.posts = posts
|
||||
|
||||
@ -170,40 +169,4 @@ app:post("thread_sticky", "/:slug/sticky", function(self)
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end)
|
||||
|
||||
app:post("thread_move", "/:slug/move", function(self)
|
||||
local user = util.get_logged_in_user(self)
|
||||
if not user then
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
|
||||
if not user:is_mod() then
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
|
||||
if not self.params.new_topic_id then
|
||||
util.inject_err_infobox(self, "Thread already in this topic.")
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
|
||||
local new_topic = Topics:find({id = self.params.new_topic_id})
|
||||
if not new_topic then
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
local thread = Threads:find({slug = self.params.slug})
|
||||
if not thread then
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
if new_topic.id == thread.topic_id then
|
||||
util.inject_err_infobox(self, "Thread already in this topic.")
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end
|
||||
|
||||
local old_topic = Topics:find({id = thread.topic_id})
|
||||
|
||||
thread:update({topic_id = new_topic.id})
|
||||
util.inject_infobox(self, ("Thread moved from \"%s\" to \"%s\"."):format(old_topic.name, new_topic.name))
|
||||
|
||||
return {redirect_to = self:url_for("thread", {slug = self.params.slug})}
|
||||
end)
|
||||
|
||||
return app
|
||||
|
@ -126,10 +126,8 @@ app:post("user_delete", "/:username/delete", function(self)
|
||||
return {redirect_to = self:url_for("user_delete_confirm", {username = me.username})}
|
||||
end
|
||||
|
||||
local session = Sessions:find({key = self.session.session_key})
|
||||
session:delete()
|
||||
self.session.queue_delete = true
|
||||
util.transfer_and_delete_user(target_user)
|
||||
util.inject_infobox(self, "Your account has been added to the deletion queue.")
|
||||
return {redirect_to = self:url_for("user_signup")}
|
||||
end)
|
||||
|
||||
@ -381,7 +379,7 @@ app:post("user_logout", "/logout", function (self)
|
||||
|
||||
local session = Sessions:find({key = self.session.session_key})
|
||||
session:delete()
|
||||
self.session.queue_delete = true
|
||||
self.session = nil
|
||||
return {redirect_to = self:url_for("user_login")}
|
||||
end)
|
||||
|
||||
|
@ -25,15 +25,6 @@
|
||||
<input type=hidden value="<%= not is_stickied %>" name="target_op">
|
||||
<input class="warn" type="submit" value="<%= is_stickied and "Unsticky thread" or "Sticky thread" %>">
|
||||
</form>
|
||||
<form class="modform" action="<%= url_for("thread_move", {slug = thread.slug}) %>" method="post">
|
||||
<label for="new_topic_id">Move to topic:</label>
|
||||
<select style="width:200px;" id="new_topic_id" name="new_topic_id" autocomplete="off">
|
||||
<% for _, topic in ipairs(other_topics) do %>
|
||||
<option value="<%= topic.id %>" <%- thread.topic_id == topic.id and "selected disabled" or "" %>><%= topic.name %></option>
|
||||
<% end %>
|
||||
</select>
|
||||
<input class="warn" type="submit" value="Move thread">
|
||||
</form>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
Loading…
Reference in New Issue
Block a user