Add option to hide related videos

pull/143/head
Omar Roth 6 years ago
parent 6b3c9d23d0
commit cb01b50fbb

@ -799,6 +799,10 @@ post "/preferences" do |env|
captions_2 = env.params.body["captions_2"]?.try &.as(String) || "" captions_2 = env.params.body["captions_2"]?.try &.as(String) || ""
captions = [captions_0, captions_1, captions_2] 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 = env.params.body["redirect_feed"]?.try &.as(String)
redirect_feed ||= "off" redirect_feed ||= "off"
redirect_feed = redirect_feed == "on" redirect_feed = redirect_feed == "on"
@ -837,6 +841,7 @@ post "/preferences" do |env|
"volume" => volume, "volume" => volume,
"comments" => comments, "comments" => comments,
"captions" => captions, "captions" => captions,
"related_videos" => related_videos,
"redirect_feed" => redirect_feed, "redirect_feed" => redirect_feed,
"dark_mode" => dark_mode, "dark_mode" => dark_mode,
"thin_mode" => thin_mode, "thin_mode" => thin_mode,

@ -27,19 +27,20 @@ class User
end end
DEFAULT_USER_PREFERENCES = Preferences.from_json({ DEFAULT_USER_PREFERENCES = Preferences.from_json({
"video_loop" => false, "video_loop" => false,
"autoplay" => false, "autoplay" => false,
"speed" => 1.0, "speed" => 1.0,
"quality" => "hd720", "quality" => "hd720",
"volume" => 100, "volume" => 100,
"comments" => ["youtube", ""], "comments" => ["youtube", ""],
"captions" => ["", "", ""], "captions" => ["", "", ""],
"dark_mode" => false, "related_videos" => true,
"thin_mode " => false, "dark_mode" => false,
"max_results" => 40, "thin_mode " => false,
"sort" => "published", "max_results" => 40,
"latest_only" => false, "sort" => "published",
"unseen_only" => false, "latest_only" => false,
"unseen_only" => false,
}.to_json) }.to_json)
class Preferences class Preferences
@ -85,6 +86,10 @@ class Preferences
type: Bool, type: Bool,
default: false, default: false,
}, },
related_videos: {
type: Bool,
default: true,
},
dark_mode: Bool, dark_mode: Bool,
thin_mode: { thin_mode: {
type: Bool, type: Bool,

@ -75,7 +75,7 @@ function update_value(element) {
</div> </div>
<div class="pure-control-group"> <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"> <select class="pure-u-1-5" name="captions_1" id="captions_1">
<% CAPTION_LANGUAGES.each do |option| %> <% CAPTION_LANGUAGES.each do |option| %>
<option <% if user.preferences.captions[1] == option %> selected <% end %>><%= option %></option> <option <% if user.preferences.captions[1] == option %> selected <% end %>><%= option %></option>
@ -89,7 +89,13 @@ function update_value(element) {
</select> </select>
</div> </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> <legend>Visual preferences</legend>
<div class="pure-control-group"> <div class="pure-control-group">
<label for="dark_mode">Dark mode: </label> <label for="dark_mode">Dark mode: </label>
<input name="dark_mode" id="dark_mode" type="checkbox" <% if user.preferences.dark_mode %>checked<% end %>> <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> </div>
<legend>Subscription preferences</legend> <legend>Subscription preferences</legend>
<div class="pure-control-group"> <div class="pure-control-group">
<label for="redirect_feed">Redirect homepage to feed: </label> <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 %>> <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> </div>
<legend>Data preferences</legend> <legend>Data preferences</legend>
<div class="pure-control-group"> <div class="pure-control-group">
<a href="/clear_watch_history?referer=<%= referer %>">Clear watch history</a> <a href="/clear_watch_history?referer=<%= referer %>">Clear watch history</a>
</div> </div>

@ -113,6 +113,7 @@
</div> </div>
</div> </div>
<div class="pure-u-1 pure-u-md-1-5"> <div class="pure-u-1 pure-u-md-1-5">
<% if preferences && preferences.related_videos %>
<div class="h-box"> <div class="h-box">
<% rvs.each do |rv| %> <% rvs.each do |rv| %>
<% if rv.has_key?("id") %> <% if rv.has_key?("id") %>
@ -129,6 +130,7 @@
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
<% end %>
</div> </div>
</div> </div>

Loading…
Cancel
Save