From 8e4261100babc104c2e2738afae4787d21510c3c Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 11 Feb 2017 23:30:42 +0100 Subject: [PATCH 1/2] 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 From 10935d623bc3dc950dafa54e7025565a4b03873e Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 4 Mar 2017 22:56:11 +0100 Subject: [PATCH 2/2] Pin thor to prevent accidental upgrades Thor was upgraded again in #7345, but there are still "warnings" looking like errors when using "db:migrate" for example. So lets pin it until it is safe to upgrade. closes #7351 --- Gemfile | 6 ++++++ Gemfile.lock | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1000c422d..aa5951a1f 100644 --- a/Gemfile +++ b/Gemfile @@ -203,6 +203,12 @@ gem "minitest" gem "versionist", "1.5.0" +# Prevent accidental upgrades of thor +# TODO: remove this when either all gems depending on thor have fixed the warnings +# or thor released a version where they are clearly marked as warnings +# see: https://github.com/erikhuda/thor/issues/538 +gem "thor", "0.19.1" + # Windows and OSX have an execjs compatible runtime built-in, Linux users should # install Node.js or use "therubyracer". # diff --git a/Gemfile.lock b/Gemfile.lock index 06cde3e12..562226990 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -715,7 +715,7 @@ GEM unicode-display_width (~> 1.1.1) test_after_commit (1.1.0) activerecord (>= 3.2) - thor (0.19.4) + thor (0.19.1) thread_safe (0.3.6) tilt (1.4.1) timecop (0.8.1) @@ -913,6 +913,7 @@ DEPENDENCIES spring-commands-rspec (= 1.0.4) string-direction (= 1.2.0) test_after_commit (= 1.1.0) + thor (= 0.19.1) timecop (= 0.8.1) turbo_dev_assets (= 0.0.2) twitter (= 6.1.0)