From 8e4261100babc104c2e2738afae4787d21510c3c Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 11 Feb 2017 23:30:42 +0100 Subject: [PATCH] Create asterisk.png without digest after precompile fixes #7317 closes #7322 --- Changelog.md | 1 + config/application.rb | 3 +++ lib/tasks/assets.rake | 27 +++++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index d679a4ab8..b360d79b8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -15,6 +15,7 @@ * Fix autosize in modals [#7339](https://github.com/diaspora/diaspora/pull/7339) * Only display invite link on contacts page if invitations are enabled [#7342](https://github.com/diaspora/diaspora/pull/7342) * Fix regex for hashtags for some languages [#7350](https://github.com/diaspora/diaspora/pull/7350) +* Create asterisk.png without digest after precompile [#7322](https://github.com/diaspora/diaspora/pull/7322) ## Features * Add support for [Liberapay](https://liberapay.com) donations [#7290](https://github.com/diaspora/diaspora/pull/7290) diff --git a/config/application.rb b/config/application.rb index 617292212..98bf0609f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -86,6 +86,9 @@ module Diaspora # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + # See lib/tasks/assets.rake: non_digest_assets + config.assets.non_digest_assets = %w(branding/logos/asterisk.png) + # Configure generators values. Many other options are available, be sure to check the documentation. config.generators do |g| g.template_engine :haml diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 88147646b..9cbd410e2 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -10,9 +10,32 @@ namespace :assets do BookmarkletRenderer.compile end + desc "Create non digest assets" + task non_digest_assets: :environment do + logger = ::Logging::Logger["assets:non_digest_assets"] + + non_digest_assets = Diaspora::Application.config.assets.non_digest_assets + manifest_path = Dir.glob(File.join(Rails.root, "public/assets/manifest-*.json")).first + + JSON.load(File.new(manifest_path))["assets"].each do |logical_path, digested_path| + logical_pathname = Pathname.new(logical_path) + next unless non_digest_assets.any? {|testpath| logical_pathname.fnmatch?(testpath, File::FNM_PATHNAME) } + + full_digested_path = File.join(Rails.root, "public/assets", digested_path) + full_non_digested_path = File.join(Rails.root, "public/assets", logical_path) + + next unless FileUtils.uptodate?(full_digested_path, [full_non_digested_path]) + + logger.info "Copying #{full_digested_path} to #{full_non_digested_path}" + + FileUtils.copy_file(full_digested_path, full_non_digested_path, true) + end + end + # Augment precompile with error page generation task :precompile do - Rake::Task['assets:generate_error_pages'].invoke - Rake::Task['assets:uglify_bookmarklet'].invoke + Rake::Task["assets:generate_error_pages"].invoke + Rake::Task["assets:uglify_bookmarklet"].invoke + Rake::Task["assets:non_digest_assets"].invoke end end