summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-06-14 19:06:22 -0500
committerOmar Roth <omarroth@hotmail.com>2018-06-14 19:06:22 -0500
commit650b8a50fc67dae8cc1eb3186737b1ad20f74f44 (patch)
tree96774f0e0c75e875a5a94acfce1475dc5557a553
parent7234785145bf3d1cb60c7d8e8a4713e730295403 (diff)
downloadinvidious-650b8a50fc67dae8cc1eb3186737b1ad20f74f44.tar.gz
invidious-650b8a50fc67dae8cc1eb3186737b1ad20f74f44.tar.bz2
invidious-650b8a50fc67dae8cc1eb3186737b1ad20f74f44.zip
Add subscribe button to channel page
-rw-r--r--src/invidious.cr8
-rw-r--r--src/views/channel.ecr21
2 files changed, 29 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index d3c563c8..71a0f0b6 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -939,6 +939,14 @@ get "/videoplayback*" do |env|
end
get "/channel/:ucid" do |env|
+ authorized = env.get? "authorized"
+ if authorized
+ sid = env.get("sid").as(String)
+
+ subscriptions = PG_DB.query_one?("SELECT subscriptions FROM users WHERE id = $1", sid, as: Array(String))
+ end
+ subscriptions ||= [] of String
+
ucid = env.params.url["ucid"]
page = env.params.query["page"]?.try &.to_i
diff --git a/src/views/channel.ecr b/src/views/channel.ecr
index 857ad57a..e67dbfda 100644
--- a/src/views/channel.ecr
+++ b/src/views/channel.ecr
@@ -3,6 +3,27 @@
<% end %>
<h1><%= author %></h1>
+<% if authorized %>
+ <% if subscriptions.includes? ucid %>
+ <p>
+ <a href="/subscription_ajax?action_remove_subscriptions=1&c=<%= ucid %>">
+ <b>Unsubscribe from <%= author %></b>
+ </a>
+ </p>
+ <% else %>
+ <p>
+ <a href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>">
+ <b>Subscribe to <%= author %></b>
+ </a>
+ </p>
+ <% end %>
+<% else %>
+ <p>
+ <a href="/login">
+ <b>Login to subscribe to <%= author %></b>
+ </a>
+ </p>
+<% end %>
<% videos.each_slice(4) do |slice| %>
<div class="pure-g">
<% slice.each do |video| %>