Add simple form of cache busting

This commit is contained in:
Omar Roth 2019-05-08 08:58:10 -05:00
parent 59cbf95c4f
commit 4616f889fd
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2
8 changed files with 60 additions and 60 deletions

View file

@ -1845,12 +1845,12 @@ post "/data_control" do |env|
sleep 20.seconds sleep 20.seconds
env.response.puts %(<meta http-equiv="refresh" content="0; url=#{referer}">) env.response.puts %(<meta http-equiv="refresh" content="0; url=#{referer}">)
env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css">) env.response.puts %(<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>">)
env.response.puts %(<link rel="stylesheet" href="/css/default.css">) env.response.puts %(<link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">)
if env.get("preferences").as(Preferences).dark_mode if env.get("preferences").as(Preferences).dark_mode
env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css">) env.response.puts %(<link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>">)
else else
env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css">) env.response.puts %(<link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>">)
end end
env.response.puts %(<h3><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>) env.response.puts %(<h3><div class="loading"><i class="icon ion-ios-refresh"></i></div></h3>)
env.response.flush env.response.flush
@ -5351,7 +5351,7 @@ if Kemal.config.ssl
end end
static_headers do |response, filepath, filestat| static_headers do |response, filepath, filestat|
response.headers.add("Cache-Control", "max-age=86400") response.headers.add("Cache-Control", "max-age=2629800")
end end
public_folder "assets" public_folder "assets"

View file

@ -43,8 +43,8 @@
var player_data = { var player_data = {
aspect_ratio: '<%= aspect_ratio %>', aspect_ratio: '<%= aspect_ratio %>',
title: "<%= video.title.dump_unquoted %>", title: "<%= video.title.dump_unquoted %>",
description: "<%= description %>", description: "<%= HTML.escape(description) %>",
thumbnail: "<%= thumbnail %>" thumbnail: "<%= thumbnail %>"
} }
</script> </script>
<script src="/js/player.js"></script> <script src="/js/player.js?v=<%= CURRENT_COMMIT %>"></script>

View file

@ -1,22 +1,22 @@
<link rel="stylesheet" href="/css/video-js.min.css"> <link rel="stylesheet" href="/css/video-js.min.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-http-source-selector.css"> <link rel="stylesheet" href="/css/videojs-http-source-selector.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/videojs.markers.min.css"> <link rel="stylesheet" href="/css/videojs.markers.min.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-share.css"> <link rel="stylesheet" href="/css/videojs-share.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css"> <link rel="stylesheet" href="/css/videojs-vtt-thumbnails.css?v=<%= CURRENT_COMMIT %>">
<script src="/js/video.min.js"></script> <script src="/js/video.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs-contrib-quality-levels.min.js"></script> <script src="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs-http-source-selector.min.js"></script> <script src="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs.hotkeys.min.js"></script> <script src="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs-markers.min.js"></script> <script src="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs-share.min.js"></script> <script src="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>"></script>
<script src="/js/videojs-vtt-thumbnails.min.js"></script> <script src="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>"></script>
<% if params.annotations %> <% if params.annotations %>
<link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css"> <link rel="stylesheet" href="/css/videojs-youtube-annotations.min.css?v=<%= CURRENT_COMMIT %>">
<script src="/js/videojs-youtube-annotations.min.js"></script> <script src="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>"></script>
<% end %> <% end %>
<% if params.listen || params.quality != "dash" %> <% if params.listen || params.quality != "dash" %>
<link rel="stylesheet" href="/css/quality-selector.css"> <link rel="stylesheet" href="/css/quality-selector.css?v=<%= CURRENT_COMMIT %>">
<script src="/js/silvermine-videojs-quality-selector.min.js"></script> <script src="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>"></script>
<% end %> <% end %>

View file

