diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-07-28 22:31:02 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-07-28 22:31:02 -0500 |
| commit | 0d23f25a8ced84083cc54b3bf0393d54dafa7ec9 (patch) | |
| tree | c3e6446d29012931c6f2fc36a428c27b9d591b12 | |
| parent | 09d78c9d3ab42ee8e80e96017fcb7d7434c79fde (diff) | |
| download | invidious-0d23f25a8ced84083cc54b3bf0393d54dafa7ec9.tar.gz invidious-0d23f25a8ced84083cc54b3bf0393d54dafa7ec9.tar.bz2 invidious-0d23f25a8ced84083cc54b3bf0393d54dafa7ec9.zip | |
Add option to redirect homepage to subscription feed
| -rw-r--r-- | src/invidious.cr | 35 | ||||
| -rw-r--r-- | src/invidious/helpers.cr | 5 | ||||
| -rw-r--r-- | src/invidious/views/preferences.ecr | 5 |
3 files changed, 34 insertions, 11 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index e7928e1b..137ce72a 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -258,6 +258,14 @@ before_all do |env| end 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" end @@ -1689,6 +1697,10 @@ post "/preferences" do |env| comments = env.params.body["comments"]? 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 ||= "off" dark_mode = dark_mode == "on" @@ -1708,17 +1720,18 @@ post "/preferences" do |env| latest_only = latest_only == "on" preferences = { - "video_loop" => video_loop, - "autoplay" => autoplay, - "speed" => speed, - "quality" => quality, - "volume" => volume, - "comments" => comments, - "dark_mode" => dark_mode, - "thin_mode" => thin_mode, - "max_results" => max_results, - "sort" => sort, - "latest_only" => latest_only, + "video_loop" => video_loop, + "autoplay" => autoplay, + "speed" => speed, + "quality" => quality, + "volume" => volume, + "comments" => comments, + "redirect_feed" => redirect_feed, + "dark_mode" => dark_mode, + "thin_mode" => thin_mode, + "max_results" => max_results, + "sort" => sort, + "latest_only" => latest_only, }.to_json PG_DB.exec("UPDATE users SET preferences = $1 WHERE email = $2", preferences, user.email) diff --git a/src/invidious/helpers.cr b/src/invidious/helpers.cr index a091d1e2..370e1efd 100644 --- a/src/invidious/helpers.cr +++ b/src/invidious/helpers.cr @@ -163,6 +163,11 @@ class Preferences nilable: true, default: "youtube", }, + redirect_feed: { + type: Bool, + nilable: true, + default: false, + }, dark_mode: Bool, thin_mode: { type: Bool, diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr index 9fd42d03..7f675bcc 100644 --- a/src/invidious/views/preferences.ecr +++ b/src/invidious/views/preferences.ecr @@ -69,6 +69,11 @@ function update_value(element) { <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"> <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 %>"> </div> |
