summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-02-02 18:19:33 -0600
committerGitHub <noreply@github.com>2019-02-02 18:19:33 -0600
commita1af27b12529bf732af55047a135ddaa67b8af8d (patch)
treeddcce227ac22445d27deab5b42694a164485dcad
parent9989c8100ae73b1f2cdfb409e66142b63d12142b (diff)
parentceaddbc8211b727c07bc47aa77a9cac431702fbc (diff)
downloadinvidious-a1af27b12529bf732af55047a135ddaa67b8af8d.tar.gz
invidious-a1af27b12529bf732af55047a135ddaa67b8af8d.tar.bz2
invidious-a1af27b12529bf732af55047a135ddaa67b8af8d.zip
Merge pull request #334 from aaferrari/master
Color change in the links and several improvements in the comments
-rw-r--r--assets/css/default.css42
-rw-r--r--assets/css/lighttheme.css2
-rw-r--r--locales/en-US.json6
-rw-r--r--src/invidious/comments.cr44
4 files changed, 88 insertions, 6 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index 244a5edd..800d529a 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -1,3 +1,43 @@
+.channel-owner {
+ background-color: #008BEC;
+ color: #fff;
+ border-radius: 9px;
+ padding: 1px 6px;
+}
+
+.creator-heart-container {
+ display: inline-block;
+ padding: 0px 7px 6px 0px;
+ margin: 0px -7px -4px 0px;
+}
+
+.creator-heart {
+ position: relative;
+ width: 16px;
+ height: 16px;
+ border: 2px none;
+}
+
+.creator-heart-background-hearted {
+ width: 16px;
+ height: 16px;
+ padding: 0px;
+ position: relative;
+}
+
+.creator-heart-small-hearted {
+ position: absolute;
+ right: -7px;
+ bottom: -4px;
+}
+
+.creator-heart-small-container {
+ position: relative;
+ width: 13px;
+ height: 13px;
+ color: rgb(255, 0, 0);
+}
+
.h-box {
padding-left: 1em;
padding-right: 1em;
@@ -23,7 +63,7 @@ div {
}
button.pure-button-primary,
-a.pure-button-primary {
+a.pure-button-primary, .channel-owner:hover {
background-color: #a0a0a0;
color: rgba(35, 35, 35, 1);
}
diff --git a/assets/css/lighttheme.css b/assets/css/lighttheme.css
index 34bb9fc1..1ecd2bd0 100644
--- a/assets/css/lighttheme.css
+++ b/assets/css/lighttheme.css
@@ -4,6 +4,6 @@ a:active {
}
a {
- color: #303030;
+ color: #61809b;
text-decoration: none;
}
diff --git a/locales/en-US.json b/locales/en-US.json
index ccc01458..20fc019e 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -270,5 +270,9 @@
"News": "News",
"Movies": "Movies",
"Download": "Download",
- "Download as: ": "Download as: "
+ "Download as: ": "Download as: ",
+ "%A %B %-d, %Y": "%A %B %-d, %Y",
+ "(edited)": "(edited)",
+ "Youtube permalink of the comment": "Youtube permalink of the comment",
+ "`x` marked it with a ❤": "`x` marked it with a ❤"
}
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 87065b5f..e6d74d1d 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -158,6 +158,8 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale)
comment_count = body["header"]["commentsHeaderRenderer"]["countText"]["simpleText"].as_s.delete("Comments,").to_i
json.field "commentCount", comment_count
end
+
+ json.field "videoId", id
json.field "comments" do
json.array do
@@ -209,7 +211,14 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale)
json.field "authorUrl", ""
end
- published = decode_date(node_comment["publishedTimeText"]["runs"][0]["text"].as_s.rchop(" (edited)"))
+ published_text = node_comment["publishedTimeText"]["runs"][0]["text"].as_s
+ published = decode_date(published_text.rchop(" (edited)"))
+
+ if published_text.includes?(" (edited)")
+ json.field "isEdited", true
+ else
+ json.field "isEdited", false
+ end
json.field "content", content
json.field "contentHtml", content_html
@@ -217,6 +226,17 @@ def fetch_youtube_comments(id, continuation, proxies, format, locale)
json.field "publishedText", translate(locale, "`x` ago", recode_date(published))
json.field "likeCount", node_comment["likeCount"]
json.field "commentId", node_comment["commentId"]
+ json.field "authorIsChannelOwner", node_comment["authorIsChannelOwner"]
+
+ if node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]?
+ hearth_data = node_comment["actionButtons"]["commentActionButtonsRenderer"]["creatorHeart"]["creatorHeartRenderer"]["creatorThumbnail"]
+ json.field "creatorHeart" do
+ json.object do
+ json.field "creatorThumbnail", hearth_data["thumbnails"][-1]["url"]
+ json.field "creatorName", hearth_data["accessibility"]["accessibilityData"]["label"]
+ end
+ end
+ end
if node_replies && !response["commentRepliesContinuation"]?
reply_count = node_replies["moreText"]["simpleText"].as_s.delete("View all reply replies,")
@@ -326,12 +346,30 @@ def template_youtube_comments(comments, locale)
<div class="pure-u-20-24 pure-u-md-22-24">
<p>
<b>
- <a href="#{child["authorUrl"]}">#{child["author"]}</a>
+ <a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{child["author"]}</a>
</b>
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))}
+ <span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale,"%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64)))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
+ |
+ <a href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "Youtube permalink of the comment")}">[YT]</a>
|
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
+ END_HTML
+
+ if child["creatorHeart"]?
+ html += <<-END_HTML
+ <span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
+ <div class="creator-heart">
+ <img class="creator-heart-background-hearted" src="#{child["creatorHeart"]["creatorThumbnail"]}"></img>
+ <div class="creator-heart-small-hearted">
+ <div class="creator-heart-small-container">🖤</div>
+ </div>
+ </div>
+ </span>
+ END_HTML
+ end
+
+ html += <<-END_HTML
</p>
#{replies_html}
</div>