Merge 68c4de1e53f3f4a755ee2a2abbeeebe351c896b8 into 35d1d499bc42a9b141b3dc92c4a5827b5f21a3ff

This commit is contained in:
Fijxu 2025-12-02 21:29:54 +00:00 committed by GitHub
commit 04d1c6c60f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 39 additions and 3 deletions

View File

@ -124,6 +124,8 @@
"preferences_sort_label": "Sort videos by: ", "preferences_sort_label": "Sort videos by: ",
"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 to be saved in your browser history.",
"published": "published", "published": "published",
"published - reverse": "published - reverse", "published - reverse": "published - reverse",
"alphabetically": "alphabetically", "alphabetically": "alphabetically",

View File

@ -54,6 +54,7 @@ struct ConfigPreferences
property save_player_pos : Bool = false property save_player_pos : Bool = false
@[YAML::Field(ignore: true)] @[YAML::Field(ignore: true)]
property default_playlist : String? = nil property default_playlist : String? = nil
property search_privacy : Bool = false
def to_tuple def to_tuple
{% begin %} {% begin %}

View File

@ -145,6 +145,10 @@ module Invidious::Routes::PreferencesRoute
default_playlist = env.params.body["default_playlist"]?.try &.as(String) default_playlist = env.params.body["default_playlist"]?.try &.as(String)
search_privacy = env.params.body["search_privacy"]?.try &.as(String)
search_privacy ||= "off"
search_privacy = search_privacy == "on"
# Convert to JSON and back again to take advantage of converters used for compatibility # Convert to JSON and back again to take advantage of converters used for compatibility
preferences = Preferences.from_json({ preferences = Preferences.from_json({
annotations: annotations, annotations: annotations,
@ -182,6 +186,7 @@ module Invidious::Routes::PreferencesRoute
show_nick: show_nick, show_nick: show_nick,
save_player_pos: save_player_pos, save_player_pos: save_player_pos,
default_playlist: default_playlist, default_playlist: default_playlist,
search_privacy: search_privacy,
}.to_json) }.to_json)
if user = env.get? "user" if user = env.get? "user"

View File

@ -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

View File

@ -185,6 +185,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

View File

@ -57,6 +57,7 @@ struct Preferences
property volume : Int32 = CONFIG.default_user_preferences.volume property volume : Int32 = CONFIG.default_user_preferences.volume
property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos
property default_playlist : String? = nil property default_playlist : String? = 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)

View File

@ -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 %>

View File

@ -1,5 +1,10 @@
<%
search_privacy = preferences.search_privacy
search_query = query.text.size > 30 ? HTML.escape(query.text[0,30].rstrip(".")) + "&hellip;" : HTML.escape(query.text)
%>
<% content_for "header" do %> <% content_for "header" do %>
<title><%= query.text.size > 30 ? HTML.escape(query.text[0,30].rstrip(".")) + "&hellip;" : 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 %>

View File

@ -221,6 +221,12 @@
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>> <input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
</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 %>>
<label for="search_privacy"><%= translate(locale, "preferences_search_privacy_description") %></label>
</div>
<% if env.get? "user" %> <% if env.get? "user" %>
<legend><%= translate(locale, "preferences_category_subscription") %></legend> <legend><%= translate(locale, "preferences_category_subscription") %></legend>