mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-22 16:19:53 +05:30
Merge pull request #2719 from SamantazFox/batch-minor-fixes
Multiple minor fixes
This commit is contained in:
commit
3bb7fbb2f1
@ -192,20 +192,24 @@ img.thumbnail {
|
|||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchbar .pure-form input[type="search"] {
|
.searchbar .pure-form fieldset { padding: 0; }
|
||||||
margin-bottom: 1px;
|
|
||||||
|
|
||||||
border-top: 0;
|
.searchbar input[type="search"] {
|
||||||
border-left: 0;
|
width: 100%;
|
||||||
border-right: 0;
|
margin: 1px;
|
||||||
border-bottom: 1px solid #ccc;
|
|
||||||
border-radius: 0;
|
|
||||||
|
|
||||||
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 */
|
/* https://stackoverflow.com/a/55170420 */
|
||||||
@ -217,16 +221,6 @@ input[type="search"]::-webkit-search-cancel-button {
|
|||||||
background-size: 14px;
|
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 {
|
.user-field {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -546,7 +540,8 @@ p,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#descriptionWrapper {
|
#descriptionWrapper {
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Center the "invidious" logo on the search page */
|
/* Center the "invidious" logo on the search page */
|
||||||
|
@ -41,16 +41,6 @@ describe "Helper" do
|
|||||||
end
|
end
|
||||||
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
|
describe "#produce_search_params" do
|
||||||
it "correctly produces token for searching with specified filters" do
|
it "correctly produces token for searching with specified filters" do
|
||||||
produce_search_params.should eq("CAASAhABSAA%3D")
|
produce_search_params.should eq("CAASAhABSAA%3D")
|
||||||
|
@ -59,7 +59,7 @@ def get_about_info(ucid, locale)
|
|||||||
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
banner = banners.try &.[-1]?.try &.["url"].as_s?
|
||||||
|
|
||||||
description = initdata["header"]["interactiveTabbedHeaderRenderer"]["description"]["simpleText"].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
|
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
|
||||||
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
|
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
|
||||||
@ -81,7 +81,7 @@ def get_about_info(ucid, locale)
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
description = initdata["metadata"]["channelMetadataRenderer"]?.try &.["description"]?.try &.as_s? || ""
|
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
|
is_family_friendly = initdata["microformat"]["microformatDataRenderer"]["familySafe"].as_bool
|
||||||
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
|
allowed_regions = initdata["microformat"]["microformatDataRenderer"]["availableCountries"].as_a.map(&.as_s)
|
||||||
|
@ -550,12 +550,12 @@ end
|
|||||||
|
|
||||||
def parse_content(content : JSON::Any) : String
|
def parse_content(content : JSON::Any) : String
|
||||||
content["simpleText"]?.try &.as_s.rchop('\ufeff').try { |b| HTML.escape(b) }.to_s ||
|
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
|
end
|
||||||
|
|
||||||
def content_to_comment_html(content)
|
def content_to_comment_html(content)
|
||||||
comment_html = content.map do |run|
|
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"]?
|
if run["bold"]?
|
||||||
text = "<b>#{text}</b>"
|
text = "<b>#{text}</b>"
|
||||||
|
@ -243,7 +243,7 @@ struct InvidiousPlaylist
|
|||||||
end
|
end
|
||||||
|
|
||||||
def description_html
|
def description_html
|
||||||
HTML.escape(self.description).gsub("\n", "<br>")
|
HTML.escape(self.description)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -300,16 +300,14 @@ def produce_playlist_continuation(id, index)
|
|||||||
.try { |i| Protodec::Any.from_json(i) }
|
.try { |i| Protodec::Any.from_json(i) }
|
||||||
.try { |i| Base64.urlsafe_encode(i, padding: false) }
|
.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 = {
|
object = {
|
||||||
"80226972:embedded" => {
|
"80226972:embedded" => {
|
||||||
"2:string" => plid,
|
"2:string" => plid,
|
||||||
"3:string" => data_wrapper,
|
"3:base64" => {
|
||||||
|
"1:varint" => request_count,
|
||||||
|
"15:string" => "PT:#{data}",
|
||||||
|
"104:embedded" => {"1:0:varint" => 0_i64},
|
||||||
|
},
|
||||||
"35:string" => id,
|
"35:string" => id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -347,7 +345,7 @@ def fetch_playlist(plid, locale)
|
|||||||
playlist_info = playlist_sidebar_renderer[0]["playlistSidebarPrimaryInfoRenderer"]?
|
playlist_info = playlist_sidebar_renderer[0]["playlistSidebarPrimaryInfoRenderer"]?
|
||||||
raise InfoException.new("Could not extract playlist info") if !playlist_info
|
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"]?
|
desc_item = playlist_info["description"]?
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
|
|||||||
# Description
|
# Description
|
||||||
|
|
||||||
description_html = video_secondary_renderer.try &.dig?("description", "runs")
|
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>")
|
params["descriptionHtml"] = JSON::Any.new(description_html || "<p></p>")
|
||||||
|
|
||||||
|
9
src/invidious/views/components/search_box.ecr
Normal file
9
src/invidious/views/components/search_box.ecr
Normal 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>
|
@ -74,9 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="h-box">
|
<div class="h-box">
|
||||||
<div id="descriptionWrapper">
|
<div id="descriptionWrapper"><%= playlist.description_html %></div>
|
||||||
<p><%= playlist.description_html %></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if playlist.is_a?(InvidiousPlaylist) && playlist.author == user.try &.email %>
|
<% if playlist.is_a?(InvidiousPlaylist) && playlist.author == user.try &.email %>
|
||||||
|
@ -14,11 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-4"></div>
|
<div class="pure-u-1-4"></div>
|
||||||
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
||||||
<form class="pure-form" action="/search" method="get">
|
<%= rendered "components/search_box" %>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-4"></div>
|
<div class="pure-u-1-4"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -35,11 +35,7 @@
|
|||||||
<a href="/" class="index-link pure-menu-heading">Invidious</a>
|
<a href="/" class="index-link pure-menu-heading">Invidious</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
<div class="pure-u-1 pure-u-md-12-24 searchbar">
|
||||||
<form class="pure-form" action="/search" method="get">
|
<%= rendered "components/search_box" %>
|
||||||
<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>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ we're going to need to do it here in order to allow for translations.
|
|||||||
<% if user %>
|
<% if user %>
|
||||||
<% playlists = Invidious::Database::Playlists.select_user_created_playlists(user.email) %>
|
<% playlists = Invidious::Database::Playlists.select_user_created_playlists(user.email) %>
|
||||||
<% if !playlists.empty? %>
|
<% 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">
|
<div class="pure-control-group">
|
||||||
<label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label>
|
<label for="playlist_id"><%= translate(locale, "Add to playlist: ") %></label>
|
||||||
<select style="width:100%" name="playlist_id" id="playlist_id">
|
<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>
|
</select>
|
||||||
</div>
|
</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">
|
<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>
|
<b><%= translate(locale, "Add to playlist") %></b>
|
||||||
</button>
|
</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 -->
|
<div id="description-box"> <!-- Description -->
|
||||||
<% if video.description.size < 200 || params.extend_desc %>
|
<% if video.description.size < 200 || params.extend_desc %>
|
||||||
<div id="descriptionWrapper">
|
<div id="descriptionWrapper"><%= video.description_html %></div>
|
||||||
<%= video.description_html %>
|
|
||||||
</div>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<input id="descexpansionbutton" type="checkbox"/>
|
<input id="descexpansionbutton" type="checkbox"/>
|
||||||
<div id="descriptionWrapper">
|
<div id="descriptionWrapper"><%= video.description_html %></div>
|
||||||
<%= video.description_html %>
|
|
||||||
</div>
|
|
||||||
<label for="descexpansionbutton">
|
<label for="descexpansionbutton">
|
||||||
<a></a>
|
<a></a>
|
||||||
</label>
|
</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user