Merge pull request #2719 from SamantazFox/batch-minor-fixes

Multiple minor fixes
This commit is contained in:
Samantaz Fox 2022-01-05 17:20:57 +01:00 committed by GitHub
commit 3bb7fbb2f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 47 additions and 66 deletions

View file

@ -192,20 +192,24 @@ img.thumbnail {
display: inline;
}
.searchbar .pure-form input[type="search"] {
margin-bottom: 1px;
.searchbar .pure-form fieldset { padding: 0; }
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #ccc;
border-radius: 0;
.searchbar input[type="search"] {
width: 100%;
margin: 1px;
padding: initial 0;
border: 1px solid;
border-color: #0000 #0000 #CCC #0000;
border-radius: 0;
box-shadow: none;
box-shadow: none;
-webkit-appearance: none;
}
-webkit-appearance: none;
.searchbar input[type="search"]:focus {
margin: 0 0 0.5px 0;
border: 2px solid;
border-color: #0000 #0000 #FED #0000;
}
/* https://stackoverflow.com/a/55170420 */
@ -217,16 +221,6 @@ input[type="search"]::-webkit-search-cancel-button {
background-size: 14px;
}
.searchbar .pure-form fieldset {
padding: 0;
}
/* attract focus to the searchbar by adding a subtle transition */
.searchbar .pure-form input[type="search"]:focus {
margin-bottom: 0px;
border-bottom: 2px solid #aaa;
}
.user-field {
display: flex;
flex-direction: row;
@ -546,7 +540,8 @@ p,
}
#descriptionWrapper {
max-width: 600px;
max-width: 600px;
white-space: pre-wrap;
}
/* Center the "invidious" logo on the search page */

View file

@ -41,16 +41,6 @@ describe "Helper" do
end
end
describe "#produce_playlist_continuation" do
it "correctly produces ctoken for requesting index `x` of a playlist" do
produce_playlist_continuation("UUCla9fZca4I7KagBtgRGnOw", 100).should eq("4qmFsgJNEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoUQ0FGNkJsQlVPa05IVVElM0QlM0SaAhhVVUNsYTlmWmNhNEk3S2FnQnRnUkduT3c%3D")
produce_playlist_continuation("UCCla9fZca4I7KagBtgRGnOw", 200).should eq("4qmFsgJLEhpWTFVVQ2xhOWZaY2E0STdLYWdCdGdSR25PdxoSQ0FKNkIxQlVPa05OWjBJJTNEmgIYVVVDbGE5ZlpjYTRJN0thZ0J0Z1JHbk93")
produce_playlist_continuation("PL55713C70BA91BD6E", 100).should eq("4qmFsgJBEhRWTFBMNTU3MTNDNzBCQTkxQkQ2RRoUQ0FGNkJsQlVPa05IVVElM0QlM0SaAhJQTDU1NzEzQzcwQkE5MUJENkU%3D")
end
end
describe "#produce_search_params" do
it "correctly produces token for searching with specified filters" do
produce_search_params.should eq("CAASAhABSAA%3D")

View file

@ -59,7 +59,7 @@ def get_about_info(ucid, locale)
banner = banners.try &.[-1]?.try &.["url"].as_s?
description = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"]["simpleText"].as_s
description_html = HTML.escape(description).gsub("\n", "<br>")
description_html = HTML.escape(description)
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
@ -81,7 +81,7 @@ def get_about_info(ucid, locale)
# end
description = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?.try &.as_s? || ""
description_html = HTML.escape(description).gsub("\n", "<br>")
description_html = HTML.escape(description)
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)

View file

