forked from midou/invidious
Merge pull request #2155 from SamantazFox/fix-utf8-in-search
Multiple search fixes
This commit is contained in:
commit
2b9c6c95b1
@ -79,7 +79,7 @@ end
|
|||||||
def request_youtube_api_search(search_query : String, params : String, region = nil)
|
def request_youtube_api_search(search_query : String, params : String, region = nil)
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
"query" => URI.encode_www_form(search_query),
|
"query" => search_query,
|
||||||
"context" => make_youtube_api_context(region),
|
"context" => make_youtube_api_context(region),
|
||||||
"params" => params,
|
"params" => params,
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,17 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
|
|||||||
|
|
||||||
query = env.params.query["search_query"]?
|
query = env.params.query["search_query"]?
|
||||||
query ||= env.params.query["q"]?
|
query ||= env.params.query["q"]?
|
||||||
query ||= ""
|
|
||||||
|
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?
|
||||||
page ||= 1
|
|
||||||
|
|
||||||
if query
|
if query && !query.empty?
|
||||||
env.redirect "/search?q=#{URI.encode_www_form(query)}&page=#{page}"
|
if page && !page.empty?
|
||||||
|
env.redirect "/search?q=" + URI.encode_www_form(query) + "&page=" + page
|
||||||
else
|
else
|
||||||
env.redirect "/"
|
env.redirect "/search?q=" + URI.encode_www_form(query)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
env.redirect "/search"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,17 +40,19 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
|
|||||||
|
|
||||||
query = env.params.query["search_query"]?
|
query = env.params.query["search_query"]?
|
||||||
query ||= env.params.query["q"]?
|
query ||= env.params.query["q"]?
|
||||||
query ||= ""
|
|
||||||
|
|
||||||
return env.redirect "/" if query.empty?
|
|
||||||
|
|
||||||
|
if !query || query.empty?
|
||||||
|
# Display the full page search box implemented in #1977
|
||||||
|
env.set "search", ""
|
||||||
|
templated "search_homepage", navbar_search: false
|
||||||
|
else
|
||||||
page = env.params.query["page"]?.try &.to_i?
|
page = env.params.query["page"]?.try &.to_i?
|
||||||
page ||= 1
|
page ||= 1
|
||||||
|
|
||||||
user = env.get? "user"
|
user = env.get? "user"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
search_query, count, videos, operators = process_search_query(query, page, user, region: nil)
|
search_query, count, videos, operators = process_search_query(query, page, user, region: region)
|
||||||
rescue ex
|
rescue ex
|
||||||
return error_template(500, ex)
|
return error_template(500, ex)
|
||||||
end
|
end
|
||||||
@ -62,4 +66,5 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute
|
|||||||
env.set "search", query
|
env.set "search", query
|
||||||
templated "search"
|
templated "search"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<% content_for "header" do %>
|
<% content_for "header" do %>
|
||||||
<meta name="description" content="<%= translate(locale, "An alternative front-end to YouTube") %>">
|
<meta name="description" content="<%= translate(locale, "An alternative front-end to YouTube") %>">
|
||||||
<title>
|
<title>
|
||||||
Invidious
|
Invidious - <%= translate(locale, "search") %>
|
||||||
</title>
|
</title>
|
||||||
<link rel="stylesheet" href="/css/empty.css?v=<%= ASSET_COMMIT %>">
|
<link rel="stylesheet" href="/css/empty.css?v=<%= ASSET_COMMIT %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
Reference in New Issue
Block a user