Use common heredoc markers

This commit is contained in:
Sijawusz Pur Rahnama 2026-01-11 23:13:19 +01:00
parent b0049e1680
commit 7d90748e78
6 changed files with 60 additions and 60 deletions

View File

@ -15,20 +15,20 @@ module Invidious::Frontend::Comments
end
if child.depth > 0
html << <<-END_HTML
html << <<-HTML
<div class="pure-g">
<div class="pure-u-1-24">
</div>
<div class="pure-u-23-24">
END_HTML
HTML
else
html << <<-END_HTML
html << <<-HTML
<div class="pure-g">
<div class="pure-u-1">
END_HTML
HTML
end
html << <<-END_HTML
html << <<-HTML
<p>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ ]</a>
<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>
END_HTML
HTML
end
end
end

View File

@ -12,7 +12,7 @@ module Invidious::Frontend::Comments
NumberFormatting::Separator
)
replies_html = <<-END_HTML
replies_html = <<-HTML
<div id="replies" class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
@ -22,7 +22,7 @@ module Invidious::Frontend::Comments
</p>
</div>
</div>
END_HTML
HTML
elsif comments["authorId"]? && !comments["singlePost"]?
# for posts we should display a link to the post
replies_count_text = translate_count(locale,
@ -31,7 +31,7 @@ module Invidious::Frontend::Comments
NumberFormatting::Separator
)
replies_html = <<-END_HTML
replies_html = <<-HTML
<div class="pure-g">
<div class="pure-u-1-24"></div>
<div class="pure-u-23-24">
@ -40,7 +40,7 @@ module Invidious::Frontend::Comments
</p>
</div>
</div>
END_HTML
HTML
end
if !thin_mode
@ -65,7 +65,7 @@ module Invidious::Frontend::Comments
str << %(width="16" height="16" />)
end
end
html << <<-END_HTML
html << <<-HTML
<div class="pure-g" style="width:100%">
<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="" />
@ -77,7 +77,7 @@ module Invidious::Frontend::Comments
</b>
#{sponsor_icon}
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
END_HTML
HTML
if child["attachment"]?
attachment = child["attachment"]
@ -86,81 +86,81 @@ module Invidious::Frontend::Comments
when "image"
attachment = attachment["imageThumbnails"][1]
html << <<-END_HTML
html << <<-HTML
<div class="pure-g">
<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="" />
</div>
</div>
END_HTML
HTML
when "video"
if attachment["error"]?
html << <<-END_HTML
html << <<-HTML
<div class="pure-g video-iframe-wrapper">
<p>#{attachment["error"]}</p>
</div>
END_HTML
HTML
else
html << <<-END_HTML
html << <<-HTML
<div class="pure-g video-iframe-wrapper">
<iframe class="video-iframe" src='/embed/#{attachment["videoId"]?}?autoplay=0'></iframe>
</div>
END_HTML
HTML
end
when "multiImage"
html << <<-END_HTML
html << <<-HTML
<section class="carousel">
<a class="skip-link" href="#skip-#{child["commentId"]}">#{translate(locale, "carousel_skip")}</a>
<div class="slides">
END_HTML
HTML
image_array = attachment["images"].as_a
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">
<img loading="lazy" src="/ggpht#{URI.parse(image_array[i][1]["url"].as_s).request_target}" alt="" />
</div>
END_HTML
HTML
end
html << <<-END_HTML
html << <<-HTML
</div>
<div class="carousel__nav">
END_HTML
HTML
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>
END_HTML
HTML
end
html << <<-END_HTML
html << <<-HTML
</div>
<div id="skip-#{child["commentId"]}"></div>
</section>
END_HTML
HTML
end
end
html << <<-END_HTML
html << <<-HTML
<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>
|
END_HTML
HTML
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>
|
END_HTML
HTML
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>
|
END_HTML
HTML
end
html << <<-END_HTML
html << <<-HTML
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
END_HTML
HTML
if child["creatorHeart"]?
if !thin_mode
@ -169,7 +169,7 @@ module Invidious::Frontend::Comments
creator_thumbnail = ""
end
html << <<-END_HTML
html << <<-HTML
&nbsp;
<span class="creator-heart-container" title="#{translate(locale, "`x` marked it with a ❤", child["creatorHeart"]["creatorName"].as_s)}">
<span class="creator-heart">
@ -179,19 +179,19 @@ module Invidious::Frontend::Comments
</span>
</span>
</span>
END_HTML
HTML
end
html << <<-END_HTML
html << <<-HTML
</p>
#{replies_html}
</div>
</div>
END_HTML
HTML
end
if comments["continuation"]?
html << <<-END_HTML
html << <<-HTML
<div class="pure-g">
<div class="pure-u-1">
<p>
@ -200,7 +200,7 @@ module Invidious::Frontend::Comments
</p>
</div>
</div>
END_HTML
HTML
end
end
end

