Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -887,4 +887,11 @@ h1, h2, h3, h4, h5, p,
.error-issue-template {
padding: 20px;
background: rgba(0, 0, 0, 0.12345);
}

.preference-description {
width: 250px;
padding-left: 10px;
display: inline-block;
vertical-align: top;
}
2 changes: 2 additions & 0 deletions locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
"preferences_sort_label": "Sort videos by: ",
"preferences_default_playlist": "Default playlist: ",
"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 - reverse": "published - reverse",
"alphabetically": "alphabetically",
Expand Down
1 change: 1 addition & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct ConfigPreferences
property save_player_pos : Bool = false
@[YAML::Field(ignore: true)]
property default_playlist : String? = nil
property search_privacy : Bool = false

def to_tuple
{% begin %}
Expand Down
5 changes: 5 additions & 0 deletions src/invidious/routes/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ module Invidious::Routes::PreferencesRoute

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
preferences = Preferences.from_json({
annotations: annotations,
Expand Down Expand Up @@ -182,6 +186,7 @@ module Invidious::Routes::PreferencesRoute
show_nick: show_nick,
save_player_pos: save_player_pos,
default_playlist: default_playlist,
search_privacy: search_privacy,
}.to_json)

if user = env.get? "user"
Expand Down
11 changes: 9 additions & 2 deletions src/invidious/routes/search.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ module Invidious::Routes::Search
preferences = env.get("preferences").as(Preferences)
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

region = uri_params["region"]? || preferences.region

query = Invidious::Search::Query.new(env.params.query, :regular, region)
query = Invidious::Search::Query.new(uri_params, :regular, region)

if query.empty?
# Display the full page search box implemented in #1977
Expand Down
1 change: 1 addition & 0 deletions src/invidious/routing.cr
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ module Invidious::Routing
get "/opensearch.xml", Routes::Search, :opensearch
get "/results", Routes::Search, :results
get "/search", Routes::Search, :search
post "/search", Routes::Search, :search
get "/hashtag/:hashtag", Routes::Search, :hashtag
end

Expand Down
1 change: 1 addition & 0 deletions src/invidious/user/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct Preferences
property volume : Int32 = CONFIG.default_user_preferences.volume
property save_player_pos : Bool = CONFIG.default_user_preferences.save_player_pos
property default_playlist : String? = nil
property search_privacy : Bool = CONFIG.default_user_preferences.search_privacy

module BoolToString
def self.to_json(value : String, json : JSON::Builder)
Expand Down
8 changes: 8 additions & 0 deletions src/invidious/views/components/search_box.ecr
Original file line number Diff line number Diff line change
@@ -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">
<% end %>
<fieldset>
<input type="search" id="searchbox" autocorrect="off"
autocapitalize="none" spellcheck="false" <% if autofocus %>autofocus<% end %>
Expand Down
7 changes: 6 additions & 1 deletion src/invidious/views/search.ecr
Original file line number Diff line number Diff line change
@@ -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 %>
<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 %>">
<% end %>

Expand Down
6 changes: 6 additions & 0 deletions src/invidious/views/user/preferences.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
</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>

<% if env.get? "user" %>
<legend><%= translate(locale, "preferences_category_subscription") %></legend>

Expand Down