Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -712,20 +712,20 @@ default_user_preferences:
## when the user is logged in.
##
## Accepted values: A list of strings
## Each entry can be one of: "Popular", "Trending",
## Each entry can be one of: "Popular",
## "Subscriptions", "Playlists"
##
## Default: ["Popular", "Trending", "Subscriptions", "Playlists"] (show all feeds)
## Default: ["Popular", "Subscriptions", "Playlists"] (show all feeds)
##
#feed_menu: ["Popular", "Trending", "Subscriptions", "Playlists"]
#feed_menu: ["Popular", "Subscriptions", "Playlists"]

##
## Default feed to display on the home page.
##
## Note: setting this option to "Popular" has no
## effect when 'popular_enabled' is set to false.
##
## Accepted values: Popular, Trending, Subscriptions, Playlists, <none>
## Accepted values: Popular, Subscriptions, Playlists, <none>
## Default: Popular
##
#default_home: Popular
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require "../src/invidious/videos/caption"
require "../src/invidious/videos"
require "../src/invidious/playlists"
require "../src/invidious/search/ctoken"
require "../src/invidious/trending"
require "spectator"

Spectator.configure do |config|
Expand Down
2 changes: 1 addition & 1 deletion src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ConfigPreferences
property quality : String = "dash"
property quality_dash : String = "auto"
property default_home : String? = "Popular"
property feed_menu : Array(String) = ["Popular", "Trending", "Subscriptions", "Playlists"]
property feed_menu : Array(String) = ["Popular", "Subscriptions", "Playlists"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that we should log a warning if feed_menu contains Trending in the server config?

property automatic_instance_redirect : Bool = false
property region : String = "US"
property related_videos : Bool = true
Expand Down
25 changes: 0 additions & 25 deletions src/invidious/routes/api/v1/feeds.cr
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
module Invidious::Routes::API::V1::Feeds
def self.trending(env)
locale = env.get("preferences").as(Preferences).locale

env.response.content_type = "application/json"

region = env.params.query["region"]?
trending_type = env.params.query["type"]?

begin
trending, plid = fetch_trending(trending_type, region, locale)
rescue ex
return error_json(500, ex)
end

videos = JSON.build do |json|
json.array do
trending.each do |video|
video.to_json(locale, json)
end
end
end

videos
end

def self.popular(env)
locale = env.get("preferences").as(Preferences).locale

Expand Down
18 changes: 0 additions & 18 deletions src/invidious/routes/feeds.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ module Invidious::Routes::Feeds
end
end

def self.trending(env)
locale = env.get("preferences").as(Preferences).locale

trending_type = env.params.query["type"]?
trending_type ||= "Default"

region = env.params.query["region"]?
region ||= env.get("preferences").as(Preferences).region

begin
trending, plid = fetch_trending(trending_type, region, locale)
rescue ex
return error_template(500, ex)
end

templated "feeds/trending"
end

def self.subscriptions(env)
locale = env.get("preferences").as(Preferences).locale

Expand Down
2 changes: 0 additions & 2 deletions src/invidious/routes/misc.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ module Invidious::Routes::Misc
case preferences.default_home
when "Popular"
env.redirect "/feed/popular"
when "Trending"
env.redirect "/feed/trending"
when "Subscriptions"
if user
env.redirect "/feed/subscriptions"
Expand Down
4 changes: 2 additions & 2 deletions src/invidious/routes/preferences.cr
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module Invidious::Routes::PreferencesRoute
default_home = env.params.body["default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home

feed_menu = [] of String
4.times do |index|
3.times do |index|
option = env.params.body["feed_menu[#{index}]"]?.try &.as(String) || ""
if !option.empty?
feed_menu << option
Expand Down Expand Up @@ -194,7 +194,7 @@ module Invidious::Routes::PreferencesRoute
CONFIG.default_user_preferences.default_home = env.params.body["admin_default_home"]?.try &.as(String) || CONFIG.default_user_preferences.default_home

admin_feed_menu = [] of String
4.times do |index|
3.times do |index|
option = env.params.body["admin_feed_menu[#{index}]"]?.try &.as(String) || ""
if !option.empty?
admin_feed_menu << option
Expand Down
2 changes: 0 additions & 2 deletions src/invidious/routing.cr
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ module Invidious::Routing
get "/view_all_playlists", Routes::Feeds, :view_all_playlists_redirect
get "/feed/playlists", Routes::Feeds, :playlists
get "/feed/popular", Routes::Feeds, :popular
get "/feed/trending", Routes::Feeds, :trending
get "/feed/subscriptions", Routes::Feeds, :subscriptions
get "/feed/history", Routes::Feeds, :history

Expand Down Expand Up @@ -249,7 +248,6 @@ module Invidious::Routing
get "/api/v1/transcripts/:id", {{namespace}}::Videos, :transcripts

# Feeds
get "/api/v1/trending", {{namespace}}::Feeds, :trending
get "/api/v1/popular", {{namespace}}::Feeds, :popular

# Channels
Expand Down
47 changes: 0 additions & 47 deletions src/invidious/trending.cr

This file was deleted.

7 changes: 7 additions & 0 deletions src/invidious/views/components/feed_menu.ecr
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<div class="feed-menu">
<% feed_menu = env.get("preferences").as(Preferences).feed_menu.dup %>
<%
# Remove the Trending page from the menu for users with the Trending
# item inside their PREFS cookie or in their user preferences saved
# in the database (if registered user)
# https://github.com/iv-org/invidious/issues/5397
%>
<% feed_menu.reject! {|item| "Trending" == item} %>
Comment on lines +3 to +9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is a good way to remove the Trending page from the feed menu. Registered users and unregistered users with the PREFS cookie set with Trending inside their feed_menu preferences will get the Trending option in their Feed menu, but since Trending is removed, is going to be a dead option that does nothing. So I did this to basically strip Trending from the feed menu if it's available on the user preferences.

Registered users and unregistered users will have to save their preferences again in order to remove Trending from their feed_menu preferences.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me!

<% if !env.get?("user") %>
<% feed_menu.reject! {|item| {"Subscriptions", "Playlists"}.includes? item} %>
<% end %>
Expand Down
49 changes: 0 additions & 49 deletions src/invidious/views/feeds/trending.ecr

This file was deleted.

4 changes: 2 additions & 2 deletions src/invidious/views/user/preferences.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@
</div>

<% if env.get?("user") %>
<% feed_options = {"", "Popular", "Trending", "Subscriptions", "Playlists"} %>
<% feed_options = {"", "Popular", "Subscriptions", "Playlists"} %>
<% else %>
<% feed_options = {"", "Popular", "Trending"} %>
<% feed_options = {"", "Popular"} %>
<% end %>

<div class="pure-control-group">
Expand Down
Loading