Add config opt. to view chan vid page by default

pull/2059/head
syeopite 3 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])
@ -160,6 +164,7 @@ class Invidious::Routes::PreferencesRoute < Invidious::Routes::BaseRoute
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