use 'me' instead of 'user' consistently

This commit is contained in:
Lera Elvoé 2025-05-20 14:28:23 +03:00
parent 82b25946a0
commit 3bd474d7fe
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
9 changed files with 23 additions and 23 deletions

View File

@ -23,6 +23,7 @@ app:get("thread_create", "/create", function(self)
end
self.all_topics = all_topics
self.page_title = "creating thread"
self.me = user
return {render = "threads.create"}
end)
@ -90,7 +91,7 @@ app:get("thread", "/:slug", function(self)
LIMIT ? OFFSET ?
]], thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
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.page_title = thread.title

View File

@ -21,7 +21,7 @@ local ThreadCreateError = {
app:get("all_topics", "", function(self)
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"}
end)
@ -32,6 +32,7 @@ app:get("topic_create", "/create", function(self)
end
self.page_title = "creating topic"
self.me = user
return {render = "topics.create"}
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)
local user = util.get_logged_in_user_or_transient(self)
print(topic.is_locked, type(topic.is_locked))
self.user = user
self.me = user
self.ThreadCreateError = ThreadCreateError
self.thread_create_error = ThreadCreateError.OK
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")}
end
self.topic = topic
self.me = user
self.page_title = "editing topic " .. topic.name
return {render = "topics.edit"}

View File

@ -131,8 +131,7 @@ app:get("user_delete_confirm", "/:username/delete_confirm", function(self)
self.err = self.session.flash.error
self.session.flash = {}
end
self.user = target_user
self.me = target_user
self.page_title = "confirm deletion"
return {render = "user.delete_confirm"}
@ -212,8 +211,7 @@ app:get("user_settings", "/:username/settings", function(self)
self.flash_msg = flash.error
end
end
self.user = target_user
self.me = target_user
self.page_title = "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})}
end)
return app
return app

View File

@ -4,8 +4,8 @@
<a href="<%= url_for("all_topics") %>">All topics</a>
</span>
<span>
<% if user:is_logged_in() then -%>
Welcome, <a href="<%= url_for("user", {username = user.username}) %>"><%= user.username %></a>
<% if me:is_logged_in() then -%>
Welcome, <a href="<%= url_for("user", {username = me.username}) %>"><%= me.username %></a>
<% else -%>
Welcome, guest. Please <a href="<%= url_for("user_login") %>">log in</a>
<% end -%>

View File

@ -1,4 +1,4 @@
<% render("views.common.topnav", {user = user}) -%>
<% render("views.common.topnav") -%>
<main>
<nav id="threadnav">
<h1 class="thread-title"><%= thread.title %></h1>
@ -13,7 +13,7 @@
<% render("views.common.pagination", {page_count = pages, current_page = page}) %>
</nav>
<% if not user:is_guest() then %>
<% if not me: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>

View File

@ -22,7 +22,7 @@
<p>This topic is locked.</p>
<% end %>
<% if user:is_mod() then %>
<% if me:is_mod() 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}) %>">

View File

@ -11,6 +11,6 @@
<% end %>
<% end %>
</ul>
<% if user:is_mod() then %>
<% if me:is_mod() then %>
<a href="<%= url_for("topic_create") %>">Create new topic</a>
<% end %>

View File

@ -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>If you are sure, please type your password below.</p>
@ -6,7 +6,7 @@
<h2><%= err %></h2>
<% 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 class="critical" type="submit" value="Delete my account (NO UNDO)">
</form>

View File

@ -2,19 +2,19 @@
<% if flash_msg then %>
<h2><%= flash_msg %></h2>
<% end %>
<form method="post" action="<%= url_for("user_set_avatar", {username = user.username}) %>" enctype="multipart/form-data">
<img src="<%= avatar_url(user) %>"><br>
<form method="post" action="<%= url_for("user_set_avatar", {username = me.username}) %>" enctype="multipart/form-data">
<img src="<%= avatar_url(me) %>"><br>
<input id="file" type="file" name="avatar" accept="image/*">
<input type="submit" value="Update avatar">
<% if not user:is_default_avatar() then %>
<input type="submit" value="Clear avatar" formaction="<%= url_for("user_clear_avatar", {username = user.username}) %>">
<% if not me:is_default_avatar() then %>
<input type="submit" value="Clear avatar" formaction="<%= url_for("user_clear_avatar", {username = me.username}) %>">
<% end %>
<br>
</form>
<form method="post" action="">
<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">
</form>
<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>