@ -550,12 +550,12 @@ end
def parse_content(content : JSON::Any) : String
content["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s } || ""
content["runs"]?.try &.as_a.try { |r| content_to_comment_html(r).try &.to_s.gsub("\n", "<br>") } || ""
end
def content_to_comment_html(content)
comment_html = content.map do |run|
text = HTML.escape(run["text"].as_s).gsub("\n", "<br>")
text = HTML.escape(run["text"].as_s)
if run["bold"]?
text = "<b>#{text}</b>"

View file

@ -243,7 +243,7 @@ struct InvidiousPlaylist
end
def description_html
HTML.escape(self.description).gsub("\n", "<br>")
HTML.escape(self.description)
end
end
@ -300,16 +300,14 @@ def produce_playlist_continuation(id, index)
.try { |i| Protodec::Any.from_json(i) }
.try { |i| Base64.urlsafe_encode(i, padding: false) }
data_wrapper = {"1:varint" => request_count, "15:string" => "PT:#{data}"}
.try { |i| Protodec::Any.cast_json(i) }
.try { |i| Protodec::Any.from_json(i) }
.try { |i| Base64.urlsafe_encode(i) }
.try { |i| URI.encode_www_form(i) }
object = {
"80226972:embedded" => {
"2:string" => plid,
"3:string" => data_wrapper,
"2:string" => plid,
"3:base64" => {
"1:varint" => request_count,
"15:string" => "PT:#{data}",
"104:embedded" => {"1:0:varint" => 0_i64},
},
"35:string" => id,
},
}
@ -347,7 +345,7 @@ def fetch_playlist(plid, locale)
playlist_info = playlist_sidebar_renderer[0]["playlistSidebarPrimaryInfoRenderer"]?
raise InfoException.new("Could not extract playlist info") if !playlist_info
title = playlist_info["title"]?.try &.["runs"][0]?.try &.["text"]?.try &.as_s || ""
title = playlist_info.dig?("title", "runs", 0, "text").try &.as_s || ""
desc_item = playlist_info["description"]?

View file

@ -945,7 +945,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Description
description_html = video_secondary_renderer.try &.dig?("description", "runs")
.try &.as_a.try { |t| content_to_comment_html(t).gsub("\n", "<br/>") }
.try &.as_a.try { |t| content_to_comment_html(t) }
params["descriptionHtml"] = JSON::Any.new(description_html || "<p></p>")

View file

@ -0,0 +1,9 @@
<form class="pure-form" action="/search" method="get">
<fieldset>
<input type="search" id="searchbox" autocomplete="off" autocorrect="off"
autocapitalize="none" spellcheck="false" autofocus name="q"
placeholder="<%= translate(locale, "search") %>"
title="<%= translate(locale, "search") %>"
value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
</fieldset>
</form>

View file

@ -74,9 +74,7 @@
</div>
<div class="h-box">
<div id="descriptionWrapper">
<p><%= playlist.description_html %></p>
</div>
<div id="descriptionWrapper"><%= playlist.description_html %></div>
</div>
<% if playlist.is_a?(InvidiousPlaylist) && playlist.author == user.try &.email %>

View file

@ -14,11 +14,7 @@
</div>
<div class="pure-u-1-4"></div>
<div class="pure-u-1 pure-u-md-12-24 searchbar">
<form class="pure-form" action="/search" method="get">
<fieldset>
<input autofocus type="search" style="width:100%" name="q" placeholder="<%= translate(locale, "search") %>" value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
</fieldset>
</form>
<%= rendered "components/search_box" %>
</div>
<div class="pure-u-1-4"></div>
</div>

View file

@ -35,11 +35,7 @@
<a href="/" class="index-link pure-menu-heading">Invidious</a>
</div>
<div class="pure-u-1 pure-u-md-12-24 searchbar">
<form class="pure-form" action="/search" method="get">
<fieldset>
<input type="search" style="width:100%" name="q" placeholder="<%= translate(locale, "search") %>" value="<%= env.get?("search").try {|x| HTML.escape(x.as(String)) } %>">
</fieldset>
</form>
<%= rendered "components/search_box" %>
</div>
<% end %>

View file

@ -140,7 +140,7 @@ we're going to need to do it here in order to allow for translations.
<% if user %>
<% playlists = Invidious::Database::Playlists.select_user_created_playlists(user.email) %>
<% if !playlists.empty? %>
<form data-onsubmit="return_false" class="pure-form pure-form-stacked" action="/playlist_ajax" method="post">
<form data-onsubmit="return_false" class="pure-form pure-form-stacked" action="/playlist_ajax" method="post" target="_blank">
<div class="pure-control-group">
<label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label>
<select style="width:100%" name="playlist_id" id="playlist_id">
@ -150,6 +150,9 @@ we're going to need to do it here in order to allow for translations.
</select>
</div>
<input type="hidden" name="csrf_token" value="<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>">
<input type="hidden" name="action_add_video" value="1">
<input type="hidden" name="video_id" value="<%= video.id %>">
<button data-onclick="add_playlist_video" data-id="<%= video.id %>" type="submit" class="pure-button pure-button-primary">
<b><%= translate(locale, "Add to playlist") %></b>
</button>
@ -254,14 +257,10 @@ we're going to need to do it here in order to allow for translations.
<div id="description-box"> <!-- Description -->
<% if video.description.size < 200 || params.extend_desc %>
<div id="descriptionWrapper">
<%= video.description_html %>
</div>
<div id="descriptionWrapper"><%= video.description_html %></div>
<% else %>
<input id="descexpansionbutton" type="checkbox"/>
<div id="descriptionWrapper">
<%= video.description_html %>
</div>
<div id="descriptionWrapper"><%= video.description_html %></div>
<label for="descexpansionbutton">
<a></a>
</label>