locomotive_cms 0.0.4.beta12 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -15
- data/README.textile +4 -5
- data/app/controllers/admin/api_contents_controller.rb +1 -10
- data/app/controllers/admin/base_controller.rb +2 -2
- data/app/controllers/admin/cross_domain_sessions_controller.rb +4 -7
- data/app/controllers/admin/current_sites_controller.rb +0 -2
- data/app/controllers/admin/imports_controller.rb +19 -13
- data/app/controllers/admin/pages_controller.rb +1 -1
- data/app/controllers/admin/passwords_controller.rb +2 -2
- data/app/controllers/admin/sessions_controller.rb +2 -2
- data/app/controllers/admin/sites_controller.rb +0 -2
- data/app/controllers/admin/theme_assets_controller.rb +1 -1
- data/app/controllers/application_controller.rb +1 -1
- data/app/controllers/home_controller.rb +7 -0
- data/app/helpers/admin/assets_helper.rb +6 -0
- data/app/helpers/admin/custom_fields_helper.rb +2 -2
- data/app/helpers/admin/{box_helper.rb → login_helper.rb} +3 -7
- data/app/models/asset_collection.rb +3 -15
- data/app/models/content_instance.rb +0 -19
- data/app/models/content_type.rb +3 -21
- data/app/models/extensions/page/tree.rb +7 -63
- data/app/models/page.rb +0 -2
- data/app/models/site.rb +3 -15
- data/app/uploaders/asset_uploader.rb +1 -1
- data/app/uploaders/theme_asset_uploader.rb +1 -12
- data/app/views/admin/asset_collections/edit.html.haml +2 -2
- data/app/views/admin/asset_collections/new.html.haml +1 -1
- data/app/views/admin/assets/_form.html.haml +2 -2
- data/app/views/admin/content_types/_form.html.haml +2 -2
- data/app/views/admin/content_types/new.html.haml +1 -1
- data/app/views/admin/contents/_form.html.haml +2 -2
- data/app/views/admin/contents/index.html.haml +1 -1
- data/app/views/admin/cross_domain_sessions/new.html.haml +1 -1
- data/app/views/admin/current_sites/_form.html.haml +3 -3
- data/app/views/admin/current_sites/edit.html.haml +1 -1
- data/app/views/admin/imports/new.html.haml +0 -11
- data/app/views/admin/imports/show.html.haml +1 -1
- data/app/views/admin/my_accounts/edit.html.haml +1 -1
- data/app/views/admin/pages/_form.html.haml +3 -2
- data/app/views/admin/pages/_page.html.haml +2 -4
- data/app/views/admin/pages/index.html.haml +1 -1
- data/app/views/admin/passwords/edit.html.haml +2 -2
- data/app/views/admin/passwords/new.html.haml +2 -2
- data/app/views/admin/sessions/new.html.haml +2 -2
- data/app/views/admin/shared/_head.html.haml +5 -4
- data/app/views/admin/shared/menu/_contents.html.haml +1 -1
- data/app/views/admin/sites/_form.html.haml +3 -3
- data/app/views/admin/snippets/_form.html.haml +2 -2
- data/app/views/admin/snippets/index.html.haml +15 -0
- data/app/views/admin/theme_assets/_form.html.haml +2 -2
- data/app/views/admin/theme_assets/index.html.haml +1 -1
- data/app/views/home/show.html.haml +4 -0
- data/app/views/{admin/layouts → layouts/admin}/application.html.haml +0 -0
- data/app/views/layouts/admin/box.html.haml +19 -0
- data/app/views/layouts/application.html.haml +7 -0
- data/config/application.rb +3 -1
- data/config/environments/development.rb +6 -1
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +5 -1
- data/config/initializers/locomotive.rb +0 -14
- data/config/locales/admin_ui_en.yml +1 -33
- data/config/locales/admin_ui_fr.yml +1 -34
- data/config/locales/default_en.yml +0 -1
- data/config/locales/default_fr.yml +0 -1
- data/config/locales/flash.en.yml +0 -1
- data/config/locales/flash.fr.yml +0 -1
- data/config/mongoid.yml +5 -13
- data/config/routes.rb +1 -6
- data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +14 -0
- data/lib/generators/locomotive/install/install_generator.rb +10 -18
- data/lib/generators/locomotive/install/templates/README +13 -23
- data/lib/generators/locomotive/install/templates/locomotive.rb +1 -15
- data/lib/locomotive/carrierwave.rb +0 -1
- data/lib/locomotive/configuration.rb +1 -3
- data/lib/locomotive/custom_fields.rb +1 -0
- data/lib/locomotive/delayed_job.rb +2 -1
- data/lib/locomotive/engine.rb +7 -24
- data/lib/locomotive/heroku.rb +0 -1
- data/lib/locomotive/httparty/webservice.rb +1 -12
- data/lib/locomotive/import.rb +0 -2
- data/lib/locomotive/import/asset_collections.rb +8 -40
- data/lib/locomotive/import/assets.rb +12 -20
- data/lib/locomotive/import/content_types.rb +15 -51
- data/lib/locomotive/import/job.rb +11 -106
- data/lib/locomotive/import/pages.rb +26 -79
- data/lib/locomotive/import/site.rb +5 -3
- data/lib/locomotive/import/snippets.rb +8 -6
- data/lib/locomotive/inherited_resources.rb +0 -1
- data/lib/locomotive/liquid/drops/asset_collections.rb +4 -4
- data/lib/locomotive/liquid/drops/contents.rb +16 -21
- data/lib/locomotive/liquid/drops/page.rb +0 -4
- data/lib/locomotive/liquid/filters/html.rb +29 -15
- data/lib/locomotive/liquid/tags/consume.rb +1 -1
- data/lib/locomotive/liquid/tags/nav.rb +17 -48
- data/lib/locomotive/liquid/tags/paginate.rb +3 -3
- data/lib/locomotive/middlewares/fonts.rb +11 -3
- data/lib/locomotive/misc_form_builder.rb +7 -2
- data/lib/locomotive/regexps.rb +1 -1
- data/lib/locomotive/render.rb +3 -9
- data/lib/locomotive/routing/site_dispatcher.rb +6 -10
- data/lib/locomotive/version.rb +1 -2
- data/public/images/admin/box/buttons/right_bg.png +0 -0
- data/public/javascripts/admin/aloha/VERSION.txt +1 -1
- data/public/javascripts/admin/aloha/aloha-nodeps.js +101 -140
- data/public/javascripts/admin/aloha/aloha.js +105 -193
- data/public/javascripts/admin/aloha/css/aloha.css +4 -65
- data/public/javascripts/admin/aloha/deps/prettyPhoto/resources/css/prettyPhoto.css +2 -2
- data/public/javascripts/admin/aloha/i18n/de.dict +0 -2
- data/public/javascripts/admin/aloha/i18n/en.dict +0 -2
- data/public/javascripts/admin/aloha/images/base.png +0 -0
- data/public/javascripts/admin/aloha/images/base_multi.png +0 -0
- data/public/javascripts/admin/aloha/images/fade_in.png +0 -0
- data/public/javascripts/admin/aloha/images/fade_out.png +0 -0
- data/public/javascripts/admin/aloha/images/gentics_logo.png +0 -0
- data/public/javascripts/admin/aloha/images/grabhandle.png +0 -0
- data/public/javascripts/admin/aloha/images/maximize.png +0 -0
- data/public/javascripts/admin/aloha/images/pin.png +0 -0
- data/public/javascripts/admin/aloha/images/removeformat.png +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/de.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/en.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/eo.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fi.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fr.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/it.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/plugin.js +7 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/i18n/de.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/i18n/en.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/i18n/fi.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/i18n/fr.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/i18n/it.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.plugins.Save → com.example.aloha.DummySave}/plugin.js +0 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/de.dict +20 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/en.dict +20 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/eo.dict +16 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fi.dict +20 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fr.dict +16 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/it.dict +20 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/plugin.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.HighlightEditables/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/css/jquery.autocomplete.css +48 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/deps/jquery.autocomplete.js +1 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressource.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourcedummy.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourceregistry.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/de.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/en.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/table.css +110 -28
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Loader/plugin.js +1 -0
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/en.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fi.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fr.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/person.css +3 -0
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/plugin.js +1 -0
- data/public/javascripts/admin/aloha/plugins/simpletable/plugin.js.deactivated +2330 -0
- data/public/javascripts/admin/asset_collections.js +7 -11
- data/public/javascripts/admin/contents.js +1 -3
- data/public/javascripts/admin/site.js +3 -9
- data/public/javascripts/admin/snippets.js +1 -1
- data/public/javascripts/admin/utils.js +3 -5
- data/public/stylesheets/admin/application.css +1 -1
- data/public/stylesheets/admin/box.css +5 -5
- data/public/stylesheets/admin/buttons.css +5 -0
- data/public/stylesheets/admin/formtastic_changes.css +12 -5
- data/public/stylesheets/admin/inline_editor.css +5 -22
- data/public/stylesheets/admin/layout.css +4 -9
- metadata +130 -187
- data/app/controllers/admin/installation_controller.rb +0 -79
- data/app/uploaders/theme_uploader.rb +0 -19
- data/app/views/admin/errors/no_page.html.haml +0 -1
- data/app/views/admin/errors/no_site.html.haml +0 -1
- data/app/views/admin/installation/step_1.html.haml +0 -24
- data/app/views/admin/installation/step_2.html.haml +0 -26
- data/app/views/admin/installation/step_3.html.haml +0 -23
- data/app/views/admin/layouts/box.html.haml +0 -21
- data/app/views/admin/layouts/error.html.haml +0 -1
- data/config/assets.yml +0 -96
- data/config/initializers/carrierwave.rb +0 -17
- data/lib/locomotive/import/base.rb +0 -46
- data/lib/locomotive/import/logger.rb +0 -13
- data/lib/locomotive/railties/tasks.rake +0 -16
- data/public/javascripts/admin/aloha/i18n/pl.dict +0 -5
- data/public/javascripts/admin/aloha/images/base_big.png +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.css +0 -86
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.html +0 -44
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/de.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/en.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/fr.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/plugin.js +0 -1
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/product.js +0 -1
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/2xu-wetsuit.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/asics-noosa.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/fivefingers-kso.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/kuota-kueen-k.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/mizuno-wave-musha2.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product.css +0 -69
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product_button.gif +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/simplon-mrt.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trek-fuel-ex.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trisports.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/zoggs-predator.jpg +0 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.css +0 -48
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.html +0 -69
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/de.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/en.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/plugin.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/i18n/pl.dict +0 -30
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/LinkList.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/delicious.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/i18n/pl.dict +0 -4
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/css/LinkChecker.css +0 -14
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.css +0 -49
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.html +0 -82
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/i18n/en.dict +0 -27
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/plugin.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/proxy.php +0 -235
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/plugin.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/wordpastehandler.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/de.dict +0 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/en.dict +0 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/pl.dict +0 -12
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_green.png +0 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_red.png +0 -0
- data/public/stylesheets/admin/installation.css +0 -50
- data/public/stylesheets/admin/safari.css +0 -15
@@ -2,13 +2,7 @@ Locomotive.configure do |config|
|
|
2
2
|
# if not defined, locomotive will use example.com as main domain name. Remove prefix www from your domain name.
|
3
3
|
# Ex:
|
4
4
|
# config.default_domain = Rails.env.production? ? 'mydomain.com' : 'example.com'
|
5
|
-
|
6
|
-
# If you use locomotive for a single site in Heroku, use "heroku.com" as default domain name.
|
7
|
-
# Your heroku app name (<app_name>.heroku.name) will be used as the sub domain name in Locomotive
|
8
|
-
# during the installation wizzard.
|
9
|
-
# Ex:
|
10
|
-
# config.default_domain = Rails.env.production? ? 'heroku.com' : 'example.com'
|
11
|
-
config.default_domain = 'example.com'
|
5
|
+
config.default_domain = 'mydomain.com'
|
12
6
|
|
13
7
|
# configure how many items we display in sub menu in the "Contents" section.
|
14
8
|
config.lastest_items_nb = 5
|
@@ -29,12 +23,4 @@ Locomotive.configure do |config|
|
|
29
23
|
# Ex:
|
30
24
|
# config.heroku = { :name => '<my heroku app name>', :login => 'john@doe.net', :password => 'easy' }
|
31
25
|
config.heroku = false
|
32
|
-
|
33
|
-
# Locomotive uses the DelayedJob gem for the theme import module.
|
34
|
-
# In case you want to deploy to Heroku, you will have to pay for an extra dyno.
|
35
|
-
# If you do not mind about importing theme without DelayedJob, disable it.
|
36
|
-
config.delayed_job = false
|
37
|
-
|
38
|
-
# default locale (for now, only en and fr are supported)
|
39
|
-
config.default_locale = :en
|
40
26
|
end
|
data/lib/locomotive/engine.rb
CHANGED
@@ -1,37 +1,20 @@
|
|
1
|
-
puts "...
|
1
|
+
puts "...Locomotive engine loaded"
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'mimetype_fu'
|
4
|
+
require 'liquid'
|
4
5
|
require 'devise'
|
6
|
+
require 'carrierwave'
|
7
|
+
require 'formtastic'
|
5
8
|
require 'mongoid'
|
6
9
|
require 'mongoid_acts_as_tree'
|
7
|
-
require 'will_paginate'
|
8
|
-
require 'haml'
|
9
|
-
require 'liquid'
|
10
|
-
require 'formtastic'
|
11
|
-
require 'inherited_resources'
|
12
|
-
require 'carrierwave'
|
13
|
-
require 'custom_fields'
|
14
|
-
require 'mimetype_fu'
|
15
|
-
require 'actionmailer_with_request'
|
16
|
-
require 'heroku'
|
17
10
|
require 'httparty'
|
18
11
|
require 'redcloth'
|
19
|
-
require '
|
12
|
+
require 'actionmailer_with_request'
|
20
13
|
require 'zip/zipfilesystem'
|
21
|
-
require '
|
22
|
-
|
23
|
-
$:.unshift File.dirname(__FILE__)
|
14
|
+
require 'custom_fields'
|
24
15
|
|
25
16
|
module Locomotive
|
26
17
|
class Engine < Rails::Engine
|
27
18
|
|
28
|
-
rake_tasks do
|
29
|
-
load "railties/tasks.rake"
|
30
|
-
end
|
31
|
-
|
32
|
-
initializer "serving fonts" do |app|
|
33
|
-
app.middleware.insert_after Rack::Lock, '::Locomotive::Middlewares::Fonts', :path => %r{^/fonts}
|
34
|
-
end
|
35
|
-
|
36
19
|
end
|
37
20
|
end
|
data/lib/locomotive/heroku.rb
CHANGED
@@ -17,18 +17,7 @@ module Locomotive
|
|
17
17
|
|
18
18
|
# puts "[WebService] consuming #{path}, #{options.inspect}"
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
if response.code == 200
|
23
|
-
if response.respond_to?(:underscore_keys)
|
24
|
-
response.underscore_keys
|
25
|
-
else
|
26
|
-
response.collect(&:underscore_keys)
|
27
|
-
end
|
28
|
-
else
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
|
20
|
+
self.get(path, options).try(:underscore_keys)
|
32
21
|
end
|
33
22
|
|
34
23
|
end
|
data/lib/locomotive/import.rb
CHANGED
@@ -1,34 +1,30 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Import
|
3
|
-
|
3
|
+
module AssetCollections
|
4
|
+
|
5
|
+
def self.process(context)
|
6
|
+
site, database = context[:site], context[:database]
|
4
7
|
|
5
|
-
def process
|
6
8
|
asset_collections = database['site']['asset_collections']
|
7
9
|
|
8
10
|
return if asset_collections.nil?
|
9
11
|
|
10
12
|
asset_collections.each do |name, attributes|
|
11
|
-
|
13
|
+
puts "....asset_collection = #{attributes['slug']}"
|
12
14
|
|
13
15
|
asset_collection = site.asset_collections.where(:slug => attributes['slug']).first
|
14
16
|
|
15
|
-
asset_collection ||= self.build_asset_collection(attributes.merge(:name => name))
|
17
|
+
asset_collection ||= self.build_asset_collection(site, attributes.merge(:name => name))
|
16
18
|
|
17
19
|
self.add_or_update_fields(asset_collection, attributes['fields'])
|
18
20
|
|
19
|
-
if options[:samples] && attributes['assets']
|
20
|
-
self.insert_samples(asset_collection, attributes['assets'])
|
21
|
-
end
|
22
|
-
|
23
21
|
asset_collection.save!
|
24
22
|
|
25
23
|
site.reload
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
def build_asset_collection(data)
|
27
|
+
def self.build_asset_collection(site, data)
|
32
28
|
attributes = { :internal => false }.merge(data)
|
33
29
|
|
34
30
|
attributes.delete_if { |name, value| %w{fields assets}.include?(name) }
|
@@ -36,7 +32,7 @@ module Locomotive
|
|
36
32
|
site.asset_collections.build(attributes)
|
37
33
|
end
|
38
34
|
|
39
|
-
def add_or_update_fields(asset_collection, fields)
|
35
|
+
def self.add_or_update_fields(asset_collection, fields)
|
40
36
|
fields.each_with_index do |data, position|
|
41
37
|
name, data = data.keys.first, data.values.first
|
42
38
|
|
@@ -52,34 +48,6 @@ module Locomotive
|
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
|
-
def insert_samples(asset_collection, assets)
|
56
|
-
assets.each_with_index do |data, position|
|
57
|
-
value, attributes = data.is_a?(Array) ? [data.first, data.last] : [data.keys.first, data.values.first]
|
58
|
-
|
59
|
-
url = attributes.delete('url')
|
60
|
-
|
61
|
-
# build with default attributes
|
62
|
-
asset = asset_collection.assets.build(:name => value, :position => position, :source => self.open_sample_asset(url))
|
63
|
-
|
64
|
-
attributes.each do |name, value|
|
65
|
-
field = asset_collection.asset_custom_fields.detect { |f| f._alias == name }
|
66
|
-
|
67
|
-
value = (case field.kind.downcase
|
68
|
-
when 'file' then self.open_sample_asset(value)
|
69
|
-
when 'boolean' then Boolean.set(value)
|
70
|
-
else
|
71
|
-
value
|
72
|
-
end)
|
73
|
-
|
74
|
-
asset.send("#{name}=", value)
|
75
|
-
end
|
76
|
-
|
77
|
-
asset.save
|
78
|
-
|
79
|
-
self.log "insert asset '#{asset.name}'"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
51
|
end
|
84
52
|
end
|
85
53
|
end
|
@@ -1,26 +1,24 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Import
|
3
|
-
|
3
|
+
module Assets
|
4
4
|
|
5
|
-
def process
|
6
|
-
|
5
|
+
def self.process(context)
|
6
|
+
site, theme_path = context[:site], context[:theme_path]
|
7
7
|
|
8
|
-
self.
|
8
|
+
whitelist = self.build_regexps_in_withlist(context[:database]['site']['assets']['whitelist']) rescue nil
|
9
9
|
|
10
|
-
self.add_theme_assets(whitelist)
|
10
|
+
self.add_theme_assets(site, theme_path, whitelist)
|
11
11
|
|
12
|
-
self.add_other_assets
|
12
|
+
self.add_other_assets(site, theme_path)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
def add_theme_assets(whitelist)
|
15
|
+
def self.add_theme_assets(site, theme_path, whitelist)
|
18
16
|
%w(images media fonts javascripts stylesheets).each do |kind|
|
19
17
|
Dir[File.join(theme_path, 'public', kind, '**/*')].each do |asset_path|
|
20
18
|
|
21
19
|
next if File.directory?(asset_path)
|
22
20
|
|
23
|
-
visible = self.check_against_whitelist(whitelist, asset_path.gsub(File.join(theme_path, 'public'), '')
|
21
|
+
visible = self.check_against_whitelist(whitelist, asset_path.gsub(File.join(theme_path, 'public'), ''))
|
24
22
|
|
25
23
|
folder = asset_path.gsub(File.join(theme_path, 'public'), '').gsub(File.basename(asset_path), '').gsub(/^\//, '').gsub(/\/$/, '')
|
26
24
|
|
@@ -30,33 +28,27 @@ module Locomotive
|
|
30
28
|
|
31
29
|
asset.attributes = { :source => File.open(asset_path), :performing_plain_text => false, :hidden => !visible }
|
32
30
|
|
33
|
-
|
34
|
-
asset.save!
|
35
|
-
rescue Exception => e
|
36
|
-
self.log "!ERROR! = #{e.message}, #{asset_path}"
|
37
|
-
end
|
31
|
+
asset.save!
|
38
32
|
|
39
33
|
site.reload
|
40
34
|
end
|
41
35
|
end
|
42
36
|
end
|
43
37
|
|
44
|
-
def add_other_assets
|
38
|
+
def self.add_other_assets(site, theme_path)
|
45
39
|
collection = AssetCollection.find_or_create_internal(site)
|
46
40
|
|
47
41
|
Dir[File.join(theme_path, 'public', 'samples', '*')].each do |asset_path|
|
48
42
|
|
49
43
|
next if File.directory?(asset_path)
|
50
44
|
|
51
|
-
self.log "other asset = #{asset_path}"
|
52
|
-
|
53
45
|
name = File.basename(asset_path, File.extname(asset_path)).parameterize('_')
|
54
46
|
|
55
47
|
collection.assets.create! :name => name, :source => File.open(asset_path)
|
56
48
|
end
|
57
49
|
end
|
58
50
|
|
59
|
-
def build_regexps_in_withlist(rules)
|
51
|
+
def self.build_regexps_in_withlist(rules)
|
60
52
|
rules.collect do |rule|
|
61
53
|
if rule.start_with?('^')
|
62
54
|
Regexp.new(rule.gsub('/', '\/'))
|
@@ -66,7 +58,7 @@ module Locomotive
|
|
66
58
|
end
|
67
59
|
end
|
68
60
|
|
69
|
-
def check_against_whitelist(whitelist, path)
|
61
|
+
def self.check_against_whitelist(whitelist, path)
|
70
62
|
(whitelist || []).each do |rule|
|
71
63
|
case rule
|
72
64
|
when Regexp
|
@@ -1,16 +1,20 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Import
|
3
|
-
|
3
|
+
module ContentTypes
|
4
|
+
|
5
|
+
def self.process(context)
|
6
|
+
site, database = context[:site], context[:database]
|
7
|
+
|
8
|
+
content_types = database['site']['content_types']
|
4
9
|
|
5
|
-
def process
|
6
10
|
return if content_types.nil?
|
7
11
|
|
8
12
|
content_types.each do |name, attributes|
|
9
|
-
|
13
|
+
puts "....content_type = #{attributes['slug']}"
|
10
14
|
|
11
15
|
content_type = site.content_types.where(:slug => attributes['slug']).first
|
12
16
|
|
13
|
-
content_type ||= self.build_content_type(attributes.merge(:name => name))
|
17
|
+
content_type ||= self.build_content_type(site, attributes.merge(:name => name))
|
14
18
|
|
15
19
|
self.add_or_update_fields(content_type, attributes['fields'])
|
16
20
|
|
@@ -20,31 +24,21 @@ module Locomotive
|
|
20
24
|
|
21
25
|
self.set_group_by_value(content_type)
|
22
26
|
|
23
|
-
if options[:samples] && attributes['contents']
|
24
|
-
self.insert_samples(content_type, attributes['contents'])
|
25
|
-
end
|
26
|
-
|
27
27
|
content_type.save!
|
28
28
|
|
29
29
|
site.reload
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
def content_types
|
36
|
-
database['site']['content_types']
|
37
|
-
end
|
38
|
-
|
39
|
-
def build_content_type(data)
|
40
|
-
attributes = { :group_by_field_name => data.delete('group_by') }.merge(data)
|
33
|
+
def self.build_content_type(site, data)
|
34
|
+
attributes = { :order_by => '_position_in_list', :group_by_field_name => data.delete('group_by') }.merge(data)
|
41
35
|
|
42
36
|
attributes.delete_if { |name, value| %w{fields contents}.include?(name) }
|
43
37
|
|
44
38
|
site.content_types.build(attributes)
|
45
39
|
end
|
46
40
|
|
47
|
-
def add_or_update_fields(content_type, fields)
|
41
|
+
def self.add_or_update_fields(content_type, fields)
|
48
42
|
fields.each_with_index do |data, position|
|
49
43
|
name, data = data.keys.first, data.values.first
|
50
44
|
|
@@ -60,54 +54,24 @@ module Locomotive
|
|
60
54
|
end
|
61
55
|
end
|
62
56
|
|
63
|
-
def
|
64
|
-
contents.each_with_index do |data, position|
|
65
|
-
value, attributes = data.is_a?(Array) ? [data.first, data.last] : [data.keys.first, data.values.first]
|
66
|
-
|
67
|
-
# build with default attributes
|
68
|
-
content = content_type.contents.build(content_type.highlighted_field_name.to_sym => value, :_position_in_list => position)
|
69
|
-
|
70
|
-
attributes.each do |name, value|
|
71
|
-
field = content_type.content_custom_fields.detect { |f| f._alias == name }
|
72
|
-
|
73
|
-
value = (case field.kind.downcase
|
74
|
-
when 'file' then self.open_sample_asset(value)
|
75
|
-
when 'boolean' then Boolean.set(value)
|
76
|
-
else
|
77
|
-
value
|
78
|
-
end)
|
79
|
-
|
80
|
-
content.send("#{name}=", value)
|
81
|
-
end
|
82
|
-
|
83
|
-
content.save
|
84
|
-
|
85
|
-
self.log "insert content '#{content.send(content_type.highlighted_field_name.to_sym)}'"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def set_highlighted_field_name(content_type)
|
57
|
+
def self.set_highlighted_field_name(content_type)
|
90
58
|
field = content_type.content_custom_fields.detect { |f| f._alias == content_type.highlighted_field_name }
|
91
59
|
|
92
60
|
content_type.highlighted_field_name = field._name if field
|
93
61
|
end
|
94
62
|
|
95
|
-
def set_order_by_value(content_type)
|
96
|
-
self.log "order by #{content_type.order_by}"
|
97
|
-
|
63
|
+
def self.set_order_by_value(content_type)
|
98
64
|
order_by = (case content_type.order_by
|
99
65
|
when 'manually', '_position_in_list' then '_position_in_list'
|
100
|
-
when '
|
66
|
+
when 'date', 'updated_at' then 'updated_at'
|
101
67
|
else
|
102
68
|
content_type.content_custom_fields.detect { |f| f._alias == content_type.order_by }._name rescue nil
|
103
69
|
end)
|
104
70
|
|
105
|
-
self.log "order by (after) #{order_by}"
|
106
|
-
|
107
71
|
content_type.order_by = order_by || '_position_in_list'
|
108
72
|
end
|
109
73
|
|
110
|
-
def set_group_by_value(content_type)
|
74
|
+
def self.set_group_by_value(content_type)
|
111
75
|
return if content_type.group_by_field_name.blank?
|
112
76
|
|
113
77
|
field = content_type.content_custom_fields.detect { |f| f._alias == content_type.group_by_field_name }
|
@@ -4,21 +4,12 @@ module Locomotive
|
|
4
4
|
module Import
|
5
5
|
class Job
|
6
6
|
|
7
|
-
|
7
|
+
def initialize(theme_file, site = nil, enabled = {})
|
8
|
+
raise "Theme zipfile not found" unless File.exists?(theme_file)
|
8
9
|
|
9
|
-
|
10
|
+
@theme_file = theme_file
|
10
11
|
@site = site
|
11
|
-
@
|
12
|
-
:reset => false,
|
13
|
-
:samples => false,
|
14
|
-
:enabled => {}
|
15
|
-
}.merge(options)
|
16
|
-
|
17
|
-
@identifier = self.store_zipfile(zipfile)
|
18
|
-
|
19
|
-
raise "Theme identifier not found" if @identifier.blank?
|
20
|
-
|
21
|
-
@uploader = nil # fix issue with Ruby 1.9.2 and serialization
|
12
|
+
@enabled = enabled
|
22
13
|
end
|
23
14
|
|
24
15
|
def before(worker)
|
@@ -26,7 +17,7 @@ module Locomotive
|
|
26
17
|
end
|
27
18
|
|
28
19
|
def perform
|
29
|
-
|
20
|
+
puts "theme_file = #{@theme_file} / #{@site.present?} / #{@enabled.inspect}"
|
30
21
|
|
31
22
|
self.unzip!
|
32
23
|
|
@@ -40,96 +31,23 @@ module Locomotive
|
|
40
31
|
:worker => @worker
|
41
32
|
}
|
42
33
|
|
43
|
-
self.reset! if @options[:reset]
|
44
|
-
|
45
34
|
%w(site content_types assets asset_collections snippets pages).each do |step|
|
46
|
-
if @
|
47
|
-
"Locomotive::Import::#{step.camelize}".constantize.process(context
|
35
|
+
if @enabled[step] != false
|
36
|
+
"Locomotive::Import::#{step.camelize}".constantize.process(context)
|
48
37
|
@worker.update_attributes :step => step if @worker
|
49
38
|
else
|
50
|
-
|
39
|
+
puts "skipping #{step}"
|
51
40
|
end
|
52
41
|
end
|
53
42
|
end
|
54
43
|
|
55
|
-
def success(worker)
|
56
|
-
self.log 'deleting original zip file'
|
57
|
-
|
58
|
-
uploader = self.get_uploader(@site)
|
59
|
-
|
60
|
-
uploader.retrieve_from_store!(@identifier)
|
61
|
-
|
62
|
-
uploader.remove!
|
63
|
-
|
64
|
-
self.log 'deleting working folder'
|
65
|
-
|
66
|
-
FileUtils.rm_rf(themes_folder) rescue nil
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.run!(zipfile, site, options = {})
|
70
|
-
job = self.new(zipfile, site, options)
|
71
|
-
|
72
|
-
if Locomotive.config.delayed_job
|
73
|
-
Delayed::Job.enqueue job, { :site => site, :job_type => 'import' }
|
74
|
-
else
|
75
|
-
job.perform
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
44
|
protected
|
80
45
|
|
81
|
-
def themes_folder
|
82
|
-
File.join(Rails.root, 'tmp', 'themes', @site.id.to_s)
|
83
|
-
end
|
84
|
-
|
85
|
-
def prepare_folder
|
86
|
-
FileUtils.rm_rf self.themes_folder if File.exists?(self.themes_folder)
|
87
|
-
|
88
|
-
FileUtils.mkdir_p(self.themes_folder)
|
89
|
-
end
|
90
|
-
|
91
|
-
def store_zipfile(zipfile)
|
92
|
-
return nil if zipfile.blank?
|
93
|
-
|
94
|
-
file = CarrierWave::SanitizedFile.new(zipfile)
|
95
|
-
|
96
|
-
uploader = self.get_uploader(@site)
|
97
|
-
|
98
|
-
begin
|
99
|
-
uploader.store!(file)
|
100
|
-
uploader.identifier
|
101
|
-
rescue CarrierWave::IntegrityError
|
102
|
-
nil
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def retrieve_zipfile
|
107
|
-
uploader = self.get_uploader(@site)
|
108
|
-
|
109
|
-
uploader.retrieve_from_store!(@identifier)
|
110
|
-
|
111
|
-
if uploader.file.respond_to?(:url)
|
112
|
-
self.log 'file from remote storage'
|
113
|
-
|
114
|
-
@theme_file = File.join(self.themes_folder, @identifier)
|
115
|
-
|
116
|
-
File.open(@theme_file, 'w') { |f| f.write(uploader.file.read) }
|
117
|
-
else # local filesystem
|
118
|
-
self.log 'file from local storage'
|
119
|
-
|
120
|
-
@theme_file = uploader.path
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
46
|
def unzip!
|
125
|
-
self.prepare_folder
|
126
|
-
|
127
|
-
self.retrieve_zipfile
|
128
|
-
|
129
|
-
self.log "unzip #{@theme_file}"
|
130
|
-
|
131
47
|
Zip::ZipFile.open(@theme_file) do |zipfile|
|
132
|
-
destination_path =
|
48
|
+
destination_path = File.join(Rails.root, 'tmp', 'themes', @site.id.to_s)
|
49
|
+
|
50
|
+
FileUtils.rm_r destination_path, :force => true
|
133
51
|
|
134
52
|
zipfile.each do |entry|
|
135
53
|
next if entry.name =~ /__MACOSX/
|
@@ -147,20 +65,7 @@ module Locomotive
|
|
147
65
|
zipfile.extract(entry, File.join(destination_path, entry.name))
|
148
66
|
end
|
149
67
|
end
|
150
|
-
end
|
151
68
|
|
152
|
-
def reset!
|
153
|
-
@site.pages.destroy_all
|
154
|
-
@site.theme_assets.destroy_all
|
155
|
-
@site.content_types.destroy_all
|
156
|
-
@site.asset_collections.destroy_all
|
157
|
-
end
|
158
|
-
|
159
|
-
def get_uploader(site)
|
160
|
-
unless Locomotive.config.delayed_job
|
161
|
-
ThemeUploader.storage = :file
|
162
|
-
end
|
163
|
-
@uploader ||= ThemeUploader.new(site)
|
164
69
|
end
|
165
70
|
|
166
71
|
end
|