View File

@ -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 += URI.encode_www_form("[Bug] " + issue_title)
error_message = <<-END_HTML
error_message = <<-HTML
<div class="error_message">
<h2>#{translate(locale, "crash_page_you_found_a_bug")}</h2>
<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 -->
<pre class="error-issue-template">#{issue_template}</pre>
</div>
END_HTML
HTML
# Don't show the usual "next steps" widget. The same options are
# 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")
switch_instance = translate(locale, "Switch Invidious Instance")
return <<-END_HTML
return <<-HTML
<p style="margin-bottom: 4px;">#{next_steps_text}</p>
<ul>
<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>
</li>
</ul>
END_HTML
HTML
else
return ""
end

View File

@ -82,7 +82,7 @@ def fetch_mix(rdid, video_id, cookies = nil, locale = nil)
end
def template_mix(mix, listen)
html = <<-END_HTML
html = <<-HTML
<h3>
<a href="/mix?list=#{mix["mixId"]}">
#{mix["title"]}
@ -90,10 +90,10 @@ def template_mix(mix, listen)
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
HTML
mix["videos"].as_a.each do |video|
html += <<-END_HTML
html += <<-HTML
<li class="pure-menu-item">
<a href="/watch?v=#{video["videoId"]}&list=#{mix["mixId"]}#{listen ? "&listen=1" : ""}">
<div class="thumbnail">
@ -106,14 +106,14 @@ def template_mix(mix, listen)
</p>
</a>
</li>
END_HTML
HTML
end
html += <<-END_HTML
html += <<-HTML
</ol>
</div>
<hr>
END_HTML
HTML
html
end

View File

@ -508,7 +508,7 @@ def extract_playlist_videos(initial_data : Hash(String, JSON::Any))
end
def template_playlist(playlist, listen)
html = <<-END_HTML
html = <<-HTML
<h3>
<a href="/playlist?list=#{playlist["playlistId"]}">
#{playlist["title"]}
@ -516,10 +516,10 @@ def template_playlist(playlist, listen)
</h3>
<div class="pure-menu pure-menu-scrollable playlist-restricted">
<ol class="pure-menu-list">
END_HTML
HTML
playlist["videos"].as_a.each do |video|
html += <<-END_HTML
html += <<-HTML
<li class="pure-menu-item" id="#{video["videoId"]}">
<a href="/watch?v=#{video["videoId"]}&list=#{playlist["playlistId"]}&index=#{video["index"]}#{listen ? "&listen=1" : ""}">
<div class="thumbnail">
@ -532,14 +532,14 @@ def template_playlist(playlist, listen)
</p>
</a>
</li>
END_HTML
HTML
end
html += <<-END_HTML
html += <<-HTML
</ol>
</div>
<hr>
END_HTML
HTML
html
end

View File

@ -19,7 +19,7 @@ struct Invidious::User
hour = 12
end
clock_svg = <<-END_SVG
clock_svg = <<-SVG
<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>
@ -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="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
</svg>
END_SVG
SVG
image = "data:image/png;base64,"
image += Process.run(%(rsvg-convert -w 400 -h 400 -b none -f png), shell: true,