show timestamps in local time
This commit is contained in:
parent
873a4c0c15
commit
8ea9afd39d
10
js/date-fmt.js
Normal file
10
js/date-fmt.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const timestampSpans = document.getElementsByClassName("timestamp");
|
||||||
|
for (let timestampSpan of timestampSpans) {
|
||||||
|
const timestamp = parseInt(timestampSpan.dataset.utc);
|
||||||
|
if (!isNaN(timestamp)) {
|
||||||
|
const date = new Date(timestamp * 1000);
|
||||||
|
timestampSpan.textContent = date.toLocaleString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -17,5 +17,6 @@
|
|||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="/static/js/copy-code.js"></script>
|
<script src="/static/js/copy-code.js"></script>
|
||||||
|
<script src="/static/js/date-fmt.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
1
views/common/timestamp.etlua
Normal file
1
views/common/timestamp.etlua
Normal file
@ -0,0 +1 @@
|
|||||||
|
<span class="timestamp" data-utc="<%= timestamp %>"><%= os.date("%c", timestamp) %></span>
|
@ -22,9 +22,9 @@
|
|||||||
%>
|
%>
|
||||||
<a href="<%= post_url %>" title="Permalink"><i>
|
<a href="<%= post_url %>" title="Permalink"><i>
|
||||||
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
||||||
Edited at <%= os.date("%c", post.edited_at) %>
|
Edited at <% render("views.common.timestamp", {timestamp = post.edited_at}) -%>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
Posted on <%= os.date("%c", post.created_at) %>
|
Posted on <% render("views.common.timestamp", {timestamp = post.created_at}) -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</i></a>
|
</i></a>
|
||||||
<span>
|
<span>
|
||||||
@ -47,8 +47,8 @@
|
|||||||
end
|
end
|
||||||
if show_reply then
|
if show_reply then
|
||||||
local d = post.created_at < post.edited_at and post.edited_at or post.created_at
|
local d = post.created_at < post.edited_at and post.edited_at or post.created_at
|
||||||
local quote_src_text = ("On [url=%s]%s[/url], [url=%s]%s[/url] said:"):format(
|
local quote_src_text = ("[url=%s]%s said:[/url]"):format(
|
||||||
post_url, os.date("%c", d), url_for("user", {username = post.username}), post.username
|
post_url, post.username
|
||||||
)
|
)
|
||||||
local reply_text = ("%s\n[quote]%s[/quote]\n---\n\n"):format(quote_src_text, post.original_markup)
|
local reply_text = ("%s\n[quote]%s[/quote]\n---\n\n"):format(quote_src_text, post.original_markup)
|
||||||
%>
|
%>
|
||||||
|
@ -48,11 +48,11 @@
|
|||||||
<span class="thread-title"><a href="<%= url_for("thread", {slug = thread.slug}) %>"><%= thread.title %></a></span>
|
<span class="thread-title"><a href="<%= url_for("thread", {slug = thread.slug}) %>"><%= thread.title %></a></span>
|
||||||
•
|
•
|
||||||
Started by <a href=<%= url_for("user", {username = thread.started_by}) %>><%= thread.started_by %></a>
|
Started by <a href=<%= url_for("user", {username = thread.started_by}) %>><%= thread.started_by %></a>
|
||||||
on <%= os.date("%c", thread.created_at) %>
|
on <% render("views.common.timestamp", {timestamp = thread.created_at}) -%>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
Latest post by <a href="<%= url_for("user", {username = thread.latest_post_username}) %>"><%= thread.latest_post_username %></a>
|
Latest post by <a href="<%= url_for("user", {username = thread.latest_post_username}) %>"><%= thread.latest_post_username %></a>
|
||||||
<a href="<%= url_for("thread", {slug = thread.slug}, {after = thread.latest_post_id}) .. "#post-" .. thread.latest_post_id %>">on <%= os.date("%c", thread.latest_post_created_at) %></a>:
|
<a href="<%= url_for("thread", {slug = thread.slug}, {after = thread.latest_post_id}) .. "#post-" .. thread.latest_post_id %>">on <% render("views.common.timestamp", {timestamp = thread.latest_post_created_at}) -%></a>:
|
||||||
</span>
|
</span>
|
||||||
<span class="thread-info-post-preview">
|
<span class="thread-info-post-preview">
|
||||||
<%- thread.latest_post_content %>
|
<%- thread.latest_post_content %>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<%= topic.description %>
|
<%= topic.description %>
|
||||||
<% if topic.latest_thread_username then %>
|
<% if topic.latest_thread_username then %>
|
||||||
<span>
|
<span>
|
||||||
Latest thread: <a href="<%= url_for("thread", {slug = topic.latest_thread_slug}) %>"><%= topic.latest_thread_title %></a> by <a href="<%= url_for("user", {username = topic.latest_thread_username}) %>"><%= topic.latest_thread_username %></a> on <%= os.date("%c", topic.latest_thread_created_at) %>
|
Latest thread: <a href="<%= url_for("thread", {slug = topic.latest_thread_slug}) %>"><%= topic.latest_thread_title %></a> by <a href="<%= url_for("user", {username = topic.latest_thread_username}) %>"><%= topic.latest_thread_username %></a> on <% render("views.common.timestamp", {timestamp = topic.latest_thread_created_at}) -%>
|
||||||
</span>
|
</span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<i>No threads yet.</i>
|
<i>No threads yet.</i>
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
<div class="post-info">
|
<div class="post-info">
|
||||||
<div><a href="<%= url_for("thread", {slug = post.thread_slug}, {after = post.id}) .. "#post-" .. post.id %>" title="Permalink"><i>
|
<div><a href="<%= url_for("thread", {slug = post.thread_slug}, {after = post.id}) .. "#post-" .. post.id %>" title="Permalink"><i>
|
||||||
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
||||||
Edited in <%= post.thread_title %> at <%= os.date("%c", post.edited_at) %>
|
Edited in <%= post.thread_title %> at <% render("views.common.timestamp", {timestamp = post.edited_at}) -%>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
Posted in <%= post.thread_title %> on <%= os.date("%c", post.created_at) %>
|
Posted in <%= post.thread_title %> on <% render("views.common.timestamp", {timestamp = post.created_at}) -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</i></a></div>
|
</i></a></div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,12 +48,12 @@
|
|||||||
<div class="darkbg">
|
<div class="darkbg">
|
||||||
<h1>Moderator controls</h2>
|
<h1>Moderator controls</h2>
|
||||||
<% if user:is_guest() then %>
|
<% if user:is_guest() then %>
|
||||||
<p>This user is a guest. They signed up on <%= os.date("%c", user.created_at) %>.</p>
|
<p>This user is a guest. They signed up on <% render("views.common.timestamp", {timestamp = user.created_at}) -%>.</p>
|
||||||
<form class="modform" method="post" action="<%= url_for("confirm_user", {user_id = user.id}) %>">
|
<form class="modform" method="post" action="<%= url_for("confirm_user", {user_id = user.id}) %>">
|
||||||
<input type="submit" value="Confirm user">
|
<input type="submit" value="Confirm user">
|
||||||
</form>
|
</form>
|
||||||
<% else %> <% --[[ user is not guest ]] %>
|
<% else %> <% --[[ user is not guest ]] %>
|
||||||
<p>This user signed up on <%= os.date("%c", user.created_at) %> and was confirmed on <%= os.date("%c", user.confirmed_on) %>.</p>
|
<p>This user signed up on <% render("views.common.timestamp", {timestamp = user.created_at}) -%> and was confirmed on <% render("views.common.timestamp", {timestamp = user.confirmed_on}) %>.</p>
|
||||||
<% if user.permission < me.permission then %>
|
<% if user.permission < me.permission then %>
|
||||||
<form class="modform" method="post" action="<%= url_for("guest_user", {user_id = user.id}) %>">
|
<form class="modform" method="post" action="<%= url_for("guest_user", {user_id = user.id}) %>">
|
||||||
<input class="warn" type="submit" value="Demote user to guest (soft ban)">
|
<input class="warn" type="submit" value="Demote user to guest (soft ban)">
|
||||||
|
Loading…
Reference in New Issue
Block a user