Skip to content

Instantly share code, notes, and snippets.

@jessieay
Created May 7, 2014 21:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jessieay/63e5ca44aba45ba36263 to your computer and use it in GitHub Desktop.
Save jessieay/63e5ca44aba45ba36263 to your computer and use it in GitHub Desktop.
ckeditor rake task
namespace :ckeditor do
desc 'Create nondigest versions of all ckeditor digest assets'
task :create_nondigest_assets do
fingerprint = /\-([0-9a-f]{32})\./
for file in Dir['public/assets/ckeditor/**/*']
next unless file =~ fingerprint
nondigest = file.sub(fingerprint, '.')
filename = nondigest.sub('public/assets/', '').sub(/.gz$/, '')
latest_digest = Rails.application.assets.find_asset(filename).digest
this_digest = file.match(fingerprint)[1]
if (this_digest == latest_digest)
FileUtils.cp file, nondigest
end
end
end
end
# auto run ckeditor:create_nondigest_assets after assets:precompile
Rake::Task['assets:precompile'].enhance do
Rake::Task['ckeditor:create_nondigest_assets'].invoke
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment