mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-26 23:47:25 +00:00
Add option to redirect homepage to subscription feed
This commit is contained in:
parent
09d78c9d3a
commit
0d23f25a8c
@ -258,6 +258,14 @@ before_all do |env|
|
|||||||
end
|
end
|
||||||
|
|
||||||
get "/" do |env|
|
get "/" do |env|
|
||||||
|
user = env.get? "user"
|
||||||
|
if user
|
||||||
|
user = user.as(User)
|
||||||
|
if user.preferences.redirect_feed
|
||||||
|
env.redirect "/feed/subscriptions"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
templated "index"
|
templated "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1689,6 +1697,10 @@ post "/preferences" do |env|
|
|||||||
comments = env.params.body["comments"]?
|
comments = env.params.body["comments"]?
|
||||||
comments ||= "youtube"
|
comments ||= "youtube"
|
||||||
|
|
||||||
|
redirect_feed = env.params.body["redirect_feed"]?.try &.as(String)
|
||||||
|
redirect_feed ||= "off"
|
||||||
|
redirect_feed = redirect_feed == "on"
|
||||||
|
|
||||||
dark_mode = env.params.body["dark_mode"]?.try &.as(String)
|
dark_mode = env.params.body["dark_mode"]?.try &.as(String)
|
||||||
dark_mode ||= "off"
|
dark_mode ||= "off"
|
||||||
dark_mode = dark_mode == "on"
|
dark_mode = dark_mode == "on"
|
||||||
@ -1708,17 +1720,18 @@ post "/preferences" do |env|
|
|||||||
latest_only = latest_only == "on"
|
latest_only = latest_only == "on"
|
||||||
|
|
||||||
preferences = {
|
preferences = {
|
||||||
"video_loop" => video_loop,
|
"video_loop" => video_loop,
|
||||||
"autoplay" => autoplay,
|
"autoplay" => autoplay,
|
||||||
"speed" => speed,
|
"speed" => speed,
|
||||||
"quality" => quality,
|
"quality" => quality,
|
||||||
"volume" => volume,
|
"volume" => volume,
|
||||||
"comments" => comments,
|
"comments" => comments,
|
||||||
"dark_mode" => dark_mode,
|
"redirect_feed" => redirect_feed,
|
||||||
"thin_mode" => thin_mode,
|
"dark_mode" => dark_mode,
|
||||||
"max_results" => max_results,
|
"thin_mode" => thin_mode,
|
||||||
"sort" => sort,
|
"max_results" => max_results,
|
||||||
"latest_only" => latest_only,
|
"sort" => sort,
|
||||||
|
"latest_only" => latest_only,
|
||||||
}.to_json
|
}.to_json
|
||||||
|
|
||||||
PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences, user.email)
|
PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences, user.email)
|
||||||
|
@ -163,6 +163,11 @@ class Preferences
|
|||||||
nilable: true,
|
nilable: true,
|
||||||
default: "youtube",
|
default: "youtube",
|
||||||
},
|
},
|
||||||
|
redirect_feed: {
|
||||||
|
type: Bool,
|
||||||
|
nilable: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
dark_mode: Bool,
|
dark_mode: Bool,
|
||||||
thin_mode: {
|
thin_mode: {
|
||||||
type: Bool,
|
type: Bool,
|
||||||
|
@ -68,6 +68,11 @@ function update_value(element) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<legend>Subscription preferences</legend>
|
<legend>Subscription preferences</legend>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="redirect_feed">Redirect homepage to feed: </label>
|
||||||
|
<input name="redirect_feed" id="redirect_feed" type="checkbox" <% if user.preferences.redirect_feed %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="max_results">Number of videos shown in feed: </label>
|
<label for="max_results">Number of videos shown in feed: </label>
|
||||||
<input name="max_results" id="max_results" type="number" value="<%= user.preferences.max_results %>">
|
<input name="max_results" id="max_results" type="number" value="<%= user.preferences.max_results %>">
|
||||||
|
Loading…
Reference in New Issue
Block a user