summaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-13 23:29:54 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-13 23:29:54 +0200
commit802e81f8551e10a3f97846a49636e675c7e21cb3 (patch)
treee7781b88465cc35f51ea1839d655b6507383a5b7 /app/helpers
parent0113d895e2fd8bf2cf88ae0196b9ab144ac9350b (diff)
Add cache-buster using mtime of css and js files outside the asset pipeline
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/admin_helper.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 08336ef..1e84620 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -8,4 +8,10 @@ module AdminHelper
8 link_to raw('<span class="inactive">English</span>'), url_for(params.permit(:locale, :page_path).to_h.merge('locale' => 'de')) 8 link_to raw('<span class="inactive">English</span>'), url_for(params.permit(:locale, :page_path).to_h.merge('locale' => 'de'))
9 end 9 end
10 end 10 end
11
12 def mtime_busted_path(path)
13 file = Rails.public_path.join(path.sub(%r{\A/}, ""))
14 raise "Static asset not found for cache-busting: #{path} (looked for #{file})" unless File.exist?(file)
15 "#{path}?v=#{File.mtime(file).to_i}"
16 end
11end 17end