locomotive_cms 0.0.4.beta3 → 0.0.4.beta4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/app/controllers/admin/imports_controller.rb +20 -9
- data/app/models/asset_collection.rb +5 -3
- data/app/models/content_type.rb +1 -1
- data/app/uploaders/theme_uploader.rb +15 -0
- data/config/environments/production.rb +2 -0
- data/config/locales/default_en.yml +1 -0
- data/config/locales/default_fr.yml +1 -0
- data/config/mongoid.yml +2 -1
- data/lib/locomotive/import/job.rb +59 -8
- data/lib/locomotive/liquid/tags/consume.rb +1 -1
- data/lib/locomotive/version.rb +1 -1
- metadata +5 -4
data/Gemfile
CHANGED
@@ -17,9 +17,9 @@ gem 'formtastic', '>= 1.1.0'
|
|
17
17
|
gem 'inherited_resources', '>= 1.1.2'
|
18
18
|
|
19
19
|
gem 'rmagick', '= 2.12.2'
|
20
|
-
gem 'locomotive_carrierwave', :require => 'carrierwave'
|
20
|
+
gem 'locomotive_carrierwave', '0.5.0.1.beta2', :require => 'carrierwave'
|
21
21
|
|
22
|
-
gem 'custom_fields', '1.0.0.
|
22
|
+
gem 'custom_fields', '1.0.0.beta2'
|
23
23
|
gem 'fog', '0.3.7'
|
24
24
|
gem 'mimetype-fu'
|
25
25
|
gem 'actionmailer-with-request'
|
@@ -23,28 +23,39 @@ module Admin
|
|
23
23
|
def new; end
|
24
24
|
|
25
25
|
def create
|
26
|
-
|
27
|
-
@error = t('errors.messages.blank')
|
28
|
-
flash[:alert] = t('flash.admin.imports.create.alert')
|
29
|
-
render 'new'
|
30
|
-
else
|
31
|
-
path = self.store_zipfile!
|
26
|
+
identifier = store_zipfile!
|
32
27
|
|
33
|
-
|
28
|
+
if identifier
|
29
|
+
job = Locomotive::Import::Job.new(identifier, current_site)
|
34
30
|
Delayed::Job.enqueue job, { :site => current_site, :job_type => 'import' }
|
35
31
|
|
36
32
|
flash[:notice] = t('flash.admin.imports.create.notice')
|
37
33
|
|
38
34
|
redirect_to admin_import_url
|
35
|
+
else
|
36
|
+
@error = t('errors.messages.invalid_theme_file')
|
37
|
+
flash[:alert] = t('flash.admin.imports.create.alert')
|
38
|
+
|
39
|
+
render 'new'
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
43
|
protected
|
43
44
|
|
44
45
|
def store_zipfile!
|
46
|
+
return nil if params[:zipfile].blank?
|
47
|
+
|
45
48
|
file = CarrierWave::SanitizedFile.new(params[:zipfile])
|
46
|
-
|
47
|
-
|
49
|
+
|
50
|
+
uploader = ThemeUploader.new(current_site)
|
51
|
+
|
52
|
+
begin
|
53
|
+
uploader.store!(file)
|
54
|
+
rescue CarrierWave::IntegrityError
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
uploader.identifier
|
48
59
|
end
|
49
60
|
|
50
61
|
end
|
@@ -53,14 +53,16 @@ class AssetCollection
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def store_asset_positions!
|
56
|
-
return if @assets_order.
|
56
|
+
return if @assets_order.blank?
|
57
57
|
|
58
|
-
@assets_order.split(',').
|
58
|
+
ids = @assets_order.split(',').collect { |id| BSON::ObjectId(id) }
|
59
|
+
|
60
|
+
ids.each_with_index do |asset_id, index|
|
59
61
|
self.assets.find(asset_id).position = index
|
60
62
|
end
|
61
63
|
|
62
64
|
self.assets.clone.each do |asset|
|
63
|
-
if
|
65
|
+
if !ids.include?(asset._id)
|
64
66
|
self.assets.delete(asset)
|
65
67
|
asset.send(:delete)
|
66
68
|
end
|
data/app/models/content_type.rb
CHANGED
@@ -13,6 +13,7 @@ en:
|
|
13
13
|
array_too_short: "is too small (minimum element number is %{count})"
|
14
14
|
liquid_syntax: "Liquid Syntax error, please check the syntax"
|
15
15
|
liquid_extend: "The page extends a template which does not exist"
|
16
|
+
invalid_theme_file: "can't be blank or isn't a zip file"
|
16
17
|
|
17
18
|
attributes:
|
18
19
|
defaults:
|
@@ -34,6 +34,7 @@ fr:
|
|
34
34
|
array_too_short: "est trop petit (le nombre minimum d'éléments est %{count})"
|
35
35
|
liquid_syntax: "Erreur de syntaxe dans les sections de page, veuillez vérifier la syntaxe"
|
36
36
|
liquid_extend: "La page étend le contenu d'une page qui n'existe pas"
|
37
|
+
invalid_theme_file: "doit être rempli ou n'est pas un fichier zip"
|
37
38
|
|
38
39
|
attributes:
|
39
40
|
defaults:
|
data/config/mongoid.yml
CHANGED
@@ -4,10 +4,10 @@ module Locomotive
|
|
4
4
|
module Import
|
5
5
|
class Job
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
raise "Theme
|
7
|
+
def initialize(identifier, site = nil, enabled = {})
|
8
|
+
raise "Theme identifier not found" if identifier.blank?
|
9
9
|
|
10
|
-
@
|
10
|
+
@identifier = identifier
|
11
11
|
@site = site
|
12
12
|
@enabled = enabled
|
13
13
|
end
|
@@ -17,7 +17,7 @@ module Locomotive
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def perform
|
20
|
-
|
20
|
+
self.log "theme identifier #{@identifier} / enabled steps = #{@enabled.inspect}"
|
21
21
|
|
22
22
|
self.unzip!
|
23
23
|
|
@@ -33,21 +33,72 @@ module Locomotive
|
|
33
33
|
|
34
34
|
%w(site content_types assets asset_collections snippets pages).each do |step|
|
35
35
|
if @enabled[step] != false
|
36
|
+
self.log "performing '#{step}' step"
|
36
37
|
"Locomotive::Import::#{step.camelize}".constantize.process(context)
|
37
38
|
@worker.update_attributes :step => step if @worker
|
38
39
|
else
|
39
|
-
|
40
|
+
self.log "skipping #{step}"
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
45
|
+
def success(worker)
|
46
|
+
self.log 'deleting original zip file'
|
47
|
+
|
48
|
+
uploader = ThemeUploader.new(@site)
|
49
|
+
|
50
|
+
uploader.retrieve_from_store!(@identifier)
|
51
|
+
|
52
|
+
uploader.remove!
|
53
|
+
|
54
|
+
self.log 'deleting working folder'
|
55
|
+
|
56
|
+
FileUtils.rm_rf(themes_folder) rescue nil
|
57
|
+
end
|
58
|
+
|
44
59
|
protected
|
45
60
|
|
61
|
+
def log(message)
|
62
|
+
puts "\t[import_theme] #{message}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def themes_folder
|
66
|
+
File.join(Rails.root, 'tmp', 'themes', @site.id.to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
def prepare_folder
|
70
|
+
FileUtils.rm_rf self.themes_folder if File.exists?(self.themes_folder)
|
71
|
+
|
72
|
+
FileUtils.mkdir_p(self.themes_folder)
|
73
|
+
end
|
74
|
+
|
75
|
+
def retrieve_zip_file
|
76
|
+
uploader = ThemeUploader.new(@site)
|
77
|
+
|
78
|
+
uploader.retrieve_from_store!(@identifier)
|
79
|
+
|
80
|
+
if uploader.file.respond_to?(:url)
|
81
|
+
self.log 'file from remote storage'
|
82
|
+
|
83
|
+
@theme_file = File.join(self.themes_folder, @identifier)
|
84
|
+
|
85
|
+
File.open(@theme_file, 'w') { |f| f.write(uploader.file.read) }
|
86
|
+
else # local filesystem
|
87
|
+
self.log 'file from local storage'
|
88
|
+
|
89
|
+
@theme_file = uploader.path
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
46
93
|
def unzip!
|
47
|
-
|
48
|
-
destination_path = File.join(Rails.root, 'tmp', 'themes', @site.id.to_s)
|
94
|
+
self.prepare_folder
|
49
95
|
|
50
|
-
|
96
|
+
self.retrieve_zip_file
|
97
|
+
|
98
|
+
self.log "unzip #{@theme_file}"
|
99
|
+
|
100
|
+
Zip::ZipFile.open(@theme_file) do |zipfile|
|
101
|
+
destination_path = self.themes_folder
|
51
102
|
|
52
103
|
zipfile.each do |entry|
|
53
104
|
next if entry.name =~ /__MACOSX/
|
@@ -39,7 +39,7 @@ module Locomotive
|
|
39
39
|
protected
|
40
40
|
|
41
41
|
def render_all_and_cache_it(context)
|
42
|
-
Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
|
42
|
+
Rails.cache.fetch(@cache_key, :expires_in => @expires_in, :force => @expires_in == 0) do
|
43
43
|
context.stack do
|
44
44
|
context.scopes.last[@target.to_s] = Locomotive::Httparty::Webservice.consume(@url, @options.symbolize_keys)
|
45
45
|
|
data/lib/locomotive/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotive_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -1848230056
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 4
|
10
|
-
-
|
11
|
-
version: 0.0.4.
|
10
|
+
- beta4
|
11
|
+
version: 0.0.4.beta4
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Didier Lafforgue
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-19 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -431,6 +431,7 @@ files:
|
|
431
431
|
- app/uploaders/asset_uploader.rb
|
432
432
|
- app/uploaders/editable_file_uploader.rb
|
433
433
|
- app/uploaders/theme_asset_uploader.rb
|
434
|
+
- app/uploaders/theme_uploader.rb
|
434
435
|
- app/views/admin/accounts/new.html.haml
|
435
436
|
- app/views/admin/asset_collections/_asset.html.haml
|
436
437
|
- app/views/admin/asset_collections/edit.html.haml
|