Invidious is an alternative front-end to YouTube
Use separate asset version for cache busting
Omar Rothfd8af884938e
diff --git a/src/invidious.cr b/src/invidious.crindex 2ef89ac3..25bd3672 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -53,6 +53,11 @@ CURRENT_BRANCH = {{ "#{`git branch | sed -n '/\* /s///p'`.strip}" }}CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }}CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }}+# This is used to determine the `?v=` on the end of file URLs (for cache busting). We+# only need to expire modified assets, so we can use this to find the last commit that changes+# any assets+ASSET_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit -- assets`.strip}" }}+SOFTWARE = {"name" => "invidious","version" => "#{CURRENT_VERSION}-#{CURRENT_COMMIT}",@@ -1854,12 +1859,12 @@ post "/data_control" do |env|sleep 20.secondsenv.response.puts %(<meta http-equiv="refresh" content="0; url=#{referer}">)- env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>">)- env.response.puts %(<link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">)+ env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css?v=#{ASSET_COMMIT}">)+ env.response.puts %(<link rel="stylesheet" href="/css/default.css?v=#{ASSET_COMMIT}">)if env.get("preferences").as(Preferences).dark_mode- env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>">)+ env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css?v=#{ASSET_COMMIT}">)else- env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>">)+ env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css?v=#{ASSET_COMMIT}">)endenv.response.puts %(<h3><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>)env.response.flushdiff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecrindex 3520ad29..a64ea39d 100644--- a/src/invidious/views/components/player.ecr+++ b/src/invidious/views/components/player.ecr@@ -47,4 +47,4 @@ var player_data = {thumbnail: "<%= thumbnail %>"}</script>-<script src="/js/player.js?v=<%= CURRENT_COMMIT %>"></script>+<script src="/js/player.js?v=<%= ASSET_COMMIT %>"></script>diff --git a/src/invidious/views/components/player_sources.ecr b/src/invidious/views/components/player_sources.ecrindex ed1239cc..003d2c3a 100644--- a/src/invidious/views/components/player_sources.ecr+++ b/src/invidious/views/components/player_sources.ecr@@ -1,22 +1,22 @@-<link rel="stylesheet" href="/css/video-js.min.css?v=<%= CURRENT_COMMIT %>">-<link rel="stylesheet" href="/css/videojs-http-source-selector.css?v=<%= CURRENT_COMMIT %>">-<link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= CURRENT_COMMIT %>">-<link rel="stylesheet" href="/css/videojs-share.css?v=<%= CURRENT_COMMIT %>">-<link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= CURRENT_COMMIT %>">-<script src="/js/video.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>"></script>-<script src="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>"></script>+<link rel="stylesheet" href="/css/video-js.min.css?v=<%= ASSET_COMMIT %>">+<link rel="stylesheet" href="/css/videojs-http-source-selector.css?v=<%= ASSET_COMMIT %>">+<link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= ASSET_COMMIT %>">+<link rel="stylesheet" href="/css/videojs-share.css?v=<%= ASSET_COMMIT %>">+<link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= ASSET_COMMIT %>">+<script src="/js/video.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs-contrib-quality-levels.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs-http-source-selector.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs.hotkeys.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs-share.min.js?v=<%= ASSET_COMMIT %>"></script>+<script src="/js/videojs-vtt-thumbnails.min.js?v=<%= ASSET_COMMIT %>"></script><% if params.annotations %>- <link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= CURRENT_COMMIT %>">- <script src="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>"></script>+ <link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= ASSET_COMMIT %>">+ <script src="/js/videojs-youtube-annotations.min.js?v=<%= ASSET_COMMIT %>"></script><% end %><% if params.listen || params.quality != "dash" %>- <link rel="stylesheet" href="/css/quality-selector.css?v=<%= CURRENT_COMMIT %>">- <script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>"></script>+ <link rel="stylesheet" href="/css/quality-selector.css?v=<%= ASSET_COMMIT %>">+ <script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= ASSET_COMMIT %>"></script><% end %>diff --git a/src/invidious/views/components/subscribe_widget.ecr b/src/invidious/views/components/subscribe_widget.ecrindex e555d6c5..1d9966b3 100644--- a/src/invidious/views/components/subscribe_widget.ecr+++ b/src/invidious/views/components/subscribe_widget.ecr@@ -29,7 +29,7 @@unsubscribe_text: '<%= HTML.escape(translate(locale, "Unsubscribe")) %>'}</script>- <script src="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"></script>+ <script src="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script><% else %><p><a id="subscribe" class="pure-button pure-button-primary"diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecrindex ebe63e40..32abd626 100644--- a/src/invidious/views/embed.ecr+++ b/src/invidious/views/embed.ecr@@ -6,7 +6,7 @@<meta name="viewport" content="width=device-width, initial-scale=1"><meta name="thumbnail" content="<%= thumbnail %>"><%= rendered "components/player_sources" %>- <link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">+ <link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>"><title><%= HTML.escape(video.title) %> - Invidious</title><style>#player {@@ -35,6 +35,6 @@ var video_data = {</script><%= rendered "components/player" %>-<script src="/js/embed.js?v=<%= CURRENT_COMMIT %>"></script>+<script src="/js/embed.js?v=<%= ASSET_COMMIT %>"></script></body></html>diff --git a/src/invidious/views/licenses.ecr b/src/invidious/views/licenses.ecrindex 254eea14..44e8350b 100644--- a/src/invidious/views/licenses.ecr+++ b/src/invidious/views/licenses.ecr@@ -11,7 +11,7 @@<table id="jslicense-labels1"><tr><td>- <a href="/js/embed.js?v=<%= CURRENT_COMMIT %>">embed.js</a>+ <a href="/js/embed.js?v=<%= ASSET_COMMIT %>">embed.js</a></td><td>@@ -19,13 +19,13 @@</td><td>- <a href="/js/embed.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>+ <a href="/js/embed.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a></td></tr><tr><td>- <a href="/js/player.js?v=<%= CURRENT_COMMIT %>">player.js</a>+ <a href="/js/player.js?v=<%= ASSET_COMMIT %>">player.js</a></td><td>@@ -33,13 +33,13 @@</td><td>- <a href="/js/player.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>+ <a href="/js/player.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a></td></tr><tr><td>- <a href="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>">silvermine-videojs-quality-selector.min.js</a>+ <a href="/js/silvermine-videojs-quality-selector.min.js?v=<%= ASSET_COMMIT %>">silvermine-videojs-quality-selector.min.js</a></td><td>@@ -53,7 +53,7 @@<tr><td>- <a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>">subscribe_widget.js</a>+ <a href="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>">subscribe_widget.js</a></td><td>@@ -61,13 +61,13 @@</td><td>- <a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>+ <a href="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a></td></tr><tr><td>- <a href="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>">videojs-contrib-quality-levels.min.js</a>+ <a href="/js/videojs-contrib-quality-levels.min.js?v=<%= ASSET_COMMIT %>">videojs-contrib-quality-levels.min.js</a></td><td>@@ -81,7 +81,7 @@<tr><td>- <a href="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>">videojs.hotkeys.min.js</a>+ <a href="/js/videojs.hotkeys.min.js?v=<%= ASSET_COMMIT %>">videojs.hotkeys.min.js</a></td><td>@@ -95,7 +95,7 @@<tr><td>- <a href="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>">videojs-http-source-selector.min.js</a>+ <a href="/js/videojs-http-source-selector.min.js?v=<%= ASSET_COMMIT %>">videojs-http-source-selector.min.js</a></td><td>@@ -109,7 +109,7 @@<tr><td>- <a href="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>">videojs-markers.min.js</a>+ <a href="/js/videojs-markers.min.js?v=<%= ASSET_COMMIT %>">videojs-markers.min.js</a></td><td>@@ -123,7 +123,7 @@<tr><td>- <a href="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>">videojs-share.min.js</a>+ <a href="/js/videojs-share.min.js?v=<%= ASSET_COMMIT %>">videojs-share.min.js</a></td><td>@@ -137,7 +137,7 @@<tr><td>- <a href="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>">videojs-vtt-thumbnails.min.js</a>+ <a href="/js/videojs-vtt-thumbnails.min.js?v=<%= ASSET_COMMIT %>">videojs-vtt-thumbnails.min.js</a></td><td>@@ -151,7 +151,7 @@<tr><td>- <a href="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>">videojs-youtube-annotations.min.js</a>+ <a href="/js/videojs-youtube-annotations.min.js?v=<%= ASSET_COMMIT %>">videojs-youtube-annotations.min.js</a></td><td>@@ -165,7 +165,7 @@<tr><td>- <a href="/js/video.min.js?v=<%= CURRENT_COMMIT %>">video.min.js</a>+ <a href="/js/video.min.js?v=<%= ASSET_COMMIT %>">video.min.js</a></td><td>@@ -179,7 +179,7 @@<tr><td>- <a href="/js/watch.js?v=<%= CURRENT_COMMIT %>">watch.js</a>+ <a href="/js/watch.js?v=<%= ASSET_COMMIT %>">watch.js</a></td><td>@@ -187,7 +187,7 @@</td><td>- <a href="/js/watch.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>+ <a href="/js/watch.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a></td></tr></table>diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecrindex 247e36b4..6b6f74fa 100644--- a/src/invidious/views/template.ecr+++ b/src/invidious/views/template.ecr@@ -6,20 +6,20 @@<meta name="viewport" content="width=device-width, initial-scale=1"><meta name="referrer" content="no-referrer"><%= yield_content "header" %>- <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">- <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">- <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">- <link rel="manifest" href="/site.webmanifest">- <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#575757">+ <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=<%= ASSET_COMMIT %>">+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=<%= ASSET_COMMIT %>">+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=<%= ASSET_COMMIT %>">+ <link rel="manifest" href="/site.webmanifest?v=<%= ASSET_COMMIT %>">+ <link rel="mask-icon" href="/safari-pinned-tab.svg?v=<%= ASSET_COMMIT %>" color="#575757"><meta name="msapplication-TileColor" content="#575757"><meta name="theme-color" content="#575757"><link title="Invidious" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml">- <link rel="stylesheet" href="/css/pure-min.css?v=<%= CURRENT_COMMIT %>">- <link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= CURRENT_COMMIT %>">- <link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>">- <link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">- <link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>" id="dark_theme" <% if !env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>>- <link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>" id="light_theme" <% if env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>>+ <link rel="stylesheet" href="/css/pure-min.css?v=<%= ASSET_COMMIT %>">+ <link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= ASSET_COMMIT %>">+ <link rel="stylesheet" href="/css/ionicons.min.css?v=<%= ASSET_COMMIT %>">+ <link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">+ <link rel="stylesheet" href="/css/darktheme.css?v=<%= ASSET_COMMIT %>" id="dark_theme" <% if !env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>>+ <link rel="stylesheet" href="/css/lighttheme.css?v=<%= ASSET_COMMIT %>" id="light_theme" <% if env.get("preferences").as(Preferences).dark_mode %>media="none"<% end %>></head><% locale = LOCALES[env.get("preferences").as(Preferences).locale]? %>@@ -150,7 +150,7 @@</div><div class="pure-u-1 pure-u-md-2-24"></div></div>- <script src="/js/themes.js?v=<%= CURRENT_COMMIT %>"></script>+ <script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script></body></html>diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecrindex ec400b24..d0dba85e 100644--- a/src/invidious/views/watch.ecr+++ b/src/invidious/views/watch.ecr@@ -242,4 +242,4 @@ var video_data = {</div><% end %></div>-<script src="/js/watch.js?v=<%= CURRENT_COMMIT %>"></script>+<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>