mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-18 20:24:22 -05: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
|
||||
|
||||
def template_youtube_comments(comments, locale, thin_mode)
|
||||
html = ""
|
||||
|
||||
String.build do |html|
|
||||
root = comments["comments"].as_a
|
||||
root.each do |child|
|
||||
if child["replies"]?
|
||||
@ -298,7 +297,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
||||
author_thumbnail = ""
|
||||
end
|
||||
|
||||
html += <<-END_HTML
|
||||
html << <<-END_HTML
|
||||
<div class="pure-g">
|
||||
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
|
||||
<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 = ""
|
||||
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)}">
|
||||
<div class="creator-heart">
|
||||
<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_HTML
|
||||
html << <<-END_HTML
|
||||
</p>
|
||||
#{replies_html}
|
||||
</div>
|
||||
@ -344,7 +343,7 @@ def template_youtube_comments(comments, locale, thin_mode)
|
||||
end
|
||||
|
||||
if comments["continuation"]?
|
||||
html += <<-END_HTML
|
||||
html << <<-END_HTML
|
||||
<div class="pure-g">
|
||||
<div class="pure-u-1">
|
||||
<p>
|
||||
@ -355,12 +354,11 @@ def template_youtube_comments(comments, locale, thin_mode)
|
||||
</div>
|
||||
END_HTML
|
||||
end
|
||||
|
||||
return html
|
||||
end
|
||||
end
|
||||
|
||||
def template_reddit_comments(root, locale)
|
||||
html = ""
|
||||
String.build do |html|
|
||||
root.each do |child|
|
||||
if child.data.is_a?(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)
|
||||
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>
|
||||
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
|
||||
<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}
|
||||
#{replies_html}
|
||||
</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>
|
||||
END_HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return html
|
||||
end
|
||||
|
||||
def replace_links(html)
|
||||
|
Loading…
Reference in New Issue
Block a user