From 17bc9349a8555f7b261b714333500501911704e4 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:02:07 -0400 Subject: [PATCH 1/6] Allow viewing more comments when js is disabled --- src/invidious/channels/community.cr | 2 +- src/invidious/comments/youtube.cr | 7 ++-- src/invidious/frontend/comments_youtube.cr | 15 +++++-- src/invidious/routes/api/v1/channels.cr | 3 +- src/invidious/routes/channels.cr | 3 +- src/invidious/routes/watch.cr | 49 ++++++++++++++++++++++ src/invidious/routing.cr | 2 + src/invidious/views/comments_no_js.ecr | 9 ++++ src/invidious/views/community.ecr | 3 +- src/invidious/views/post.ecr | 3 +- src/invidious/views/watch.ecr | 1 + 11 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 src/invidious/views/comments_no_js.ecr diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 49ffd990..bdfbc27c 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -279,7 +279,7 @@ def extract_channel_community(items, *, ucid, locale, format, thin_mode, is_sing if format == "html" response = JSON.parse(response) - content_html = IV::Frontend::Comments.template_youtube(response, locale, thin_mode) + content_html = IV::Frontend::Comments.template_youtube(response, locale, thin_mode, ucid, "community") response = JSON.build do |json| json.object do diff --git a/src/invidious/comments/youtube.cr b/src/invidious/comments/youtube.cr index 0716fcde..ec5adf65 100644 --- a/src/invidious/comments/youtube.cr +++ b/src/invidious/comments/youtube.cr @@ -57,7 +57,7 @@ module Invidious::Comments return initial_data end - def parse_youtube(id, response, format, locale, thin_mode, sort_by = "top", is_post = false) + def parse_youtube(id, response, format, locale, thin_mode, type="video", sort_by = "top") contents = nil if on_response_received_endpoints = response["onResponseReceivedEndpoints"]? @@ -115,7 +115,7 @@ module Invidious::Comments json.field "commentCount", comment_count end - if is_post + if type == "post" json.field "postId", id else json.field "videoId", id @@ -302,7 +302,8 @@ module Invidious::Comments if format == "html" response = JSON.parse(response) - content_html = Frontend::Comments.template_youtube(response, locale, thin_mode) + content_html = Frontend::Comments.template_youtube(response, locale, thin_mode, id, type) + response = JSON.build do |json| json.object do json.field "contentHtml", content_html diff --git a/src/invidious/frontend/comments_youtube.cr b/src/invidious/frontend/comments_youtube.cr index a0e1d783..fb9b3223 100644 --- a/src/invidious/frontend/comments_youtube.cr +++ b/src/invidious/frontend/comments_youtube.cr @@ -1,7 +1,7 @@ module Invidious::Frontend::Comments extend self - def template_youtube(comments, locale, thin_mode, is_replies = false) + def template_youtube(comments, locale, thin_mode, id, type="video", is_replies = false) String.build do |html| root = comments["comments"].as_a root.each do |child| @@ -13,11 +13,15 @@ module Invidious::Frontend::Comments ) replies_html = <<-END_HTML -