From 0feb414a1df50a60cadbb7795761b4c55545cf1c Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Thu, 20 Dec 2018 16:48:45 -0600 Subject: [PATCH] Add menu for selecting trending page --- src/invidious.cr | 3 +++ src/invidious/trending.cr | 2 +- src/invidious/views/trending.ecr | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index a1655044..d8d66c40 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1743,7 +1743,10 @@ get "/feed/trending" do |env| locale = LOCALES[env.get("locale").as(String)]? trending_type = env.params.query["type"]? + trending_type ||= "Default" + region = env.params.query["region"]? + region ||= "US" begin trending = fetch_trending(trending_type, proxies, region, locale) diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr index 453558d8..15630721 100644 --- a/src/invidious/trending.cr +++ b/src/invidious/trending.cr @@ -7,7 +7,7 @@ def fetch_trending(trending_type, proxies, region, locale) region = region.upcase trending = "" - if trending_type + if trending_type && trending_type != "Default" trending_type = trending_type.downcase.capitalize response = client.get("/feed/trending?gl=#{region}&hl=en", headers).body diff --git a/src/invidious/views/trending.ecr b/src/invidious/views/trending.ecr index d7a082d8..82d03b07 100644 --- a/src/invidious/views/trending.ecr +++ b/src/invidious/views/trending.ecr @@ -2,6 +2,32 @@ <%= translate(locale, "Trending") %> - Invidious <% end %> +
+
+
+
+
+
+
+ <% {"Default", "Music", "Gaming", "News", "Movies"}.each do |option| %> +
+ <% if trending_type == option %> + <%= translate(locale, option) %> + <% else %> + + <%= translate(locale, option) %> + + <% end %> +
+ <% end %> +
+
+
+ +
+
+
+
<% trending.each_slice(4) do |slice| %> <% slice.each do |item| %>