summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/css/default.css37
-rw-r--r--spec/helpers_spec.cr10
-rw-r--r--src/invidious/channels/about.cr4
-rw-r--r--src/invidious/comments.cr4
-rw-r--r--src/invidious/playlists.cr18
-rw-r--r--src/invidious/videos.cr2
-rw-r--r--src/invidious/views/components/search_box.ecr9
-rw-r--r--src/invidious/views/playlist.ecr4
-rw-r--r--src/invidious/views/search_homepage.ecr6
-rw-r--r--src/invidious/views/template.ecr6
-rw-r--r--src/invidious/views/watch.ecr13
11 files changed, 47 insertions, 66 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index 95c1f55c..8b2b3578 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -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 */
diff --git a/spec/helpers_spec.cr b/spec/helpers_spec.cr
index 4215b2bd..3319252f 100644
--- a/spec/helpers_spec.cr
+++ b/spec/helpers_spec.cr
@@ -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")
diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr
index c87c53e0..d93ee681 100644
--- a/src/invidious/channels/about.cr
+++ b/src/invidious/channels/about.cr
@@ -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)
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 12a80bc4..5b7d63e0 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -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>"
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index ee7e12aa..a09e6cdb 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -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"]?
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 6c89b445..499ed94d 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -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>")
diff --git a/src/invidious/views/components/search_box.ecr b/src/invidious/views/components/search_box.ecr
new file mode 100644
index 00000000..4144d161
--- /dev/null
+++ b/src/invidious/views/components/search_box.ecr
@@ -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>
diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr
index 7825b1f0..b720bbc2 100644
--- a/src/invidious/views/playlist.ecr
+++ b/src/invidious/views/playlist.ecr
@@ -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 %>
diff --git a/src/invidious/views/search_homepage.ecr b/src/invidious/views/search_homepage.ecr
index 7d2dab83..45561d1e 100644
--- a/src/invidious/views/search_homepage.ecr
+++ b/src/invidious/views/search_homepage.ecr
@@ -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>
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index 5b6e6ab8..efa434bf 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -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 %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index fa4fe083..363f1262 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -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>