mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2026-02-15 21:17:20 +00:00
feat: Add support for POST requests on searches for privacy
Use already set preferences variable Use span for description, grammar fix from Copilot
This commit is contained in:
@@ -129,6 +129,8 @@
|
|||||||
"preferences_default_trending_type": "Default trending page: ",
|
"preferences_default_trending_type": "Default trending page: ",
|
||||||
"preferences_default_playlist": "Default playlist: ",
|
"preferences_default_playlist": "Default playlist: ",
|
||||||
"preferences_default_playlist_none": "No default playlist set",
|
"preferences_default_playlist_none": "No default playlist set",
|
||||||
|
"preferences_search_privacy_label": "Search privacy: ",
|
||||||
|
"preferences_search_privacy_description": "Enabling this preference will prevent your search queries from being saved in your browser history.",
|
||||||
"published": "published",
|
"published": "published",
|
||||||
"published - reverse": "published - reverse",
|
"published - reverse": "published - reverse",
|
||||||
"alphabetically": "alphabetically",
|
"alphabetically": "alphabetically",
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ struct ConfigPreferences
|
|||||||
property show_community_backends : Bool = false
|
property show_community_backends : Bool = false
|
||||||
@[YAML::Field(ignore: true)]
|
@[YAML::Field(ignore: true)]
|
||||||
property current_companion : Int32? = nil
|
property current_companion : Int32? = nil
|
||||||
|
property search_privacy : Bool = false
|
||||||
|
|
||||||
def to_tuple
|
def to_tuple
|
||||||
{% begin %}
|
{% begin %}
|
||||||
|
|||||||
@@ -40,9 +40,16 @@ module Invidious::Routes::Search
|
|||||||
preferences = env.get("preferences").as(Preferences)
|
preferences = env.get("preferences").as(Preferences)
|
||||||
locale = preferences.locale
|
locale = preferences.locale
|
||||||
|
|
||||||
region = env.params.query["region"]? || preferences.region
|
uri_params = URI::Params.new
|
||||||
|
if env.request.method == "GET"
|
||||||
|
uri_params = env.params.query
|
||||||
|
else
|
||||||
|
uri_params = env.params.body
|
||||||
|
end
|
||||||
|
|
||||||
query = Invidious::Search::Query.new(env.params.query, :regular, region)
|
region = uri_params["region"]? || preferences.region
|
||||||
|
|
||||||
|
query = Invidious::Search::Query.new(uri_params, :regular, region)
|
||||||
|
|
||||||
if query.empty?
|
if query.empty?
|
||||||
# Display the full page search box implemented in #1977
|
# Display the full page search box implemented in #1977
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ module Invidious::Routing
|
|||||||
get "/opensearch.xml", Routes::Search, :opensearch
|
get "/opensearch.xml", Routes::Search, :opensearch
|
||||||
get "/results", Routes::Search, :results
|
get "/results", Routes::Search, :results
|
||||||
get "/search", Routes::Search, :search
|
get "/search", Routes::Search, :search
|
||||||
|
post "/search", Routes::Search, :search
|
||||||
get "/hashtag/:hashtag", Routes::Search, :hashtag
|
get "/hashtag/:hashtag", Routes::Search, :hashtag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ struct Preferences
|
|||||||
property default_playlist : String? = nil
|
property default_playlist : String? = nil
|
||||||
property show_community_backends : Bool = false
|
property show_community_backends : Bool = false
|
||||||
property current_companion : Int32? = nil
|
property current_companion : Int32? = nil
|
||||||
|
property search_privacy : Bool = CONFIG.default_user_preferences.search_privacy
|
||||||
|
|
||||||
module BoolToString
|
module BoolToString
|
||||||
def self.to_json(value : String, json : JSON::Builder)
|
def self.to_json(value : String, json : JSON::Builder)
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
|
<%
|
||||||
|
search_privacy = preferences.search_privacy
|
||||||
|
%>
|
||||||
|
|
||||||
|
<% if search_privacy %>
|
||||||
|
<form class="pure-form" action="/search" method="post">
|
||||||
|
<% else %>
|
||||||
<form class="pure-form" action="/search" method="get">
|
<form class="pure-form" action="/search" method="get">
|
||||||
|
<% end %>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<input type="search" id="searchbox" autocorrect="off"
|
<input type="search" id="searchbox" autocorrect="off"
|
||||||
autocapitalize="none" spellcheck="false" <% if autofocus %>autofocus<% end %>
|
autocapitalize="none" spellcheck="false" <% if autofocus %>autofocus<% end %>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
|
<%
|
||||||
|
search_privacy = preferences.search_privacy
|
||||||
|
search_query = query.text.size > 30 ? HTML.escape(query.text[0,30].rstrip(".")) + "…" : HTML.escape(query.text)
|
||||||
|
%>
|
||||||
|
|
||||||
<% content_for "header" do %>
|
<% content_for "header" do %>
|
||||||
<title><%= query.text.size > 30 ? HTML.escape(query.text[0,30].rstrip(".")) + "…" : HTML.escape(query.text) %> - Invidious</title>
|
<title><%= search_privacy ? "Search" : search_query %> - Invidious</title>
|
||||||
<link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>">
|
<link rel="stylesheet" href="/css/search.css?v=<%= ASSET_COMMIT %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,12 @@
|
|||||||
<span class="preference-description"><%= translate(locale, "preferences_show_community_backends_description") %></span>
|
<span class="preference-description"><%= translate(locale, "preferences_show_community_backends_description") %></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="search_privacy"><%= translate(locale, "preferences_search_privacy_label") %></label>
|
||||||
|
<input name="search_privacy" id="search_privacy" type="checkbox" <% if preferences.search_privacy %>checked<% end %>>
|
||||||
|
<span class="preference-description"><%= translate(locale, "preferences_search_privacy_description") %></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="hidden_channels"><%= translate(locale, "preferences_hidden_channels") %></label>
|
<label for="hidden_channels"><%= translate(locale, "preferences_hidden_channels") %></label>
|
||||||
<% hidden_channels = preferences.hidden_channels %>
|
<% hidden_channels = preferences.hidden_channels %>
|
||||||
|
|||||||
Reference in New Issue
Block a user