@ -22,14 +22,14 @@
<script> <script>
var subscribe_data = { var subscribe_data = {
ucid: '<%= ucid %>', ucid: '<%= ucid %>',
author: '<%= author %>', author: '<%= HTML.escape(author) %>',
sub_count_text: '<%= sub_count_text %>', sub_count_text: '<%= HTML.escape(sub_count_text) %>',
csrf_token: '<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>', csrf_token: '<%= URI.escape(env.get?("csrf_token").try &.as(String) || "") %>',
subscribe_text: '<%= translate(locale, "Subscribe").gsub("'", "\\'") %>', subscribe_text: '<%= HTML.escape(translate(locale, "Subscribe")) %>',
unsubscribe_text: '<%= translate(locale, "Unsubscribe").gsub("'", "\\'") %>' unsubscribe_text: '<%= HTML.escape(translate(locale, "Unsubscribe")) %>'
} }
</script> </script>
<script src="/js/subscribe_widget.js"></script> <script src="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"></script>
<% else %> <% else %>
<p> <p>
<a id="subscribe" class="pure-button pure-button-primary" <a id="subscribe" class="pure-button pure-button-primary"

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="thumbnail" content="<%= thumbnail %>"> <meta name="thumbnail" content="<%= thumbnail %>">
<%= rendered "components/player_sources" %> <%= rendered "components/player_sources" %>
<link rel="stylesheet" href="/css/default.css"> <link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">
<title><%= HTML.escape(video.title) %> - Invidious</title> <title><%= HTML.escape(video.title) %> - Invidious</title>
<style> <style>
#player { #player {
@ -35,6 +35,6 @@ var video_data = {
</script> </script>
<%= rendered "components/player" %> <%= rendered "components/player" %>
<script src="/js/embed.js"></script> <script src="/js/embed.js?v=<%= CURRENT_COMMIT %>"></script>
</body> </body>
</html> </html>

View file

@ -11,7 +11,7 @@
<table id="jslicense-labels1"> <table id="jslicense-labels1">
<tr> <tr>
<td> <td>
<a href="/js/embed.js">embed.js</a> <a href="/js/embed.js?v=<%= CURRENT_COMMIT %>">embed.js</a>
</td> </td>
<td> <td>
@ -19,13 +19,13 @@
</td> </td>
<td> <td>
<a href="/js/embed.js"><%= translate(locale, "source") %></a> <a href="/js/embed.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/player.js">player.js</a> <a href="/js/player.js?v=<%= CURRENT_COMMIT %>">player.js</a>
</td> </td>
<td> <td>
@ -33,13 +33,13 @@
</td> </td>
<td> <td>
<a href="/js/player.js"><%= translate(locale, "source") %></a> <a href="/js/player.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/silvermine-videojs-quality-selector.min.js">silvermine-videojs-quality-selector.min.js</a> <a href="/js/silvermine-videojs-quality-selector.min.js?v=<%= CURRENT_COMMIT %>">silvermine-videojs-quality-selector.min.js</a>
</td> </td>
<td> <td>
@ -53,7 +53,7 @@
<tr> <tr>
<td> <td>
<a href="/js/subscribe_widget.js">subscribe_widget.js</a> <a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>">subscribe_widget.js</a>
</td> </td>
<td> <td>
@ -61,13 +61,13 @@
</td> </td>
<td> <td>
<a href="/js/subscribe_widget.js"><%= translate(locale, "source") %></a> <a href="/js/subscribe_widget.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<a href="/js/videojs-contrib-quality-levels.min.js">videojs-contrib-quality-levels.min.js</a> <a href="/js/videojs-contrib-quality-levels.min.js?v=<%= CURRENT_COMMIT %>">videojs-contrib-quality-levels.min.js</a>
</td> </td>
<td> <td>
@ -81,7 +81,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs.hotkeys.min.js">videojs.hotkeys.min.js</a> <a href="/js/videojs.hotkeys.min.js?v=<%= CURRENT_COMMIT %>">videojs.hotkeys.min.js</a>
</td> </td>
<td> <td>
@ -95,7 +95,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-http-source-selector.min.js">videojs-http-source-selector.min.js</a> <a href="/js/videojs-http-source-selector.min.js?v=<%= CURRENT_COMMIT %>">videojs-http-source-selector.min.js</a>
</td> </td>
<td> <td>
@ -109,7 +109,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-markers.min.js">videojs-markers.min.js</a> <a href="/js/videojs-markers.min.js?v=<%= CURRENT_COMMIT %>">videojs-markers.min.js</a>
</td> </td>
<td> <td>
@ -123,7 +123,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-share.min.js">videojs-share.min.js</a> <a href="/js/videojs-share.min.js?v=<%= CURRENT_COMMIT %>">videojs-share.min.js</a>
</td> </td>
<td> <td>
@ -137,7 +137,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-vtt-thumbnails.min.js">videojs-vtt-thumbnails.min.js</a> <a href="/js/videojs-vtt-thumbnails.min.js?v=<%= CURRENT_COMMIT %>">videojs-vtt-thumbnails.min.js</a>
</td> </td>
<td> <td>
@ -151,7 +151,7 @@
<tr> <tr>
<td> <td>
<a href="/js/videojs-youtube-annotations.min.js">videojs-youtube-annotations.min.js</a> <a href="/js/videojs-youtube-annotations.min.js?v=<%= CURRENT_COMMIT %>">videojs-youtube-annotations.min.js</a>
</td> </td>
<td> <td>
@ -165,7 +165,7 @@
<tr> <tr>
<td> <td>
<a href="/js/video.min.js">video.min.js</a> <a href="/js/video.min.js?v=<%= CURRENT_COMMIT %>">video.min.js</a>
</td> </td>
<td> <td>
@ -179,7 +179,7 @@
<tr> <tr>
<td> <td>
<a href="/js/watch.js">watch.js</a> <a href="/js/watch.js?v=<%= CURRENT_COMMIT %>">watch.js</a>
</td> </td>
<td> <td>
@ -187,7 +187,7 @@
</td> </td>
<td> <td>
<a href="/js/watch.js"><%= translate(locale, "source") %></a> <a href="/js/watch.js?v=<%= CURRENT_COMMIT %>"><%= translate(locale, "source") %></a>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -14,14 +14,14 @@
<meta name="msapplication-TileColor" content="#575757"> <meta name="msapplication-TileColor" content="#575757">
<meta name="theme-color" content="#575757"> <meta name="theme-color" content="#575757">
<link title="Invidious" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml"> <link title="Invidious" type="application/opensearchdescription+xml" rel="search" href="/opensearch.xml">
<link rel="stylesheet" href="/css/pure-min.css"> <link rel="stylesheet" href="/css/pure-min.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/grids-responsive-min.css"> <link rel="stylesheet" href="/css/grids-responsive-min.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/ionicons.min.css"> <link rel="stylesheet" href="/css/ionicons.min.css?v=<%= CURRENT_COMMIT %>">
<link rel="stylesheet" href="/css/default.css"> <link rel="stylesheet" href="/css/default.css?v=<%= CURRENT_COMMIT %>">
<% if env.get("preferences").as(Preferences).dark_mode %> <% if env.get("preferences").as(Preferences).dark_mode %>
<link rel="stylesheet" href="/css/darktheme.css"> <link rel="stylesheet" href="/css/darktheme.css?v=<%= CURRENT_COMMIT %>">
<% else %> <% else %>
<link rel="stylesheet" href="/css/lighttheme.css"> <link rel="stylesheet" href="/css/lighttheme.css?v=<%= CURRENT_COMMIT %>">
<% end %> <% end %>
</head> </head>

View file

@ -33,12 +33,12 @@ var video_data = {
length_seconds: '<%= video.info["length_seconds"].to_f %>', length_seconds: '<%= video.info["length_seconds"].to_f %>',
play_next: <%= !rvs.empty? && !plid && params.continue %>, play_next: <%= !rvs.empty? && !plid && params.continue %>,
next_video: '<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>', next_video: '<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>',
youtube_comments_text: '<%= translate(locale, "View YouTube comments") %>', youtube_comments_text: '<%= HTML.escape(translate(locale, "View YouTube comments")) %>',
reddit_comments_text: '<%= translate(locale, "View Reddit comments") %>', reddit_comments_text: '<%= HTML.escape(translate(locale, "View Reddit comments")) %>',
reddit_permalink_text: '<%= translate(locale, "View more comments on Reddit") %>', reddit_permalink_text: '<%= HTML.escape(translate(locale, "View more comments on Reddit")) %>',
comments_text: '<%= translate(locale, "View `x` comments", "{commentCount}") %>', comments_text: '<%= HTML.escape(translate(locale, "View `x` comments", "{commentCount}")) %>',
hide_replies_text: '<%= translate(locale, "Hide replies") %>', hide_replies_text: '<%= HTML.escape(translate(locale, "Hide replies")) %>',
show_replies_text: '<%= translate(locale, "Show replies") %>', show_replies_text: '<%= HTML.escape(translate(locale, "Show replies")) %>',
params: <%= params.to_json %>, params: <%= params.to_json %>,
preferences: <%= preferences.to_json %> preferences: <%= preferences.to_json %>
} }
@ -242,4 +242,4 @@ var video_data = {
</div> </div>
<% end %> <% end %>
</div> </div>
<script src="/js/watch.js"></script> <script src="/js/watch.js?v=<%= CURRENT_COMMIT %>"></script>