summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-30 16:49:38 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-30 16:49:38 -0500
commitcb01b50fbb6243557e6b4bdc58486158d906dd11 (patch)
tree00a8f1edbfee572aee362ad081f5c5b5d6e8538d /src
parent6b3c9d23d025148da76f1b24dd968d61ae3a882a (diff)
downloadinvidious-cb01b50fbb6243557e6b4bdc58486158d906dd11.tar.gz
invidious-cb01b50fbb6243557e6b4bdc58486158d906dd11.tar.bz2
invidious-cb01b50fbb6243557e6b4bdc58486158d906dd11.zip
Add option to hide related videos
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr5
-rw-r--r--src/invidious/users.cr31
-rw-r--r--src/invidious/views/preferences.ecr10
-rw-r--r--src/invidious/views/watch.ecr2
4 files changed, 34 insertions, 14 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index d898176c..dc52467e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -799,6 +799,10 @@ post "/preferences" do |env|
captions_2 = env.params.body["captions_2"]?.try &.as(String) || ""
captions = [captions_0, captions_1, captions_2]
+ related_videos = env.params.body["related_videos"]?.try &.as(String)
+ related_videos ||= "off"
+ related_videos = related_videos == "on"
+
redirect_feed = env.params.body["redirect_feed"]?.try &.as(String)
redirect_feed ||= "off"
redirect_feed = redirect_feed == "on"
@@ -837,6 +841,7 @@ post "/preferences" do |env|
"volume" => volume,
"comments" => comments,
"captions" => captions,
+ "related_videos" => related_videos,
"redirect_feed" => redirect_feed,
"dark_mode" => dark_mode,
"thin_mode" => thin_mode,
diff --git a/src/invidious/users.cr b/src/invidious/users.cr
index 7ffd5400..fa3a5f6e 100644
--- a/src/invidious/users.cr
+++ b/src/invidious/users.cr
@@ -27,19 +27,20 @@ class User
end
DEFAULT_USER_PREFERENCES = Preferences.from_json({
- "video_loop" => false,
- "autoplay" => false,
- "speed" => 1.0,
- "quality" => "hd720",
- "volume" => 100,
- "comments" => ["youtube", ""],
- "captions" => ["", "", ""],
- "dark_mode" => false,
- "thin_mode " => false,
- "max_results" => 40,
- "sort" => "published",
- "latest_only" => false,
- "unseen_only" => false,
+ "video_loop" => false,
+ "autoplay" => false,
+ "speed" => 1.0,
+ "quality" => "hd720",
+ "volume" => 100,
+ "comments" => ["youtube", ""],
+ "captions" => ["", "", ""],
+ "related_videos" => true,
+ "dark_mode" => false,
+ "thin_mode " => false,
+ "max_results" => 40,
+ "sort" => "published",
+ "latest_only" => false,
+ "unseen_only" => false,
}.to_json)
class Preferences
@@ -85,6 +86,10 @@ class Preferences
type: Bool,
default: false,
},
+ related_videos: {
+ type: Bool,
+ default: true,
+ },
dark_mode: Bool,
thin_mode: {
type: Bool,
diff --git a/src/invidious/views/preferences.ecr b/src/invidious/views/preferences.ecr
index 5ee98141..cdd2eb42 100644
--- a/src/invidious/views/preferences.ecr
+++ b/src/invidious/views/preferences.ecr
@@ -75,7 +75,7 @@ function update_value(element) {
</div>
<div class="pure-control-group">
- <label for="captions_fallback">Fallback languages: </label>
+ <label for="captions_fallback">Fallback captions: </label>
<select class="pure-u-1-5" name="captions_1" id="captions_1">
<% CAPTION_LANGUAGES.each do |option| %>
<option <% if user.preferences.captions[1] == option %> selected <% end %>><%= option %></option>
@@ -89,7 +89,13 @@ function update_value(element) {
</select>
</div>
+ <div class="pure-control-group">
+ <label for="related_videos">Show related videos? </label>
+ <input name="related_videos" id="related_videos" type="checkbox" <% if user.preferences.related_videos %>checked<% end %>>
+ </div>
+
<legend>Visual preferences</legend>
+
<div class="pure-control-group">
<label for="dark_mode">Dark mode: </label>
<input name="dark_mode" id="dark_mode" type="checkbox" <% if user.preferences.dark_mode %>checked<% end %>>
@@ -101,6 +107,7 @@ function update_value(element) {
</div>
<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 %>>
@@ -136,6 +143,7 @@ function update_value(element) {
</div>
<legend>Data preferences</legend>
+
<div class="pure-control-group">
<a href="/clear_watch_history?referer=<%= referer %>">Clear watch history</a>
</div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index b90c46aa..223af75f 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -113,6 +113,7 @@
</div>
</div>
<div class="pure-u-1 pure-u-md-1-5">
+ <% if preferences && preferences.related_videos %>
<div class="h-box">
<% rvs.each do |rv| %>
<% if rv.has_key?("id") %>
@@ -129,6 +130,7 @@
<% end %>
<% end %>
</div>
+ <% end %>
</div>
</div>