summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-13 10:30:27 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-13 10:37:29 -0500
commitf3fde38137855326068379f9183e6df7ff234c82 (patch)
treeb4b7892a8177d137fd42e141fe65abbbe986b603
parentc776e1f82aabea3cdd65f64a2049af3be55ddb3b (diff)
downloadinvidious-f3fde38137855326068379f9183e6df7ff234c82.tar.gz
invidious-f3fde38137855326068379f9183e6df7ff234c82.tar.bz2
invidious-f3fde38137855326068379f9183e6df7ff234c82.zip
Add time published to Reddit comments
-rw-r--r--src/invidious/comments.cr15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 246f3967..c186243c 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -6,12 +6,26 @@ class RedditThing
end
class RedditComment
+ module TimeConverter
+ def self.from_json(value : JSON::PullParser) : Time
+ Time.epoch(value.read_float.to_i)
+ end
+
+ def self.to_json(value : Time, json : JSON::Builder)
+ json.number(value.epoch)
+ end
+ end
+
JSON.mapping({
author: String,
body_html: String,
replies: RedditThing | String,
score: Int32,
depth: Int32,
+ created: {
+ type: Time,
+ converter: RedditComment::TimeConverter,
+ },
})
end
@@ -144,6 +158,7 @@ def template_reddit_comments(root)
<a href="javascript:void(0)" onclick="toggle(this)">[ - ]</a>
<i class="icon ion-ios-thumbs-up"></i> #{score}
<b><a href="https://www.reddit.com/user/#{author}">#{author}</a></b>
+ - #{recode_date(child.created)} ago
</p>
<div>
#{body_html}