Add config opt. to view chan vid page by default

pull/2059/head
syeopite 4 years ago
parent faf4b7207b
commit b2a24bf0ae
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82

@ -309,7 +309,8 @@ Invidious::Routing.get "/", Invidious::Routes::Misc, :home
Invidious::Routing.get "/privacy", Invidious::Routes::Misc, :privacy Invidious::Routing.get "/privacy", Invidious::Routes::Misc, :privacy
Invidious::Routing.get "/licenses", Invidious::Routes::Misc, :licenses Invidious::Routing.get "/licenses", Invidious::Routes::Misc, :licenses
Invidious::Routing.get "/channel/:ucid", Invidious::Routes::Channels, :home Invidious::Routing.get "/channel/:ucid", Invidious::Routes::Channels, :channel
Invidious::Routing.get "/channel/:ucid/home", Invidious::Routes::Channels, :home
Invidious::Routing.get "/channel/:ucid/videos", Invidious::Routes::Channels, :videos Invidious::Routing.get "/channel/:ucid/videos", Invidious::Routes::Channels, :videos
Invidious::Routing.get "/channel/:ucid/playlists", Invidious::Routes::Channels, :playlists Invidious::Routing.get "/channel/:ucid/playlists", Invidious::Routes::Channels, :playlists
Invidious::Routing.get "/channel/:ucid/community", Invidious::Routes::Channels, :community Invidious::Routing.get "/channel/:ucid/community", Invidious::Routes::Channels, :community

@ -55,6 +55,7 @@ struct ConfigPreferences
property volume : Int32 = 100 property volume : Int32 = 100
property vr_mode : Bool = true property vr_mode : Bool = true
property show_nick : Bool = true property show_nick : Bool = true
property view_channel_homepage_by_default : Bool = true
def to_tuple def to_tuple
{% begin %} {% begin %}

@ -1,4 +1,12 @@
class Invidious::Routes::Channels < Invidious::Routes::BaseRoute class Invidious::Routes::Channels < Invidious::Routes::BaseRoute
def channel(env)
if !env.get("preferences").as(Preferences).view_channel_homepage_by_default
env.redirect "/channel/#{env.params.url["ucid"]}/videos"
else
env.redirect "/channel/#{env.params.url["ucid"]}/home"
end
end
def home(env) def home(env)
data = self.fetch_basic_information(env) data = self.fetch_basic_information(env)
if !data.is_a?(Tuple) if !data.is_a?(Tuple)

@ -72,6 +72,10 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
show_nick ||= "off" show_nick ||= "off"
show_nick = show_nick == "on" show_nick = show_nick == "on"
view_channel_homepage_by_default = env.params.body["view_channel_homepage_by_default"]?.try &.as(String)
view_channel_homepage_by_default ||= "off"
view_channel_homepage_by_default = view_channel_homepage_by_default == "on"
comments = [] of String comments = [] of String
2.times do |i| 2.times do |i|
comments << (env.params.body["comments[#{i}]"]?.try &.as(String) || CONFIG.default_user_preferences.comments[i]) comments << (env.params.body["comments[#{i}]"]?.try &.as(String) || CONFIG.default_user_preferences.comments[i])
@ -130,36 +134,37 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
# Convert to JSON and back again to take advantage of converters used for compatability # Convert to JSON and back again to take advantage of converters used for compatability
preferences = Preferences.from_json({ preferences = Preferences.from_json({
annotations: annotations, annotations: annotations,
annotations_subscribed: annotations_subscribed, annotations_subscribed: annotations_subscribed,
autoplay: autoplay, autoplay: autoplay,
captions: captions, captions: captions,
comments: comments, comments: comments,
continue: continue, continue: continue,
continue_autoplay: continue_autoplay, continue_autoplay: continue_autoplay,
dark_mode: dark_mode, dark_mode: dark_mode,
latest_only: latest_only, latest_only: latest_only,
listen: listen, listen: listen,
local: local, local: local,
locale: locale, locale: locale,
max_results: max_results, max_results: max_results,
notifications_only: notifications_only, notifications_only: notifications_only,
player_style: player_style, player_style: player_style,
quality: quality, quality: quality,
quality_dash: quality_dash, quality_dash: quality_dash,
default_home: default_home, default_home: default_home,
feed_menu: feed_menu, feed_menu: feed_menu,
automatic_instance_redirect: automatic_instance_redirect, automatic_instance_redirect: automatic_instance_redirect,
related_videos: related_videos, related_videos: related_videos,
sort: sort, sort: sort,
speed: speed, speed: speed,
thin_mode: thin_mode, thin_mode: thin_mode,
unseen_only: unseen_only, unseen_only: unseen_only,
video_loop: video_loop, video_loop: video_loop,
volume: volume, volume: volume,
extend_desc: extend_desc, extend_desc: extend_desc,
vr_mode: vr_mode, vr_mode: vr_mode,
show_nick: show_nick, show_nick: show_nick,
view_channel_homepage_by_default: view_channel_homepage_by_default,
}.to_json).to_json }.to_json).to_json
if user = env.get? "user" if user = env.get? "user"

@ -56,6 +56,7 @@ struct Preferences
property local : Bool = CONFIG.default_user_preferences.local property local : Bool = CONFIG.default_user_preferences.local
property vr_mode : Bool = CONFIG.default_user_preferences.vr_mode property vr_mode : Bool = CONFIG.default_user_preferences.vr_mode
property show_nick : Bool = CONFIG.default_user_preferences.show_nick property show_nick : Bool = CONFIG.default_user_preferences.show_nick
property view_channel_homepage_by_default : Bool = CONFIG.default_user_preferences.view_channel_homepage_by_default
@[JSON::Field(converter: Preferences::ProcessString)] @[JSON::Field(converter: Preferences::ProcessString)]
property locale : String = CONFIG.default_user_preferences.locale property locale : String = CONFIG.default_user_preferences.locale

@ -69,13 +69,13 @@
<ul class="pure-menu-list"> <ul class="pure-menu-list">
<% if content_type == 0 %> <% if content_type == 0 %>
<li class="pure-menu-item pure-menu-selected"> <li class="pure-menu-item pure-menu-selected">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>"> <a class="pure-menu-link" href="/channel/<%= channel.ucid %>/home">
<b> <%= translate(locale, "Home") %> </b> <b> <%= translate(locale, "Home") %> </b>
</a> </a>
</li> </li>
<% else %> <% else %>
<li class="pure-menu-item"> <li class="pure-menu-item">
<a class="pure-menu-link" href="/channel/<%= channel.ucid %>"> <a class="pure-menu-link" href="/channel/<%= channel.ucid %>/home">
<%= translate(locale, "Home") %> <%= translate(locale, "Home") %>
</a> </a>
</li> </li>

@ -189,6 +189,13 @@
<input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>> <input name="automatic_instance_redirect" id="automatic_instance_redirect" type="checkbox" <% if preferences.automatic_instance_redirect %>checked<% end %>>
</div> </div>
<div class="pure-control-group">
<label for="view_channel_homepage_by_default"><%= translate(locale, "View channel homepage by default: ") %></label>
<input name="view_channel_homepage_by_default" id="view_channel_homepage_by_default" type="checkbox" <% if preferences.view_channel_homepage_by_default %>checked<% end %>>
</div>
<% if env.get? "user" %> <% if env.get? "user" %>
<legend><%= translate(locale, "Subscription preferences") %></legend> <legend><%= translate(locale, "Subscription preferences") %></legend>

Loading…
Cancel
Save