locomotive_cms 0.0.4 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +15 -13
- data/README.textile +5 -4
- data/app/controllers/admin/api_contents_controller.rb +10 -1
- data/app/controllers/admin/base_controller.rb +2 -2
- data/app/controllers/admin/cross_domain_sessions_controller.rb +7 -4
- data/app/controllers/admin/current_sites_controller.rb +2 -0
- data/app/controllers/admin/imports_controller.rb +13 -19
- data/app/controllers/admin/installation_controller.rb +79 -0
- 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 +2 -0
- data/app/controllers/admin/theme_assets_controller.rb +1 -1
- data/app/controllers/application_controller.rb +1 -1
- data/app/helpers/admin/assets_helper.rb +0 -6
- data/app/helpers/admin/{login_helper.rb → box_helper.rb} +7 -3
- data/app/helpers/admin/custom_fields_helper.rb +2 -2
- data/app/models/asset_collection.rb +15 -3
- data/app/models/content_instance.rb +19 -0
- data/app/models/content_type.rb +21 -3
- data/app/models/extensions/page/tree.rb +63 -7
- data/app/models/page.rb +2 -0
- data/app/models/site.rb +15 -3
- data/app/uploaders/asset_uploader.rb +1 -1
- data/app/uploaders/theme_asset_uploader.rb +12 -1
- data/app/uploaders/theme_uploader.rb +19 -0
- 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/errors/no_page.html.haml +1 -0
- data/app/views/admin/errors/no_site.html.haml +1 -0
- data/app/views/admin/imports/new.html.haml +11 -0
- data/app/views/admin/imports/show.html.haml +1 -1
- data/app/views/admin/installation/step_1.html.haml +24 -0
- data/app/views/admin/installation/step_2.html.haml +26 -0
- data/app/views/admin/installation/step_3.html.haml +23 -0
- data/app/views/{layouts/admin → admin/layouts}/application.html.haml +0 -0
- data/app/views/admin/layouts/box.html.haml +21 -0
- data/app/views/admin/layouts/error.html.haml +1 -0
- data/app/views/admin/my_accounts/edit.html.haml +1 -1
- data/app/views/admin/pages/_form.html.haml +2 -3
- data/app/views/admin/pages/_page.html.haml +4 -2
- 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 +4 -5
- 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/theme_assets/_form.html.haml +2 -2
- data/app/views/admin/theme_assets/index.html.haml +1 -1
- data/config/application.rb +1 -3
- data/config/assets.yml +96 -0
- data/config/environments/development.rb +1 -6
- data/config/environments/production.rb +1 -1
- data/config/environments/test.rb +1 -5
- data/config/initializers/carrierwave.rb +17 -0
- data/config/initializers/locomotive.rb +14 -0
- data/config/locales/admin_ui_en.yml +33 -1
- data/config/locales/admin_ui_fr.yml +34 -1
- data/config/locales/default_en.yml +1 -0
- data/config/locales/default_fr.yml +1 -0
- data/config/locales/flash.en.yml +1 -0
- data/config/locales/flash.fr.yml +1 -0
- data/config/mongoid.yml +13 -5
- data/config/routes.rb +6 -1
- data/lib/generators/locomotive/install/install_generator.rb +18 -10
- data/lib/generators/locomotive/install/templates/README +23 -13
- data/lib/generators/locomotive/install/templates/locomotive.rb +15 -1
- data/lib/locomotive/carrierwave.rb +1 -0
- data/lib/locomotive/configuration.rb +3 -1
- data/lib/locomotive/custom_fields.rb +0 -1
- data/lib/locomotive/delayed_job.rb +1 -2
- data/lib/locomotive/engine.rb +24 -7
- data/lib/locomotive/heroku.rb +1 -0
- data/lib/locomotive/httparty/webservice.rb +12 -1
- data/lib/locomotive/import.rb +2 -0
- data/lib/locomotive/import/asset_collections.rb +40 -8
- data/lib/locomotive/import/assets.rb +20 -12
- data/lib/locomotive/import/base.rb +46 -0
- data/lib/locomotive/import/content_types.rb +51 -15
- data/lib/locomotive/import/job.rb +106 -11
- data/lib/locomotive/import/logger.rb +13 -0
- data/lib/locomotive/import/pages.rb +79 -26
- data/lib/locomotive/import/site.rb +3 -5
- data/lib/locomotive/import/snippets.rb +6 -8
- data/lib/locomotive/inherited_resources.rb +1 -0
- data/lib/locomotive/liquid/drops/asset_collections.rb +4 -4
- data/lib/locomotive/liquid/drops/contents.rb +21 -16
- data/lib/locomotive/liquid/drops/page.rb +4 -0
- data/lib/locomotive/liquid/filters/html.rb +15 -29
- data/lib/locomotive/liquid/tags/consume.rb +1 -1
- data/lib/locomotive/liquid/tags/nav.rb +48 -17
- data/lib/locomotive/liquid/tags/paginate.rb +3 -3
- data/lib/locomotive/middlewares/fonts.rb +3 -11
- data/lib/locomotive/misc_form_builder.rb +2 -7
- data/lib/locomotive/railties/tasks.rake +16 -0
- data/lib/locomotive/regexps.rb +1 -1
- data/lib/locomotive/render.rb +9 -3
- data/lib/locomotive/routing/site_dispatcher.rb +10 -6
- data/lib/locomotive/version.rb +1 -1
- 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 +140 -101
- data/public/javascripts/admin/aloha/aloha.js +193 -105
- data/public/javascripts/admin/aloha/css/aloha.css +65 -4
- data/public/javascripts/admin/aloha/deps/prettyPhoto/resources/css/prettyPhoto.css +2 -2
- data/public/javascripts/admin/aloha/i18n/de.dict +2 -0
- data/public/javascripts/admin/aloha/i18n/en.dict +2 -0
- data/public/javascripts/admin/aloha/i18n/pl.dict +5 -0
- data/public/javascripts/admin/aloha/images/base.png +0 -0
- data/public/javascripts/admin/aloha/images/base_big.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.plugins.Product/examples/triSports.css +86 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.html +44 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/de.dict +4 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/en.dict +4 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/fr.dict +4 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/plugin.js +1 -0
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/product.js +1 -0
- 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 +69 -0
- 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.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/de.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/en.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fi.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fr.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/it.dict +0 -0
- data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/plugin.js +0 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.css +48 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.html +69 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/de.dict +4 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/en.dict +4 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/plugin.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/i18n/pl.dict +30 -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.HighlightEditables/plugin.js +1 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/LinkList.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/delicious.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/i18n/pl.dict +4 -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.LinkChecker/css/LinkChecker.css +14 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.css +49 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.html +82 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/i18n/en.dict +27 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/plugin.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/proxy.php +235 -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.Paste/plugin.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/wordpastehandler.js +7 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/de.dict +1 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/en.dict +1 -0
- 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 +2 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/en.dict +2 -0
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/pl.dict +12 -0
- 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 +28 -110
- 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/javascripts/admin/asset_collections.js +11 -7
- data/public/javascripts/admin/contents.js +3 -1
- data/public/javascripts/admin/site.js +9 -3
- data/public/javascripts/admin/snippets.js +1 -1
- data/public/javascripts/admin/utils.js +5 -3
- data/public/stylesheets/admin/application.css +1 -1
- data/public/stylesheets/admin/box.css +5 -5
- data/public/stylesheets/admin/buttons.css +0 -5
- data/public/stylesheets/admin/formtastic_changes.css +5 -12
- data/public/stylesheets/admin/inline_editor.css +22 -5
- data/public/stylesheets/admin/installation.css +50 -0
- data/public/stylesheets/admin/layout.css +9 -4
- data/public/stylesheets/admin/safari.css +15 -0
- metadata +188 -131
- data/app/controllers/home_controller.rb +0 -7
- data/app/views/admin/snippets/index.html.haml +0 -15
- data/app/views/home/show.html.haml +0 -4
- data/app/views/layouts/admin/box.html.haml +0 -19
- data/app/views/layouts/application.html.haml +0 -7
- data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +0 -14
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/de.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/en.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/eo.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fi.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fr.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/it.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/plugin.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/de.dict +0 -20
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/en.dict +0 -20
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/eo.dict +0 -16
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fi.dict +0 -20
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fr.dict +0 -16
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/it.dict +0 -20
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/plugin.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/css/jquery.autocomplete.css +0 -48
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/deps/jquery.autocomplete.js +0 -1
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressource.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourcedummy.js +0 -7
- data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourceregistry.js +0 -7
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Loader/plugin.js +0 -1
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/en.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fi.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fr.dict +0 -2
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/person.css +0 -3
- data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/plugin.js +0 -1
- data/public/javascripts/admin/aloha/plugins/simpletable/plugin.js.deactivated +0 -2330
@@ -1,11 +1,9 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Import
|
3
|
-
|
3
|
+
class Site < Base
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
attributes = database['site'].clone.delete_if { |name, value| %w{pages assets content_types asset_collections}.include?(name) }
|
5
|
+
def process
|
6
|
+
attributes = database['site'].clone.delete_if { |name, value| %w{name pages assets content_types asset_collections}.include?(name) }
|
9
7
|
|
10
8
|
site.attributes = attributes
|
11
9
|
|
@@ -1,20 +1,18 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Import
|
3
|
-
|
4
|
-
|
5
|
-
def self.process(context)
|
6
|
-
site, theme_path = context[:site], context[:theme_path]
|
3
|
+
class Snippets < Base
|
7
4
|
|
5
|
+
def process
|
8
6
|
Dir[File.join(theme_path, 'snippets', '*')].each do |snippet_path|
|
7
|
+
self.log "path = #{snippet_path}"
|
9
8
|
|
10
9
|
name = File.basename(snippet_path, File.extname(snippet_path)).parameterize('_')
|
11
|
-
|
10
|
+
|
12
11
|
snippet = site.snippets.where(:slug => name).first || site.snippets.build(:name => name)
|
13
12
|
|
14
|
-
snippet.template = File.read(snippet_path) # = site.snippets.create! :name => name, :template =>
|
15
|
-
|
13
|
+
snippet.template = File.read(snippet_path) # = site.snippets.create! :name => name, :template =>
|
14
|
+
|
16
15
|
snippet.save!
|
17
|
-
# puts "snippet = #{snippet.inspect}"
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
@@ -18,19 +18,19 @@ module Locomotive
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def first
|
21
|
-
@collection.
|
21
|
+
@collection.ordered_assets.first
|
22
22
|
end
|
23
23
|
|
24
24
|
def last
|
25
|
-
@collection.
|
25
|
+
@collection.ordered_assets.last
|
26
26
|
end
|
27
27
|
|
28
28
|
def each(&block)
|
29
|
-
@collection.
|
29
|
+
@collection.ordered_assets.each(&block)
|
30
30
|
end
|
31
31
|
|
32
32
|
def paginate(options = {})
|
33
|
-
paginated_collection = @collection.
|
33
|
+
paginated_collection = @collection.ordered_assets.paginate(options)
|
34
34
|
{
|
35
35
|
:collection => paginated_collection,
|
36
36
|
:current_page => paginated_collection.current_page,
|
@@ -18,20 +18,34 @@ module Locomotive
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def first
|
21
|
-
|
21
|
+
self.collection.first
|
22
22
|
end
|
23
23
|
|
24
24
|
def last
|
25
|
-
|
25
|
+
self.collection.last
|
26
26
|
end
|
27
27
|
|
28
28
|
def each(&block)
|
29
|
-
|
30
|
-
|
29
|
+
self.collection.each(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def api
|
33
|
+
{ 'create' => @context.registers[:controller].send('admin_api_contents_url', @content_type.slug) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def before_method(meth)
|
37
|
+
klass = @content_type.contents.klass # delegate to the proxy class
|
38
|
+
if (meth.to_s =~ /^group_by_.+$/) == 0
|
39
|
+
klass.send(meth, :ordered_contents)
|
40
|
+
else
|
41
|
+
klass.send(meth)
|
42
|
+
end
|
31
43
|
end
|
32
44
|
|
45
|
+
protected
|
46
|
+
|
33
47
|
def paginate(options = {})
|
34
|
-
@collection
|
48
|
+
@collection = self.collection.paginate(options)
|
35
49
|
{
|
36
50
|
:collection => @collection,
|
37
51
|
:current_page => @collection.current_page,
|
@@ -43,17 +57,8 @@ module Locomotive
|
|
43
57
|
}
|
44
58
|
end
|
45
59
|
|
46
|
-
def
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def before_method(meth)
|
51
|
-
klass = @content_type.contents.klass # delegate to the proxy class
|
52
|
-
if (meth.to_s =~ /^group_by_.+$/) == 0
|
53
|
-
klass.send(meth, :ordered_contents)
|
54
|
-
else
|
55
|
-
klass.send(meth)
|
56
|
-
end
|
60
|
+
def collection
|
61
|
+
@collection ||= @content_type.ordered_contents(@context['with_scope'])
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
@@ -9,11 +9,7 @@ module Locomotive
|
|
9
9
|
return '' if input.nil?
|
10
10
|
|
11
11
|
unless input =~ /^(\/|http:)/
|
12
|
-
|
13
|
-
|
14
|
-
filename, folder = segments.pop, segments.join('/')
|
15
|
-
|
16
|
-
input = asset_url(folder, filename)
|
12
|
+
input = asset_url("stylesheets/#{input}")
|
17
13
|
end
|
18
14
|
|
19
15
|
input = "#{input}.css" unless input.ends_with?('.css')
|
@@ -27,14 +23,7 @@ module Locomotive
|
|
27
23
|
return '' if input.nil?
|
28
24
|
|
29
25
|
unless input =~ /^(\/|http:)/
|
30
|
-
|
31
|
-
|
32
|
-
filename, folder = segments.pop, segments.join('/')
|
33
|
-
|
34
|
-
input = asset_url(folder, filename)
|
35
|
-
# javascript = ThemeAsset.new(:site => @context.registers[:site], :folder => folder)
|
36
|
-
#
|
37
|
-
# input = '/' + ThemeAssetUploader.new(javascript).store_path(filename)
|
26
|
+
input = asset_url("javascripts/#{input}")
|
38
27
|
end
|
39
28
|
|
40
29
|
input = "#{input}.js" unless input.ends_with?('.js')
|
@@ -47,18 +36,14 @@ module Locomotive
|
|
47
36
|
|
48
37
|
input = "images/#{input}" unless input.starts_with?('/')
|
49
38
|
|
50
|
-
|
51
|
-
|
52
|
-
filename, folder = segments.pop, segments.join('/')
|
53
|
-
|
54
|
-
asset_url(folder, filename)
|
39
|
+
asset_url(input)
|
55
40
|
end
|
56
41
|
|
57
42
|
# Write an image tag
|
58
43
|
# input: url of the image OR asset drop
|
59
44
|
def image_tag(input, *args)
|
60
45
|
image_options = inline_options(args_to_options(args))
|
61
|
-
"<img src=\"#{
|
46
|
+
"<img src=\"#{get_url_from_asset(input)}\" #{image_options}/>"
|
62
47
|
end
|
63
48
|
|
64
49
|
# Embed a flash movie into a page
|
@@ -83,10 +68,13 @@ module Locomotive
|
|
83
68
|
|
84
69
|
options = args_to_options(args)
|
85
70
|
|
71
|
+
previous_label = options[:previous_label] || I18n.t('pagination.previous')
|
72
|
+
next_label = options[:next_label] || I18n.t('pagination.next')
|
73
|
+
|
86
74
|
previous_link = (if paginate['previous'].blank?
|
87
|
-
"<span class=\"disabled prev_page\">#{
|
75
|
+
"<span class=\"disabled prev_page\">#{previous_label}</span>"
|
88
76
|
else
|
89
|
-
"<a href=\"#{paginate['previous']['url']}\" class=\"prev_page\">#{
|
77
|
+
"<a href=\"#{paginate['previous']['url']}\" class=\"prev_page\">#{previous_label}</a>"
|
90
78
|
end)
|
91
79
|
|
92
80
|
links = ""
|
@@ -101,9 +89,9 @@ module Locomotive
|
|
101
89
|
end
|
102
90
|
|
103
91
|
next_link = (if paginate['next'].blank?
|
104
|
-
"<span class=\"disabled next_page\">#{
|
92
|
+
"<span class=\"disabled next_page\">#{next_label}</span>"
|
105
93
|
else
|
106
|
-
"<a href=\"#{paginate['next']['url']}\" class=\"next_page\">#{
|
94
|
+
"<a href=\"#{paginate['next']['url']}\" class=\"next_page\">#{next_label}</a>"
|
107
95
|
end)
|
108
96
|
|
109
97
|
%{<div class="pagination #{options[:css]}">
|
@@ -131,7 +119,7 @@ module Locomotive
|
|
131
119
|
# <key1>="<value1>", <key2>="<value2", ...etc
|
132
120
|
def inline_options(options = {})
|
133
121
|
return '' if options.empty?
|
134
|
-
(options.stringify_keys.to_a.collect { |a, b| "#{a}=\"#{b}\"" }).join(' ') << ' '
|
122
|
+
(options.stringify_keys.sort.to_a.collect { |a, b| "#{a}=\"#{b}\"" }).join(' ') << ' '
|
135
123
|
end
|
136
124
|
|
137
125
|
# Get the url to be used in html tags such as image_tag, flash_tag, ...etc
|
@@ -140,12 +128,10 @@ module Locomotive
|
|
140
128
|
input.respond_to?(:url) ? input.url : input
|
141
129
|
end
|
142
130
|
|
143
|
-
def asset_url(
|
144
|
-
|
145
|
-
uploader = ThemeAssetUploader.new(asset)
|
146
|
-
uploader.retrieve_from_store!(filename)
|
147
|
-
uploader.url
|
131
|
+
def asset_url(path)
|
132
|
+
ThemeAssetUploader.url_for(@context.registers[:site], path)
|
148
133
|
end
|
134
|
+
|
149
135
|
end
|
150
136
|
|
151
137
|
::Liquid::Template.register_filter(Html)
|
@@ -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
|
|
@@ -1,22 +1,26 @@
|
|
1
1
|
module Locomotive
|
2
2
|
module Liquid
|
3
3
|
module Tags
|
4
|
-
# Display the children pages of the site or the
|
4
|
+
# Display the children pages of the site, current page or the parent page. If not precised, nav is applied on the current page.
|
5
5
|
# The html output is based on the ul/li tags.
|
6
6
|
#
|
7
7
|
# Usage:
|
8
8
|
#
|
9
9
|
# {% nav site %} => <ul class="nav"><li class="on"><a href="/features">Features</a></li></ul>
|
10
10
|
#
|
11
|
+
# {% nav site, no_wrapper: true, exclude: 'contact|about', id: 'main-nav' }
|
12
|
+
#
|
11
13
|
class Nav < ::Liquid::Tag
|
12
14
|
|
13
15
|
Syntax = /(#{::Liquid::Expression}+)?/
|
14
16
|
|
15
17
|
def initialize(tag_name, markup, tokens, context)
|
16
18
|
if markup =~ Syntax
|
17
|
-
@
|
18
|
-
@options = {}
|
19
|
-
markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value }
|
19
|
+
@source = ($1 || 'page').gsub(/"|'/, '')
|
20
|
+
@options = { :id => 'nav' }
|
21
|
+
markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') }
|
22
|
+
|
23
|
+
@options[:exclude] = Regexp.new(@options[:exclude]) if @options[:exclude]
|
20
24
|
else
|
21
25
|
raise ::Liquid::SyntaxError.new("Syntax Error in 'nav' - Valid syntax: nav <page|site> <options>")
|
22
26
|
end
|
@@ -25,34 +29,61 @@ module Locomotive
|
|
25
29
|
end
|
26
30
|
|
27
31
|
def render(context)
|
28
|
-
|
32
|
+
children_output = []
|
29
33
|
|
30
|
-
|
34
|
+
entries = fetch_entries(context)
|
31
35
|
|
32
|
-
|
36
|
+
entries.each_with_index do |p, index|
|
37
|
+
css = []
|
38
|
+
css << 'first' if index == 0
|
39
|
+
css << 'last' if index == entries.size - 1
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
children_output << render_entry_link(p, css.join(' '))
|
42
|
+
end
|
43
|
+
|
44
|
+
output = children_output.join("\n")
|
45
|
+
|
46
|
+
if @options[:no_wrapper] != 'true'
|
47
|
+
output = %{<ul id="#{@options[:id]}">\n#{output}</ul>}
|
38
48
|
end
|
39
49
|
|
40
|
-
output = %{<ul id="nav">}
|
41
|
-
output += source.children.map { |p| render_child_link(p) }.join("\n")
|
42
|
-
output += %{</ul>}
|
43
50
|
output
|
44
51
|
end
|
45
52
|
|
46
53
|
private
|
47
54
|
|
48
|
-
def
|
49
|
-
|
55
|
+
def fetch_entries(context)
|
56
|
+
@current_page = context.registers[:page]
|
57
|
+
|
58
|
+
children = (case @source
|
59
|
+
when 'site' then context.registers[:site].pages.index.minimal_attributes.first # start from home page
|
60
|
+
when 'parent' then @current_page.parent || @current_page
|
61
|
+
when 'page' then @current_page
|
62
|
+
else
|
63
|
+
context.registers[:site].pages.fullpath(@source).minimal_attributes.first
|
64
|
+
end).children_with_minimal_attributes.to_a
|
65
|
+
|
66
|
+
children.delete_if { |p| !include_page?(p) }
|
67
|
+
end
|
68
|
+
|
69
|
+
def include_page?(page)
|
70
|
+
if page.templatized? || !page.published?
|
71
|
+
false
|
72
|
+
elsif @options[:exclude]
|
73
|
+
(page.fullpath =~ @options[:exclude]).nil?
|
74
|
+
else
|
75
|
+
true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def render_entry_link(page, css)
|
80
|
+
selected = @current_page.fullpath =~ /^#{page.fullpath}/ ? ' on' : ''
|
50
81
|
|
51
82
|
icon = @options[:icon] ? '<span></span>' : ''
|
52
83
|
label = %{#{icon if @options[:icon] != 'after' }#{page.title}#{icon if @options[:icon] == 'after' }}
|
53
84
|
|
54
85
|
%{
|
55
|
-
<li id="#{page.slug.dasherize}" class="link#{selected}">
|
86
|
+
<li id="#{page.slug.dasherize}" class="link#{selected} #{css}">
|
56
87
|
<a href="/#{page.fullpath}">#{label}</a>
|
57
88
|
</li>
|
58
89
|
}.strip
|
@@ -36,13 +36,13 @@ module Locomotive
|
|
36
36
|
|
37
37
|
raise ::Liquid::ArgumentError.new("Cannot paginate array '#{@collection_name}'. Not found.") if collection.nil?
|
38
38
|
|
39
|
-
pagination = collection.paginate
|
39
|
+
pagination = collection.send(:paginate, {
|
40
40
|
:page => context['current_page'],
|
41
|
-
:per_page => @per_page }).stringify_keys
|
41
|
+
:per_page => @per_page }).stringify_keys
|
42
42
|
|
43
43
|
page_count, current_page = pagination['total_pages'], pagination['current_page']
|
44
44
|
|
45
|
-
path = context[
|
45
|
+
path = context.registers[:page].fullpath
|
46
46
|
|
47
47
|
pagination['previous'] = link(I18n.t('pagination.previous'), current_page - 1, path) if pagination['previous_page']
|
48
48
|
pagination['next'] = link(I18n.t('pagination.next'), current_page + 1, path) if pagination['next_page']
|
@@ -1,15 +1,11 @@
|
|
1
|
-
require 'rack/utils'
|
2
|
-
|
3
1
|
module Locomotive
|
4
2
|
module Middlewares
|
5
3
|
class Fonts
|
6
|
-
include Rack::Utils
|
7
4
|
|
8
5
|
def initialize(app, opts = {})
|
9
6
|
@app = app
|
10
7
|
@path_regexp = opts[:path] || %r{^/fonts/}
|
11
|
-
@
|
12
|
-
@expires_in = opts[:expires_in] || 24.hour
|
8
|
+
@expires_in = opts[:expires_in] || 24.hour # varnish
|
13
9
|
end
|
14
10
|
|
15
11
|
def call(env)
|
@@ -19,13 +15,9 @@ module Locomotive
|
|
19
15
|
if site.nil?
|
20
16
|
@app.call(env)
|
21
17
|
else
|
22
|
-
|
23
|
-
|
24
|
-
response = @file_server.call(env)
|
25
|
-
|
26
|
-
response[1]['Cache-Control'] = "public; max-age=#{@expires_in}" # varnish
|
18
|
+
body = ThemeAssetUploader.build(site, env["PATH_INFO"]).read.to_s
|
27
19
|
|
28
|
-
|
20
|
+
[200, { 'Cache-Control' => "public; max-age=#{@expires_in}" }, [body]]
|
29
21
|
end
|
30
22
|
else
|
31
23
|
@app.call(env)
|
@@ -34,14 +34,9 @@ module Locomotive
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
39
|
-
[$1, $2]
|
40
|
-
else
|
41
|
-
super
|
42
|
-
end
|
37
|
+
def model_name
|
38
|
+
@object.present? ? (@object.class.name || @object.class.model_name) : @object_name.to_s.classify
|
43
39
|
end
|
44
40
|
|
45
|
-
|
46
41
|
end
|
47
42
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Re-definitions are appended to existing tasks
|
2
|
+
|
3
|
+
# Embed tasks from Delayed_job
|
4
|
+
|
5
|
+
namespace :jobs do
|
6
|
+
desc "Clear the delayed_job queue."
|
7
|
+
task :clear => :environment do
|
8
|
+
Delayed::Job.delete_all
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Start a delayed_job worker."
|
12
|
+
task :work => :environment do
|
13
|
+
puts "Delayed::Job.new = #{Delayed::Job.new.inspect}"
|
14
|
+
::Delayed::Worker.new(:min_priority => ENV['MIN_PRIORITY'], :max_priority => ENV['MAX_PRIORITY']).start
|
15
|
+
end
|
16
|
+
end
|