mirror of
https://github.com/iv-org/invidious.git
synced 2026-01-28 15:58:30 -06:00
Use common heredoc markers
This commit is contained in:
parent
b0049e1680
commit
7d90748e78
@ -15,20 +15,20 @@ module Invidious::Frontend::Comments
|
|||||||
end
|
end
|
||||||
|
|
||||||
if child.depth > 0
|
if child.depth > 0
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1-24">
|
<div class="pure-u-1-24">
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
END_HTML
|
HTML
|
||||||
else
|
else
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<p>
|
<p>
|
||||||
<a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</a>
|
<a href="javascript:void(0)" data-onclick="toggle_parent">[ − ]</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>
|
||||||
@ -42,7 +42,7 @@ module Invidious::Frontend::Comments
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Invidious::Frontend::Comments
|
|||||||
NumberFormatting::Separator
|
NumberFormatting::Separator
|
||||||
)
|
)
|
||||||
|
|
||||||
replies_html = <<-END_HTML
|
replies_html = <<-HTML
|
||||||
<div id="replies" class="pure-g">
|
<div id="replies" class="pure-g">
|
||||||
<div class="pure-u-1-24"></div>
|
<div class="pure-u-1-24"></div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
@ -22,7 +22,7 @@ module Invidious::Frontend::Comments
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
elsif comments["authorId"]? && !comments["singlePost"]?
|
elsif comments["authorId"]? && !comments["singlePost"]?
|
||||||
# for posts we should display a link to the post
|
# for posts we should display a link to the post
|
||||||
replies_count_text = translate_count(locale,
|
replies_count_text = translate_count(locale,
|
||||||
@ -31,7 +31,7 @@ module Invidious::Frontend::Comments
|
|||||||
NumberFormatting::Separator
|
NumberFormatting::Separator
|
||||||
)
|
)
|
||||||
|
|
||||||
replies_html = <<-END_HTML
|
replies_html = <<-HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1-24"></div>
|
<div class="pure-u-1-24"></div>
|
||||||
<div class="pure-u-23-24">
|
<div class="pure-u-23-24">
|
||||||
@ -40,7 +40,7 @@ module Invidious::Frontend::Comments
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
if !thin_mode
|
if !thin_mode
|
||||||
@ -65,7 +65,7 @@ module Invidious::Frontend::Comments
|
|||||||
str << %(width="16" height="16" />)
|
str << %(width="16" height="16" />)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g" style="width:100%">
|
<div class="pure-g" style="width:100%">
|
||||||
<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 loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />
|
<img loading="lazy" style="margin-right:1em;margin-top:1em;width:90%" src="#{author_thumbnail}" alt="" />
|
||||||
@ -77,7 +77,7 @@ module Invidious::Frontend::Comments
|
|||||||
</b>
|
</b>
|
||||||
#{sponsor_icon}
|
#{sponsor_icon}
|
||||||
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
if child["attachment"]?
|
if child["attachment"]?
|
||||||
attachment = child["attachment"]
|
attachment = child["attachment"]
|
||||||
@ -86,81 +86,81 @@ module Invidious::Frontend::Comments
|
|||||||
when "image"
|
when "image"
|
||||||
attachment = attachment["imageThumbnails"][1]
|
attachment = attachment["imageThumbnails"][1]
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1 pure-u-md-1-2">
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
<img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />
|
<img loading="lazy" style="width:100%" src="/ggpht#{URI.parse(attachment["url"].as_s).request_target}" alt="" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
when "video"
|
when "video"
|
||||||
if attachment["error"]?
|
if attachment["error"]?
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g video-iframe-wrapper">
|
<div class="pure-g video-iframe-wrapper">
|
||||||
<p>#{attachment["error"]}</p>
|
<p>#{attachment["error"]}</p>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
else
|
else
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g video-iframe-wrapper">
|
<div class="pure-g video-iframe-wrapper">
|
||||||
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
|
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
when "multiImage"
|
when "multiImage"
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<section class="carousel">
|
<section class="carousel">
|
||||||
<a class="skip-link" href="#skip-#{child["commentId"]}">#{translate(locale, "carousel_skip")}</a>
|
<a class="skip-link" href="#skip-#{child["commentId"]}">#{translate(locale, "carousel_skip")}</a>
|
||||||
<div class="slides">
|
<div class="slides">
|
||||||
END_HTML
|
HTML
|
||||||
image_array = attachment["images"].as_a
|
image_array = attachment["images"].as_a
|
||||||
|
|
||||||
image_array.each_index do |i|
|
image_array.each_index do |i|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="slides-item slide-#{i + 1}" id="#{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_slide", {"current" => (i + 1).to_s, "total" => image_array.size.to_s})}" tabindex="0">
|
<div class="slides-item slide-#{i + 1}" id="#{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_slide", {"current" => (i + 1).to_s, "total" => image_array.size.to_s})}" tabindex="0">
|
||||||
<img loading="lazy" src="/ggpht#{URI.parse(image_array[i][1]["url"].as_s).request_target}" alt="" />
|
<img loading="lazy" src="/ggpht#{URI.parse(image_array[i][1]["url"].as_s).request_target}" alt="" />
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
</div>
|
</div>
|
||||||
<div class="carousel__nav">
|
<div class="carousel__nav">
|
||||||
END_HTML
|
HTML
|
||||||
attachment["images"].as_a.each_index do |i|
|
attachment["images"].as_a.each_index do |i|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<a class="slider-nav" href="##{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_go_to", (i + 1).to_s)}" tabindex="-1" aria-hidden="true">#{i + 1}</a>
|
<a class="slider-nav" href="##{child["commentId"]}-slide-#{i + 1}" aria-label="#{translate(locale, "carousel_go_to", (i + 1).to_s)}" tabindex="-1" aria-hidden="true">#{i + 1}</a>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
</div>
|
</div>
|
||||||
<div id="skip-#{child["commentId"]}"></div>
|
<div id="skip-#{child["commentId"]}"></div>
|
||||||
</section>
|
</section>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<p>
|
<p>
|
||||||
<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), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
|
<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), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
|
||||||
|
|
|
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
if comments["videoId"]?
|
if comments["videoId"]?
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
<a rel="noreferrer noopener" href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
||||||
|
|
|
|
||||||
END_HTML
|
HTML
|
||||||
elsif comments["authorId"]?
|
elsif comments["authorId"]?
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
<a rel="noreferrer noopener" href="https://www.youtube.com/channel/#{comments["authorId"]}/community?lb=#{child["commentId"]}" title="#{translate(locale, "YouTube comment permalink")}">[YT]</a>
|
||||||
|
|
|
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
|
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
if child["creatorHeart"]?
|
if child["creatorHeart"]?
|
||||||
if !thin_mode
|
if !thin_mode
|
||||||
@ -169,7 +169,7 @@ module Invidious::Frontend::Comments
|
|||||||
creator_thumbnail = ""
|
creator_thumbnail = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-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)}">
|
||||||
<span class="creator-heart">
|
<span class="creator-heart">
|
||||||
@ -179,19 +179,19 @@ module Invidious::Frontend::Comments
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
</p>
|
</p>
|
||||||
#{replies_html}
|
#{replies_html}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
if comments["continuation"]?
|
if comments["continuation"]?
|
||||||
html << <<-END_HTML
|
html << <<-HTML
|
||||||
<div class="pure-g">
|
<div class="pure-g">
|
||||||
<div class="pure-u-1">
|
<div class="pure-u-1">
|
||||||
<p>
|
<p>
|
||||||
@ -200,7 +200,7 @@ module Invidious::Frontend::Comments
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -61,7 +61,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
|||||||
url_new_issue += "?labels=bug&template=bug_report.md&title="
|
url_new_issue += "?labels=bug&template=bug_report.md&title="
|
||||||
url_new_issue += URI.encode_www_form("[Bug] " + issue_title)
|
url_new_issue += URI.encode_www_form("[Bug] " + issue_title)
|
||||||
|
|
||||||
error_message = <<-END_HTML
|
error_message = <<-HTML
|
||||||
<div class="error_message">
|
<div class="error_message">
|
||||||
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
|
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
@ -80,7 +80,7 @@ def error_template_helper(env : HTTP::Server::Context, status_code : Int32, exce
|
|||||||
<!-- TODO: Add a "copy to clipboard" button -->
|
<!-- TODO: Add a "copy to clipboard" button -->
|
||||||
<pre class="error-issue-template">#{issue_template}</pre>
|
<pre class="error-issue-template">#{issue_template}</pre>
|
||||||
</div>
|
</div>
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
# Don't show the usual "next steps" widget. The same options are
|
# Don't show the usual "next steps" widget. The same options are
|
||||||
# proposed above the error message, just worded differently.
|
# proposed above the error message, just worded differently.
|
||||||
@ -191,7 +191,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
|||||||
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
|
go_to_youtube = translate(locale, "next_steps_error_message_go_to_youtube")
|
||||||
switch_instance = translate(locale, "Switch Invidious Instance")
|
switch_instance = translate(locale, "Switch Invidious Instance")
|
||||||
|
|
||||||
return <<-END_HTML
|
return <<-HTML
|
||||||
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
|
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
@ -204,7 +204,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
|
|||||||
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
END_HTML
|
HTML
|
||||||
else
|
else
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|||||||
@ -82,7 +82,7 @@ def fetch_mix(rdid, video_id, cookies = nil, locale = nil)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def template_mix(mix, listen)
|
def template_mix(mix, listen)
|
||||||
html = <<-END_HTML
|
html = <<-HTML
|
||||||
<h3>
|
<h3>
|
||||||
<a href="/mix?list=#{mix["mixId"]}">
|
<a href="/mix?list=#{mix["mixId"]}">
|
||||||
#{mix["title"]}
|
#{mix["title"]}
|
||||||
@ -90,10 +90,10 @@ def template_mix(mix, listen)
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
||||||
<ol class="pure-menu-list">
|
<ol class="pure-menu-list">
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
mix["videos"].as_a.each do |video|
|
mix["videos"].as_a.each do |video|
|
||||||
html += <<-END_HTML
|
html += <<-HTML
|
||||||
<li class="pure-menu-item">
|
<li class="pure-menu-item">
|
||||||
<a href="/watch?v=#{video["videoId"]}&list=#{mix["mixId"]}#{listen ? "&listen=1" : ""}">
|
<a href="/watch?v=#{video["videoId"]}&list=#{mix["mixId"]}#{listen ? "&listen=1" : ""}">
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
@ -106,14 +106,14 @@ def template_mix(mix, listen)
|
|||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-HTML
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|||||||
@ -508,7 +508,7 @@ def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
|
|||||||
end
|
end
|
||||||
|
|
||||||
def template_playlist(playlist, listen)
|
def template_playlist(playlist, listen)
|
||||||
html = <<-END_HTML
|
html = <<-HTML
|
||||||
<h3>
|
<h3>
|
||||||
<a href="/playlist?list=#{playlist["playlistId"]}">
|
<a href="/playlist?list=#{playlist["playlistId"]}">
|
||||||
#{playlist["title"]}
|
#{playlist["title"]}
|
||||||
@ -516,10 +516,10 @@ def template_playlist(playlist, listen)
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
<div class="pure-menu pure-menu-scrollable playlist-restricted">
|
||||||
<ol class="pure-menu-list">
|
<ol class="pure-menu-list">
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
playlist["videos"].as_a.each do |video|
|
playlist["videos"].as_a.each do |video|
|
||||||
html += <<-END_HTML
|
html += <<-HTML
|
||||||
<li class="pure-menu-item" id="#{video["videoId"]}">
|
<li class="pure-menu-item" id="#{video["videoId"]}">
|
||||||
<a href="/watch?v=#{video["videoId"]}&list=#{playlist["playlistId"]}&index=#{video["index"]}#{listen ? "&listen=1" : ""}">
|
<a href="/watch?v=#{video["videoId"]}&list=#{playlist["playlistId"]}&index=#{video["index"]}#{listen ? "&listen=1" : ""}">
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
@ -532,14 +532,14 @@ def template_playlist(playlist, listen)
|
|||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
END_HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
html += <<-END_HTML
|
html += <<-HTML
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
END_HTML
|
HTML
|
||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,7 +19,7 @@ struct Invidious::User
|
|||||||
hour = 12
|
hour = 12
|
||||||
end
|
end
|
||||||
|
|
||||||
clock_svg = <<-END_SVG
|
clock_svg = <<-SVG
|
||||||
<svg viewBox="0 0 100 100" width="200px" height="200px">
|
<svg viewBox="0 0 100 100" width="200px" height="200px">
|
||||||
<circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>
|
<circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ struct Invidious::User
|
|||||||
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
||||||
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
||||||
</svg>
|
</svg>
|
||||||
END_SVG
|
SVG
|
||||||
|
|
||||||
image = "data:image/png;base64,"
|
image = "data:image/png;base64,"
|
||||||
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,
|
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user