Fix JSON serialization

This commit is contained in:
Omar Roth
2020-03-29 17:44:45 -04:00
parent 0e58d99f4e
commit 3b2e142542
10 changed files with 76 additions and 56 deletions

View File

@@ -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>

View File

@@ -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 %>