summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.js21
-rw-r--r--views/contacts.pug2
-rw-r--r--views/forum_view.pug2
-rw-r--r--views/games_active.pug2
-rw-r--r--views/head.pug12
-rw-r--r--views/message_inbox.pug2
-rw-r--r--views/message_outbox.pug2
-rw-r--r--views/message_read.pug2
-rw-r--r--views/search_user.pug2
-rw-r--r--views/user.pug4
10 files changed, 15 insertions, 36 deletions
diff --git a/server.js b/server.js
index 125d468..b3a1cfb 100644
--- a/server.js
+++ b/server.js
@@ -745,8 +745,6 @@ app.post("/change-about", must_be_logged_in, function (req, res) {
app.get("/user/:who_name", function (req, res) {
let who = SQL_SELECT_USER_PROFILE.get(req.params.who_name)
if (who) {
- who.ctime = human_date(who.ctime)
- who.atime = human_date(who.atime)
let games = QUERY_LIST_PUBLIC_GAMES_OF_USER.all({ user_id: who.user_id })
annotate_games(games, 0, null)
let active_pools = TM_POOL_LIST_USER_ACTIVE.all(who.user_id)
@@ -774,7 +772,6 @@ const SQL_SELECT_RELATION = SQL("select relation from contacts where me=? and yo
app.get("/contacts", must_be_logged_in, function (req, res) {
let contacts = SQL_SELECT_CONTACT_LIST.all(req.user.user_id)
- contacts.forEach(user => user.atime = human_date(user.atime))
res.render("contacts.pug", {
user: req.user,
friends: contacts.filter(user => user.relation > 0),
@@ -810,8 +807,6 @@ app.get("/contacts/search", must_be_logged_in, function (req, res) {
if (!q.includes("%"))
q = "%" + q + "%"
let results = SQL_SELECT_USER_BY_SEARCH.all(q)
- for (let item of results)
- item.atime = human_date(item.atime)
res.render("search_user.pug", {
user: req.user,
search: req.query.q,
@@ -862,8 +857,6 @@ const MESSAGE_DELETE_ALL_OUTBOX = SQL("UPDATE messages SET is_deleted_from_outbo
app.get("/message/inbox", must_be_logged_in, function (req, res) {
let messages = MESSAGE_LIST_INBOX.all(req.user.user_id)
- for (let i = 0; i < messages.length; ++i)
- messages[i].time = human_date(messages[i].time)
res.render("message_inbox.pug", {
user: req.user,
messages: messages,
@@ -872,8 +865,6 @@ app.get("/message/inbox", must_be_logged_in, function (req, res) {
app.get("/message/outbox", must_be_logged_in, function (req, res) {
let messages = MESSAGE_LIST_OUTBOX.all(req.user.user_id)
- for (let i = 0; i < messages.length; ++i)
- messages[i].time = human_date(messages[i].time)
res.render("message_outbox.pug", {
user: req.user,
messages: messages,
@@ -889,7 +880,6 @@ app.get("/message/read/:message_id", must_be_logged_in, function (req, res) {
MESSAGE_MARK_READ.run(message_id)
req.user.unread --
}
- message.time = human_date(message.time)
message.body = linkify_post(message.body)
res.render("message_read.pug", {
user: req.user,
@@ -1026,8 +1016,6 @@ function show_forum_page(req, res, page) {
threads = FORUM_LIST_THREADS_USER.all(req.user.user_id, FORUM_PAGE_SIZE, FORUM_PAGE_SIZE * (page - 1))
else
threads = FORUM_LIST_THREADS.all(FORUM_PAGE_SIZE, FORUM_PAGE_SIZE * (page - 1))
- for (let thread of threads)
- thread.mtime = human_date(thread.mtime)
res.render("forum_view.pug", {
user: req.user,
threads: threads,
@@ -1063,8 +1051,6 @@ app.get("/forum/thread/:thread_id", function (req, res) {
for (let i = 0; i < posts.length; ++i) {
posts[i].body = linkify_post(posts[i].body)
posts[i].edited = posts[i].mtime !== posts[i].ctime
- posts[i].ctime = human_date(posts[i].ctime)
- posts[i].mtime = human_date(posts[i].mtime)
}
if (req.user)
FORUM_MARK_READ.run(req.user.user_id, thread_id)
@@ -1113,8 +1099,6 @@ app.get("/forum/edit/:post_id", must_be_logged_in, function (req, res) {
let post = FORUM_GET_POST.get(post_id)
if (!post || post.author_id != req.user.user_id)
return res.status(404).send("Invalid post ID.")
- post.ctime = human_date(post.ctime)
- post.mtime = human_date(post.mtime)
res.render("forum_edit.pug", {
user: req.user,
post: post,
@@ -1137,8 +1121,6 @@ app.get("/forum/reply/:post_id", must_be_logged_in, function (req, res) {
let thread = FORUM_GET_THREAD.get(post.thread_id)
post.body = linkify_post(post.body)
post.edited = post.mtime !== post.ctime
- post.ctime = human_date(post.ctime)
- post.mtime = human_date(post.mtime)
res.render("forum_reply.pug", {
user: req.user,
thread: thread,
@@ -1609,9 +1591,6 @@ function annotate_game_info(game, user_id, unread) {
if (your_count === 1)
game.your_role = your_role
}
-
- game.ctime = human_date(game.ctime)
- game.mtime = human_date(game.mtime)
}
function annotate_games(list, user_id, unread) {
diff --git a/views/contacts.pug b/views/contacts.pug
index a3ca8d0..e3c8067 100644
--- a/views/contacts.pug
+++ b/views/contacts.pug
@@ -25,7 +25,7 @@ html
tr
td
a.black(href="/user/"+who.name)= who.name
- td.w= who.atime
+ td.w= human_date(who.atime)
td.w.r
a.blue(href="/message/send/"+who.name) &#x1f4dd;
a.red(href="/contacts/remove/"+who.name) &#x274c;
diff --git a/views/forum_view.pug b/views/forum_view.pug
index c82a2b4..017e49a 100644
--- a/views/forum_view.pug
+++ b/views/forum_view.pug
@@ -29,7 +29,7 @@ html
td
a.black(href="/forum/thread/"+row.thread_id)= row.subject
td.r= row.count
- td.w= row.mtime
+ td.w= human_date(row.mtime)
tfoot
tr
td(colspan=4)
diff --git a/views/games_active.pug b/views/games_active.pug
index eaa1076..f47ae6e 100644
--- a/views/games_active.pug
+++ b/views/games_active.pug
@@ -5,7 +5,7 @@
- let move_games = games.filter(game => game.status === 1 && game.is_opposed && game.your_turn)
- let solo_games = games.filter(game => game.status === 1 && !game.is_opposed)
- let finished_games = games.filter(game => game.status === 2)
-- move_games.sort((a,b)=>a.time_left-b.time_left)
+- move_games.sort((a,b)=> a.mtime < b.mtime ? -1 : a.mtime > b.mtime ? 1 : 0)
doctype html
html
head
diff --git a/views/head.pug b/views/head.pug
index 66e3f58..d9da995 100644
--- a/views/head.pug
+++ b/views/head.pug
@@ -28,10 +28,10 @@ mixin forumpost(row,show_buttons)
.post(id=row.post_id)
.head
.from: b: a.black(href="/user/"+row.author_name)= row.author_name
- .time= row.ctime
+ .time= human_date(row.ctime)
if row.edited
|
- | (edited #{row.mtime})
+ | (edited #{human_date(row.mtime)})
.body!= row.body
if show_buttons && user
.edit
@@ -120,9 +120,9 @@ mixin gamelist(list,hide_title=0)
div Players: <span class="error">Nobody</span>
case item.status
when 0
- div Created: #{item.ctime}
+ div Created: #{human_date(item.ctime)}
when 1
- div Last move: #{item.mtime}
+ div Last move: #{human_date(item.mtime)}
if item.your_turn
if item.time_left <= 0
div Time left: none.
@@ -131,10 +131,10 @@ mixin gamelist(list,hide_title=0)
else if item.time_left <= 5
div Time left: #{ item.time_left | 0 } days
when 2
- div Finished: #{item.mtime}
+ div Finished: #{human_date(item.mtime)}
div Result: !{item.result}
when 3
- div Finished: #{item.mtime}
+ div Finished: #{human_date(item.mtime)}
div Result: !{item.result}
unless hide_title
a(href=`/${item.title_id}`)
diff --git a/views/message_inbox.pug b/views/message_inbox.pug
index 4f02790..d8b6bc1 100644
--- a/views/message_inbox.pug
+++ b/views/message_inbox.pug
@@ -32,7 +32,7 @@ html
tr(class=row.is_read?"read":"unread")
td: a.black(href="/user/"+row.from_name)= row.from_name
td: a.black(href="/message/read/"+row.message_id)= subject
- td.w= row.time
+ td.w= human_date(row.time)
else
tr
td(colspan=3) No messages.
diff --git a/views/message_outbox.pug b/views/message_outbox.pug
index f42ef7f..40cc59d 100644
--- a/views/message_outbox.pug
+++ b/views/message_outbox.pug
@@ -35,7 +35,7 @@ html
tr
td: a.black(href="/user/"+row.to_name)= row.to_name
td.e: a.black(href="/message/read/"+row.message_id)= row.subject
- td.w= row.time
+ td.w= human_date(row.time)
else
tr
td(colspan=3) No messages.
diff --git a/views/message_read.pug b/views/message_read.pug
index f02c2f7..f429f86 100644
--- a/views/message_read.pug
+++ b/views/message_read.pug
@@ -25,7 +25,7 @@ html
div.
From: #[a(href="/user/"+message.from_name)= message.from_name]
To: #[a(href="/user/"+message.to_name)= message.to_name]
- div= message.time
+ div= human_date(message.time)
div.body!= message.body
p
diff --git a/views/search_user.pug b/views/search_user.pug
index bc67cf6..308cc41 100644
--- a/views/search_user.pug
+++ b/views/search_user.pug
@@ -22,7 +22,7 @@ html
tr
td
a.black(href="/user/"+who.name)= who.name
- td.w= who.atime
+ td.w= human_date(who.atime)
else
p.error Nobody found matching "#{search}".
diff --git a/views/user.pug b/views/user.pug
index 06fa91d..f3a30f0 100644
--- a/views/user.pug
+++ b/views/user.pug
@@ -26,8 +26,8 @@ html
if who.about
p.about= who.about
- p Member since #{who.ctime}.
- p Last seen #{who.atime}.
+ p Member since #{human_date(who.ctime)}.
+ p Last seen #{human_date(who.atime)}.
if user && (who.user_id !== user.user_id)
p