use 'me' instead of 'user' consistently
This commit is contained in:
parent
82b25946a0
commit
3bd474d7fe
@ -23,6 +23,7 @@ app:get("thread_create", "/create", function(self)
|
|||||||
end
|
end
|
||||||
self.all_topics = all_topics
|
self.all_topics = all_topics
|
||||||
self.page_title = "creating thread"
|
self.page_title = "creating thread"
|
||||||
|
self.me = user
|
||||||
return {render = "threads.create"}
|
return {render = "threads.create"}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ app:get("thread", "/:slug", function(self)
|
|||||||
LIMIT ? OFFSET ?
|
LIMIT ? OFFSET ?
|
||||||
]], thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
|
]], thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
|
||||||
self.topic = Topics:find(thread.topic_id)
|
self.topic = Topics:find(thread.topic_id)
|
||||||
self.user = util.get_logged_in_user_or_transient(self)
|
self.me = util.get_logged_in_user_or_transient(self)
|
||||||
self.posts = posts
|
self.posts = posts
|
||||||
|
|
||||||
self.page_title = thread.title
|
self.page_title = thread.title
|
||||||
|
@ -21,7 +21,7 @@ local ThreadCreateError = {
|
|||||||
|
|
||||||
app:get("all_topics", "", function(self)
|
app:get("all_topics", "", function(self)
|
||||||
self.topic_list = db.query("select * from topics limit 25;")
|
self.topic_list = db.query("select * from topics limit 25;")
|
||||||
self.user = util.get_logged_in_user(self) or util.TransientUser
|
self.me = util.get_logged_in_user_or_transient(self)
|
||||||
return {render = "topics.topics"}
|
return {render = "topics.topics"}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -32,6 +32,7 @@ app:get("topic_create", "/create", function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.page_title = "creating topic"
|
self.page_title = "creating topic"
|
||||||
|
self.me = user
|
||||||
|
|
||||||
return {render = "topics.create"}
|
return {render = "topics.create"}
|
||||||
end)
|
end)
|
||||||
@ -67,7 +68,7 @@ app:get("topic", "/:slug", function(self)
|
|||||||
self.threads_list = db.query("SELECT * FROM threads WHERE topic_id = ? ORDER BY is_stickied DESC, created_at DESC", topic.id)
|
self.threads_list = db.query("SELECT * FROM threads WHERE topic_id = ? ORDER BY is_stickied DESC, created_at DESC", topic.id)
|
||||||
local user = util.get_logged_in_user_or_transient(self)
|
local user = util.get_logged_in_user_or_transient(self)
|
||||||
print(topic.is_locked, type(topic.is_locked))
|
print(topic.is_locked, type(topic.is_locked))
|
||||||
self.user = user
|
self.me = user
|
||||||
self.ThreadCreateError = ThreadCreateError
|
self.ThreadCreateError = ThreadCreateError
|
||||||
self.thread_create_error = ThreadCreateError.OK
|
self.thread_create_error = ThreadCreateError.OK
|
||||||
if user:is_logged_in_guest() then
|
if user:is_logged_in_guest() then
|
||||||
@ -95,7 +96,7 @@ app:get("topic_edit", "/:slug/edit", function(self)
|
|||||||
return {redirect_to = self:url_for("all_topics")}
|
return {redirect_to = self:url_for("all_topics")}
|
||||||
end
|
end
|
||||||
self.topic = topic
|
self.topic = topic
|
||||||
|
self.me = user
|
||||||
self.page_title = "editing topic " .. topic.name
|
self.page_title = "editing topic " .. topic.name
|
||||||
|
|
||||||
return {render = "topics.edit"}
|
return {render = "topics.edit"}
|
||||||
|
@ -131,8 +131,7 @@ app:get("user_delete_confirm", "/:username/delete_confirm", function(self)
|
|||||||
self.err = self.session.flash.error
|
self.err = self.session.flash.error
|
||||||
self.session.flash = {}
|
self.session.flash = {}
|
||||||
end
|
end
|
||||||
self.user = target_user
|
self.me = target_user
|
||||||
|
|
||||||
self.page_title = "confirm deletion"
|
self.page_title = "confirm deletion"
|
||||||
|
|
||||||
return {render = "user.delete_confirm"}
|
return {render = "user.delete_confirm"}
|
||||||
@ -212,8 +211,7 @@ app:get("user_settings", "/:username/settings", function(self)
|
|||||||
self.flash_msg = flash.error
|
self.flash_msg = flash.error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.user = target_user
|
self.me = target_user
|
||||||
|
|
||||||
self.page_title = "settings"
|
self.page_title = "settings"
|
||||||
|
|
||||||
return {render = "user.settings"}
|
return {render = "user.settings"}
|
||||||
@ -440,4 +438,4 @@ app:post("guest_user", "/guest_user/:user_id", function(self)
|
|||||||
return {redirect_to = self:url_for("user", {username = target_user.username})}
|
return {redirect_to = self:url_for("user", {username = target_user.username})}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
<a href="<%= url_for("all_topics") %>">All topics</a>
|
<a href="<%= url_for("all_topics") %>">All topics</a>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<% if user:is_logged_in() then -%>
|
<% if me:is_logged_in() then -%>
|
||||||
Welcome, <a href="<%= url_for("user", {username = user.username}) %>"><%= user.username %></a>
|
Welcome, <a href="<%= url_for("user", {username = me.username}) %>"><%= me.username %></a>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
Welcome, guest. Please <a href="<%= url_for("user_login") %>">log in</a>
|
Welcome, guest. Please <a href="<%= url_for("user_login") %>">log in</a>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<% render("views.common.topnav", {user = user}) -%>
|
<% render("views.common.topnav") -%>
|
||||||
<main>
|
<main>
|
||||||
<nav id="threadnav">
|
<nav id="threadnav">
|
||||||
<h1 class="thread-title"><%= thread.title %></h1>
|
<h1 class="thread-title"><%= thread.title %></h1>
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<% render("views.common.pagination", {page_count = pages, current_page = page}) %>
|
<% render("views.common.pagination", {page_count = pages, current_page = page}) %>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<% if not user:is_guest() then %>
|
<% if not me:is_guest() then %>
|
||||||
<h1>Respond to "<%= thread.title %>"</h1>
|
<h1>Respond to "<%= thread.title %>"</h1>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<textarea id="post_content" name="post_content" placeholder="Response body" required></textarea><br>
|
<textarea id="post_content" name="post_content" placeholder="Response body" required></textarea><br>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<p>This topic is locked.</p>
|
<p>This topic is locked.</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if user:is_mod() then %>
|
<% if me:is_mod() then %>
|
||||||
<br>
|
<br>
|
||||||
<a href="<%= url_for("topic_edit", {slug = topic.slug}) %>">Edit topic</a>
|
<a href="<%= url_for("topic_edit", {slug = topic.slug}) %>">Edit topic</a>
|
||||||
<form method="post" action="<%= url_for("topic_edit", {slug = topic.slug}) %>">
|
<form method="post" action="<%= url_for("topic_edit", {slug = topic.slug}) %>">
|
||||||
|
@ -11,6 +11,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<% if user:is_mod() then %>
|
<% if me:is_mod() then %>
|
||||||
<a href="<%= url_for("topic_create") %>">Create new topic</a>
|
<a href="<%= url_for("topic_create") %>">Create new topic</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<h1>Are you sure you want to delete your account, <%= user.username %>?</h1>
|
<h1>Are you sure you want to delete your account, <%= me.username %>?</h1>
|
||||||
<p>This cannot be undone. This will not delete your posts, only anonymize them.</p>
|
<p>This cannot be undone. This will not delete your posts, only anonymize them.</p>
|
||||||
<p>If you are sure, please type your password below.</p>
|
<p>If you are sure, please type your password below.</p>
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
<h2><%= err %></h2>
|
<h2><%= err %></h2>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<form method="post" action="<%= url_for("user_delete", {username = user.username}) %>">
|
<form method="post" action="<%= url_for("user_delete", {username = me.username}) %>">
|
||||||
<input type="password" name="password" id="password" autocomplete="current-password" placeholder="Password" required><br>
|
<input type="password" name="password" id="password" autocomplete="current-password" placeholder="Password" required><br>
|
||||||
<input class="critical" type="submit" value="Delete my account (NO UNDO)">
|
<input class="critical" type="submit" value="Delete my account (NO UNDO)">
|
||||||
</form>
|
</form>
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
<% if flash_msg then %>
|
<% if flash_msg then %>
|
||||||
<h2><%= flash_msg %></h2>
|
<h2><%= flash_msg %></h2>
|
||||||
<% end %>
|
<% end %>
|
||||||
<form method="post" action="<%= url_for("user_set_avatar", {username = user.username}) %>" enctype="multipart/form-data">
|
<form method="post" action="<%= url_for("user_set_avatar", {username = me.username}) %>" enctype="multipart/form-data">
|
||||||
<img src="<%= avatar_url(user) %>"><br>
|
<img src="<%= avatar_url(me) %>"><br>
|
||||||
<input id="file" type="file" name="avatar" accept="image/*">
|
<input id="file" type="file" name="avatar" accept="image/*">
|
||||||
<input type="submit" value="Update avatar">
|
<input type="submit" value="Update avatar">
|
||||||
<% if not user:is_default_avatar() then %>
|
<% if not me:is_default_avatar() then %>
|
||||||
<input type="submit" value="Clear avatar" formaction="<%= url_for("user_clear_avatar", {username = user.username}) %>">
|
<input type="submit" value="Clear avatar" formaction="<%= url_for("user_clear_avatar", {username = me.username}) %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<br>
|
<br>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" action="">
|
<form method="post" action="">
|
||||||
<label for="status">Status</label>
|
<label for="status">Status</label>
|
||||||
<input type="text" id="status" name="status" value="<%= user.status %>" maxlength="30"><br>
|
<input type="text" id="status" name="status" value="<%= me.status %>" maxlength="30"><br>
|
||||||
<input type="submit" value="Save status">
|
<input type="submit" value="Save status">
|
||||||
</form>
|
</form>
|
||||||
<br>
|
<br>
|
||||||
<a class="linkbutton critical" href="<%= url_for("user_delete_confirm", {username = user.username}) %>">Delete account</a>
|
<a class="linkbutton critical" href="<%= url_for("user_delete_confirm", {username = me.username}) %>">Delete account</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user