Add /subscription_manager

This commit is contained in:
Omar Roth 2018-07-05 19:48:55 -05:00
parent 1ada71e5ba
commit 431fa642bf
4 changed files with 40 additions and 1 deletions

View file

@ -806,6 +806,24 @@ get "/modify_notifications" do |env|
env.redirect referer
end
get "/subscription_manager" do |env|
authorized = env.get? "authorized"
if !authorized
next env.redirect "/"
end
subscriptions = env.get?("subscriptions").as(Array(String))
subscriptions ||= [] of String
client = make_client(YT_URL)
subscriptions = subscriptions.map do |ucid|
get_channel(ucid, client, PG_DB, false)
end
subscriptions.sort_by! { |channel| channel.author.downcase }
templated "subscription_manager"
end
get "/subscription_ajax" do |env|
authorized = env.get? "authorized"
referer = env.request.headers["referer"]?

View file

@ -2,7 +2,7 @@
<div class="h-box">
<a style="width:100%;" href="/watch?v=<%= video.id %>">
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
<p style="height:100%"><%= video.title %></p>
<p><%= video.title %></p>
</a>
<p>
<b><a style="width:100%;" href="/channel/<%= video.ucid %>"><%= video.author %></a></b>

View file

@ -0,0 +1,19 @@
<% content_for "header" do %>
<title>Subscription manager - Invidious</title>
<% end %>
<h1><%= subscriptions.size %> subscriptions</h1>
<% subscriptions.each do |channel| %>
<h3 class="h-box">
<div class="pure-g">
<div class="pure-u-2-5">
<a href="/channel/<%= channel.id %>"><%= channel.author %></a>
</div>
<div class="pure-u-2-5"></div>
<div class="pure-u-1-5">
<a style="vertical-align: right;" href="/subscription_ajax?action_remove_subscriptions=1&c=<%= channel.id %>">unsubscribe</a>
</div>
</div>
</h3>
<% end %>

View file

@ -2,6 +2,8 @@
<title>Subscriptions - Invidious</title>
<% end %>
<h3><a href="/subscription_manager">View all subscriptions</a></h3>
<% if !notifications.empty? %>
<% notifications.each_slice(4) do |slice| %>
<div class="pure-g">