caboose-cms 0.7.15 → 0.7.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +69 -46
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5296ff62df1d3dca4dc184aa275bb11324a4a5d5
|
4
|
+
data.tar.gz: 7170556acc8d764c0859353cf077576ec72d08fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7597b374c85781663a6af491668112579c21cce9dbe32d550ffbd8ddcc27b8a57e9044a9f9a49c5323d05f9357591db65e5745a398f3abbf808abb98a8214ed1
|
7
|
+
data.tar.gz: 4ca180a513d793b898def98f75d5a7db0f6f486de6e7cf7d76738d75c801f75575c77d33df732d5614f095fa8b49dcee31b5286f240633c79b5f44e2d6ebff0f
|
data/lib/caboose/version.rb
CHANGED
data/lib/tasks/caboose.rake
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "caboose/version"
|
2
|
+
require 'aws-sdk'
|
2
3
|
|
3
4
|
namespace :caboose do
|
4
5
|
|
@@ -296,57 +297,79 @@ end
|
|
296
297
|
namespace :assets do
|
297
298
|
|
298
299
|
desc "Precompile assets, upload to S3, then remove locally"
|
299
|
-
task :purl => :environment do
|
300
|
-
|
301
|
-
#
|
302
|
-
|
303
|
-
|
304
|
-
site_js = Rails.root.join('sites', site.name, 'js')
|
305
|
-
site_css = Rails.root.join('sites', site.name, 'css')
|
306
|
-
site_images = Rails.root.join('sites', site.name, 'images')
|
307
|
-
site_fonts = Rails.root.join('sites', site.name, 'fonts')
|
308
|
-
|
309
|
-
host_js = Rails.root.join('app', 'assets', 'javascripts' , site.name)
|
310
|
-
host_css = Rails.root.join('app', 'assets', 'stylesheets' , site.name)
|
311
|
-
host_images = Rails.root.join('app', 'assets', 'images' , site.name)
|
312
|
-
host_fonts = Rails.root.join('app', 'assets', 'fonts' , site.name)
|
300
|
+
task :purl, [:filename] => :environment do |t, args|
|
301
|
+
|
302
|
+
# PURL a single file
|
303
|
+
if args.filename
|
304
|
+
dest = "#{Rails.root}/tmp/#{args.filename}"
|
313
305
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
306
|
+
# Compile the file
|
307
|
+
puts "Compiling #{args.filename}..."
|
308
|
+
File.write(dest, Uglifier.compile(Rails.application.assets.find_asset(args.filename).to_s))
|
309
|
+
|
310
|
+
# Copy the file from dest to s3/assets
|
311
|
+
puts "Copying #{args.filename} to s3..."
|
312
|
+
config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))['production']
|
313
|
+
AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
|
314
|
+
bucket = AWS::S3::Bucket.new(config['bucket'])
|
315
|
+
obj = bucket.objects["assets/#{args.filename}"]
|
316
|
+
obj.write(:file => dest, :acl => :public_read)
|
317
|
+
|
318
|
+
# Remove the temp file
|
319
|
+
puts "Cleaning up..."
|
320
|
+
`rm -rf #{dest}`
|
324
321
|
|
325
|
-
|
326
|
-
Rake::Task['assets:precompile'].invoke
|
327
|
-
|
328
|
-
puts "Removing assets from public/assets, but leaving manifest file..."
|
329
|
-
`mv #{Rails.root.join('public', 'assets', 'manifest.yml')} #{Rails.root.join('public', 'manifest.yml')}`
|
330
|
-
`rm -rf #{Rails.root.join('public', 'assets')}`
|
331
|
-
`mkdir #{Rails.root.join('public', 'assets')}`
|
332
|
-
`mv #{Rails.root.join('public', 'manifest.yml')} #{Rails.root.join('public', 'assets', 'manifest.yml')}`
|
322
|
+
else # Otherwise do a full PURL
|
333
323
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
324
|
+
# Copy any site assets into the host app assets directory first
|
325
|
+
puts "Copying site assets into host assets..."
|
326
|
+
Caboose::Site.all.each do |site|
|
327
|
+
site_js = Rails.root.join('sites', site.name, 'js')
|
328
|
+
site_css = Rails.root.join('sites', site.name, 'css')
|
329
|
+
site_images = Rails.root.join('sites', site.name, 'images')
|
330
|
+
site_fonts = Rails.root.join('sites', site.name, 'fonts')
|
331
|
+
|
332
|
+
host_js = Rails.root.join('app', 'assets', 'javascripts' , site.name)
|
333
|
+
host_css = Rails.root.join('app', 'assets', 'stylesheets' , site.name)
|
334
|
+
host_images = Rails.root.join('app', 'assets', 'images' , site.name)
|
335
|
+
host_fonts = Rails.root.join('app', 'assets', 'fonts' , site.name)
|
336
|
+
|
337
|
+
`mkdir -p #{host_js }` if File.directory?(site_js)
|
338
|
+
`mkdir -p #{host_css }` if File.directory?(site_css)
|
339
|
+
`mkdir -p #{host_images }` if File.directory?(site_images)
|
340
|
+
`mkdir -p #{host_fonts }` if File.directory?(site_fonts)
|
341
|
+
|
342
|
+
`cp -R #{site_js } #{host_js }` if File.directory?(site_js)
|
343
|
+
`cp -R #{site_css } #{host_css }` if File.directory?(site_css)
|
344
|
+
`cp -R #{site_images } #{host_images }` if File.directory?(site_images)
|
345
|
+
`cp -R #{site_fonts } #{host_fonts }` if File.directory?(site_fonts)
|
346
|
+
end
|
347
|
+
|
348
|
+
puts "Running precompile..."
|
349
|
+
Rake::Task['assets:precompile'].invoke
|
350
|
+
|
351
|
+
puts "Removing assets from public/assets, but leaving manifest file..."
|
352
|
+
`mv #{Rails.root.join('public', 'assets', 'manifest.yml')} #{Rails.root.join('public', 'manifest.yml')}`
|
353
|
+
`rm -rf #{Rails.root.join('public', 'assets')}`
|
354
|
+
`mkdir #{Rails.root.join('public', 'assets')}`
|
355
|
+
`mv #{Rails.root.join('public', 'manifest.yml')} #{Rails.root.join('public', 'assets', 'manifest.yml')}`
|
356
|
+
|
357
|
+
# Clean up
|
358
|
+
puts "Removing site assets from host assets..."
|
359
|
+
Caboose::Site.all.each do |site|
|
360
|
+
host_js = Rails.root.join('app', 'assets', 'javascripts' , site.name)
|
361
|
+
host_css = Rails.root.join('app', 'assets', 'stylesheets' , site.name)
|
362
|
+
host_images = Rails.root.join('app', 'assets', 'images' , site.name)
|
363
|
+
host_fonts = Rails.root.join('app', 'assets', 'fonts' , site.name)
|
364
|
+
|
365
|
+
`rm -rf #{host_js }`
|
366
|
+
`rm -rf #{host_css }`
|
367
|
+
`rm -rf #{host_images }`
|
368
|
+
`rm -rf #{host_fonts }`
|
369
|
+
end
|
346
370
|
end
|
347
|
-
|
348
371
|
end
|
349
|
-
|
372
|
+
|
350
373
|
desc "Fix variant sort order"
|
351
374
|
task :set_variant_sort_order => :environment do
|
352
375
|
Caboose::Product.all.each do |p|
|