mirror of
https://github.com/iv-org/invidious
synced 2024-11-28 05:53:28 +01:00
Clean up comment templating
This commit is contained in:
parent
c47f1ae236
commit
6efa6691b1
@ -274,8 +274,7 @@ def fetch_reddit_comments(id, sort_by = "confidence")
|
|||||||
end
|
end
|
||||||
|
|
||||||
def template_youtube_comments(comments, locale, thin_mode)
|
def template_youtube_comments(comments, locale, thin_mode)
|
||||||
html = ""
|
String.build do |html|
|
||||||
|
|
||||||
root = comments["comments"].as_a
|
root = comments["comments"].as_a
|
||||||
root.each do |child|
|
root.each do |child|
|
||||||
if child["replies"]?
|
if child["replies"]?
|
||||||
@ -298,7 +297,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
|||||||
author_thumbnail = ""
|
author_thumbnail = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
|
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
|
||||||
<img style="padding-right:1em;padding-top:1em" src="#{author_thumbnail}">
|
<img style="padding-right:1em;padding-top:1em" src="#{author_thumbnail}">
|
||||||
@ -323,7 +322,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
|||||||
creator_thumbnail = ""
|
creator_thumbnail = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html << <<-END_HTML
|
||||||
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
|
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
|
||||||
<div class="creator-heart">
|
<div class="creator-heart">
|
||||||
<img class="creator-heart-background-hearted" src="#{creator_thumbnail}"></img>
|
<img class="creator-heart-background-hearted" src="#{creator_thumbnail}"></img>
|
||||||
@ -335,7 +334,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
|||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html << <<-END_HTML
|
||||||
</p>
|
</p>
|
||||||
#{replies_html}
|
#{replies_html}
|
||||||
</div>
|
</div>
|
||||||
@ -344,7 +343,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if comments["continuation"]?
|
if comments["continuation"]?
|
||||||
html += <<-END_HTML
|
html << <<-END_HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
<p>
|
<p>
|
||||||
@ -355,12 +354,11 @@ def template_youtube_comments(comments, locale, thin_mode)
|
|||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return html
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def template_reddit_comments(root, locale)
|
def template_reddit_comments(root, locale)
|
||||||
html = ""
|
String.build do |html|
|
||||||
root.each do |child|
|
root.each do |child|
|
||||||
if child.data.is_a?(RedditComment)
|
if child.data.is_a?(RedditComment)
|
||||||
child = child.data.as(RedditComment)
|
child = child.data.as(RedditComment)
|
||||||
@ -372,7 +370,21 @@ def template_reddit_comments(root, locale)
|
|||||||
replies_html = template_reddit_comments(replies.data.as(RedditListing).children, locale)
|
replies_html = template_reddit_comments(replies.data.as(RedditListing).children, locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
content = <<-END_HTML
|
if child.depth > 0
|
||||||
|
html << <<-END_HTML
|
||||||
|
<div class="pure-g">
|
||||||
|
<div class="pure-u-1-24">
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-23-24">
|
||||||
|
END_HTML
|
||||||
|
else
|
||||||
|
html << <<-END_HTML
|
||||||
|
<div class="pure-g">
|
||||||
|
<div class="pure-u-1">
|
||||||
|
END_HTML
|
||||||
|
end
|
||||||
|
|
||||||
|
html << <<-END_HTML
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
|
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
|
||||||
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
|
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
|
||||||
@ -384,31 +396,12 @@ def template_reddit_comments(root, locale)
|
|||||||
#{body_html}
|
#{body_html}
|
||||||
#{replies_html}
|
#{replies_html}
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
|
||||||
|
|
||||||
if child.depth > 0
|
|
||||||
html += <<-END_HTML
|
|
||||||
<div class="pure-g">
|
|
||||||
<div class="pure-u-1-24">
|
|
||||||
</div>
|
|
||||||
<div class="pure-u-23-24">
|
|
||||||
#{content}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
END_HTML
|
|
||||||
else
|
|
||||||
html += <<-END_HTML
|
|
||||||
<div class="pure-g">
|
|
||||||
<div class="pure-u-1">
|
|
||||||
#{content}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
END_HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return html
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def replace_links(html)
|
def replace_links(html)
|
||||||
|
Loading…
Reference in New Issue
Block a user