From 22d96bbd8d2f3c63328e0beb4e192eb9bf3d5ce3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 13 Oct 2024 22:23:59 +0200 Subject: Format human dates in view templates rather than in server queries. --- views/contacts.pug | 2 +- views/forum_view.pug | 2 +- views/games_active.pug | 2 +- views/head.pug | 12 ++++++------ views/message_inbox.pug | 2 +- views/message_outbox.pug | 2 +- views/message_read.pug | 2 +- views/search_user.pug | 2 +- views/user.pug | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) (limited to 'views') 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) 📝 a.red(href="/contacts/remove/"+who.name) ❌ 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: Nobody 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 -- cgit v1.2.3