Add support for community post page/comments (#4010)

This commit is contained in:
Samantaz Fox
2023-10-07 19:58:54 +02:00
14 changed files with 450 additions and 169 deletions

View File

@@ -26,7 +26,7 @@
<p><%= error_message %></p>
</div>
<% else %>
<div class="h-box pure-g" id="comments">
<div class="h-box pure-g comments" id="comments">
<%= IV::Frontend::Comments.template_youtube(items.not_nil!, locale, thin_mode) %>
</div>
<% end %>

View File

@@ -0,0 +1,48 @@
<% content_for "header" do %>
<title>Invidious</title>
<% end %>
<div>
<div id="post" class="comments post-comments">
<%= IV::Frontend::Comments.template_youtube(post_response.not_nil!, locale, thin_mode) %>
</div>
<% if nojs %>
<hr>
<% end %>
<br />
<div id="comments" class="comments post-comments">
<% if nojs %>
<%= comment_html %>
<% else %>
<noscript>
<a href="/post/<%= id %>?ucid=<%= ucid %>&nojs=1">
<%= translate(locale, "Hi! Looks like you have JavaScript turned off. Click here to view comments, keep in mind they may take a bit longer to load.") %>
</a>
</noscript>
<% end %>
</div>
</div>
<script id="video_data" type="application/json">
<%=
{
"id" => id,
"youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
"reddit_comments_text" => "",
"reddit_permalink_text" => "",
"comments_text" => HTML.escape(translate(locale, "View `x` comments", "{commentCount}")),
"hide_replies_text" => HTML.escape(translate(locale, "Hide replies")),
"show_replies_text" => HTML.escape(translate(locale, "Show replies")),
"params" => {
"comments": ["youtube"]
},
"preferences" => prefs,
"base_url" => "/api/v1/post/#{URI.encode_www_form(id)}/comments",
"ucid" => ucid
}.to_pretty_json
%>
</script>
<script src="/js/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/post.js?v=<%= ASSET_COMMIT %>"></script>

View File

@@ -64,7 +64,8 @@ we're going to need to do it here in order to allow for translations.
"premiere_timestamp" => video.premiere_timestamp.try &.to_unix,
"vr" => video.is_vr,
"projection_type" => video.projection_type,
"local_disabled" => CONFIG.disabled?("local")
"local_disabled" => CONFIG.disabled?("local"),
"support_reddit" => true
}.to_pretty_json
%>
</script>
@@ -270,7 +271,7 @@ we're going to need to do it here in order to allow for translations.
<hr>
<% end %>
<div id="comments">
<div id="comments" class="comments">
<% if nojs %>
<%= comment_html %>
<% else %>
@@ -352,4 +353,5 @@ we're going to need to do it here in order to allow for translations.
</div>
<% end %>
</div>
<script src="/js/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>