summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/views/add_playlist_items.ecr6
-rw-r--r--src/invidious/views/community.ecr16
-rw-r--r--src/invidious/views/components/player.ecr12
-rw-r--r--src/invidious/views/components/subscribe_widget.ecr16
-rw-r--r--src/invidious/views/embed.ecr20
-rw-r--r--src/invidious/views/history.ecr6
-rw-r--r--src/invidious/views/playlist.ecr6
-rw-r--r--src/invidious/views/subscriptions.ecr6
-rw-r--r--src/invidious/views/template.ecr10
-rw-r--r--src/invidious/views/watch.ecr34
10 files changed, 76 insertions, 56 deletions
diff --git a/src/invidious/views/add_playlist_items.ecr b/src/invidious/views/add_playlist_items.ecr
index dff0b549..07295c1a 100644
--- a/src/invidious/views/add_playlist_items.ecr
+++ b/src/invidious/views/add_playlist_items.ecr
@@ -21,9 +21,11 @@
</div>
<script id="playlist_data" type="application/json">
+<%=
{
- "csrf_token": "<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"
-}
+ "csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "")
+}.to_pretty_json
+%>
</script>
<script src="/js/playlist_widget.js"></script>
diff --git a/src/invidious/views/community.ecr b/src/invidious/views/community.ecr
index fca8c0b6..69724390 100644
--- a/src/invidious/views/community.ecr
+++ b/src/invidious/views/community.ecr
@@ -72,13 +72,15 @@
<% end %>
<script id="community_data" type="application/json">
+<%=
{
- "ucid": "<%= channel.ucid %>",
- "youtube_comments_text": "<%= HTML.escape(translate(locale, "View YouTube comments")) %>",
- "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")) %>",
- "preferences": <%= env.get("preferences").as(Preferences).to_json %>
-}
+ "ucid" => channel.ucid,
+ "youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
+ "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")),
+ "preferences" => env.get("preferences").as(Preferences)
+}.to_pretty_json
+%>
</script>
<script src="/js/community.js?v=<%= ASSET_COMMIT %>"></script>
diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr
index 520d72dd..3c30f69e 100644
--- a/src/invidious/views/components/player.ecr
+++ b/src/invidious/views/components/player.ecr
@@ -37,11 +37,13 @@
</video>
<script id="player_data" type="application/json">
+<%=
{
- "aspect_ratio": "<%= aspect_ratio %>",
- "title": "<%= video.title.dump_unquoted %>",
- "description": "<%= HTML.escape(video.short_description) %>",
- "thumbnail": "<%= thumbnail %>"
-}
+ "aspect_ratio" => aspect_ratio,
+ "title" => video.title,
+ "description" => HTML.escape(video.short_description),
+ "thumbnail" => thumbnail
+}.to_pretty_json
+%>
</script>
<script src="/js/player.js?v=<%= ASSET_COMMIT %>"></script>
diff --git a/src/invidious/views/components/subscribe_widget.ecr b/src/invidious/views/components/subscribe_widget.ecr
index 7c579a8a..ac2fbf1d 100644
--- a/src/invidious/views/components/subscribe_widget.ecr
+++ b/src/invidious/views/components/subscribe_widget.ecr
@@ -20,14 +20,16 @@
<% end %>
<script id="subscribe_data" type="application/json">
+ <%=
{
- "ucid": "<%= ucid %>",
- "author": "<%= HTML.escape(author) %>",
- "sub_count_text": "<%= HTML.escape(sub_count_text) %>",
- "csrf_token": "<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>",
- "subscribe_text": "<%= HTML.escape(translate(locale, "Subscribe")) %>",
- "unsubscribe_text": "<%= HTML.escape(translate(locale, "Unsubscribe")) %>"
- }
+ "ucid" => ucid,
+ "author" => HTML.escape(author),
+ "sub_count_text" => HTML.escape(sub_count_text),
+ "csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || ""),
+ "subscribe_text" => HTML.escape(translate(locale, "Subscribe")),
+ "unsubscribe_text" => HTML.escape(translate(locale, "Unsubscribe"))
+ }.to_pretty_json
+ %>
</script>
<script src="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% else %>
diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr
index ff8277e8..48dbc55f 100644
--- a/src/invidious/views/embed.ecr
+++ b/src/invidious/views/embed.ecr
@@ -16,16 +16,18 @@
<body>
<script id="video_data" type="application/json">
+<%=
{
- "id": "<%= video.id %>",
- "index": "<%= continuation %>",
- "plid": "<%= plid %>",
- "length_seconds": "<%= video.length_seconds.to_f %>",
- "video_series": <%= video_series.to_json %>,
- "params": <%= params.to_json %>,
- "preferences": <%= preferences.to_json %>,
- "premiere_timestamp": <%= video.premiere_timestamp.try &.to_unix || "null" %>
-}
+ "id" => video.id,
+ "index" => continuation,
+ "plid" => plid,
+ "length_seconds" => video.length_seconds.to_f,
+ "video_series" => video_series,
+ "params" => params,
+ "preferences" => preferences,
+ "premiere_timestamp" => video.premiere_timestamp.try &.to_unix
+}.to_pretty_json
+%>
</script>
<%= rendered "components/player" %>
diff --git a/src/invidious/views/history.ecr b/src/invidious/views/history.ecr
index 2aa8adf7..fe8c70b9 100644
--- a/src/invidious/views/history.ecr
+++ b/src/invidious/views/history.ecr
@@ -19,9 +19,11 @@
</div>
<script id="watched_data" type="application/json">
+<%=
{
- "csrf_token": "<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"
-}
+ "csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "")
+}.to_pretty_json
+%>
</script>
<script src="/js/watched_widget.js"></script>
diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr
index eff12c48..ccda94d9 100644
--- a/src/invidious/views/playlist.ecr
+++ b/src/invidious/views/playlist.ecr
@@ -70,9 +70,11 @@
<% if playlist.is_a?(InvidiousPlaylist) && playlist.author == user.try &.email %>
<script id="playlist_data" type="application/json">
+<%=
{
- "csrf_token": "<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"
-}
+ "csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "")
+}.to_pretty_json
+%>
</script>
<script src="/js/playlist_widget.js"></script>
<% end %>
diff --git a/src/invidious/views/subscriptions.ecr b/src/invidious/views/subscriptions.ecr
index 93c58471..af1d4fbc 100644
--- a/src/invidious/views/subscriptions.ecr
+++ b/src/invidious/views/subscriptions.ecr
@@ -46,9 +46,11 @@
</div>
<script id="watched_data" type="application/json">
+<%=
{
- "csrf_token": "<%= URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "") %>"
-}
+ "csrf_token" => URI.encode_www_form(env.get?("csrf_token").try &.as(String) || "")
+}.to_pretty_json
+%>
</script>
<script src="/js/watched_widget.js"></script>
diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr
index b239d22a..3a8d47dd 100644
--- a/src/invidious/views/template.ecr
+++ b/src/invidious/views/template.ecr
@@ -152,10 +152,12 @@
<% if env.get? "user" %>
<script src="/js/sse.js?v=<%= ASSET_COMMIT %>"></script>
<script id="notification_data" type="application/json">
- {
- "upload_text": "<%= HTML.escape(translate(locale, "`x` uploaded a video")) %>",
- "live_upload_text": "<%= HTML.escape(translate(locale, "`x` is live")) %>"
- }
+ <%=
+ {
+ "upload_text" => HTML.escape(translate(locale, "`x` uploaded a video")),
+ "live_upload_text" => HTML.escape(translate(locale, "`x` is live"))
+ }.to_pretty_json
+ %>
</script>
<script src="/js/notifications.js?v=<%= ASSET_COMMIT %>"></script>
<% end %>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 16ac71eb..2a99dd5b 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -27,23 +27,25 @@
<% end %>
<script id="video_data" type="application/json">
+<%=
{
- "id": "<%= video.id %>",
- "index": "<%= continuation %>",
- "plid": "<%= plid %>",
- "length_seconds": <%= video.length_seconds.to_f %>,
- "play_next": <%= !rvs.empty? && !plid && params.continue %>,
- "next_video": "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>",
- "youtube_comments_text": "<%= HTML.escape(translate(locale, "View YouTube comments")) %>",
- "reddit_comments_text": "<%= HTML.escape(translate(locale, "View Reddit comments")) %>",
- "reddit_permalink_text": "<%= HTML.escape(translate(locale, "View more comments on Reddit")) %>",
- "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": <%= params.to_json %>,
- "preferences": <%= preferences.to_json %>,
- "premiere_timestamp": <%= video.premiere_timestamp.try &.to_unix || "null" %>
-}
+ "id" => video.id,
+ "index" => continuation,
+ "plid" => plid,
+ "length_seconds" => video.length_seconds.to_f,
+ "play_next" => !rvs.empty? && !plid && params.continue,
+ "next_video" => rvs.select { |rv| rv["id"]? }[0]?.try &.["id"],
+ "youtube_comments_text" => HTML.escape(translate(locale, "View YouTube comments")),
+ "reddit_comments_text" => HTML.escape(translate(locale, "View Reddit comments")),
+ "reddit_permalink_text" => HTML.escape(translate(locale, "View more comments on Reddit")),
+ "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" => params,
+ "preferences" => preferences,
+ "premiere_timestamp" => video.premiere_timestamp.try &.to_unix
+}.to_pretty_json
+%>
</script>
<div id="player-container" class="h-box">