locomotivecms 3.0.0.pre.alpha.2 → 3.0.0.pre.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +1 -1
- data/app/api/locomotive/api/forms/membership_form.rb +13 -0
- data/app/api/locomotive/api/resources/membership_resource.rb +5 -3
- data/app/assets/javascripts/locomotive.js +2 -0
- data/app/assets/javascripts/locomotive/utils/backbone_patches.js.coffee +15 -1
- data/app/assets/javascripts/locomotive/utils/file.js.coffee +20 -0
- data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/utils/rails_ujs.js.coffee +36 -0
- data/app/assets/javascripts/locomotive/utils/wysihtml5.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +9 -17
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_view.js.coffee +39 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +104 -1
- data/app/assets/javascripts/locomotive/views/inputs/file_view.js.coffee +79 -10
- data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +24 -4
- data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +18 -0
- data/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +3 -6
- data/app/assets/javascripts/locomotive/views/shared/drawer_view.js.coffee +24 -8
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +21 -148
- data/app/assets/stylesheets/locomotive/application.scss +6 -0
- data/app/assets/stylesheets/locomotive/base/_form.scss +1 -0
- data/app/assets/stylesheets/locomotive/base/form/_base.scss +9 -0
- data/app/assets/stylesheets/locomotive/base/form/_file_input.scss +1 -1
- data/app/assets/stylesheets/locomotive/base/form/_link.scss +13 -0
- data/app/assets/stylesheets/locomotive/base/form/_select2.scss +28 -1
- data/app/assets/stylesheets/locomotive/components/_drawer.scss +8 -18
- data/app/assets/stylesheets/locomotive/components/_live_editing.scss +83 -0
- data/app/assets/stylesheets/locomotive/components/_transitions.scss +63 -1
- data/app/assets/stylesheets/locomotive/components/header/_base.scss +5 -1
- data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +5 -7
- data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +4 -4
- data/app/assets/stylesheets/locomotive/globals/_mixins.scss +16 -0
- data/app/assets/stylesheets/locomotive/globals/_nprogress.scss +3 -0
- data/app/assets/stylesheets/locomotive/globals/_variables.scss +57 -49
- data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +29 -0
- data/app/controllers/locomotive/editable_elements_controller.rb +49 -2
- data/app/controllers/locomotive/pages_controller.rb +2 -2
- data/app/helpers/locomotive/custom_fields_helper.rb +1 -1
- data/app/helpers/locomotive/editable_elements_helper.rb +40 -0
- data/app/helpers/locomotive/pages_helper.rb +0 -1
- data/app/inputs/locomotive/array_input.rb +1 -1
- data/app/inputs/locomotive/file_input.rb +35 -7
- data/app/inputs/locomotive/rte_input.rb +2 -1
- data/app/inputs/locomotive/toggle_input.rb +1 -1
- data/app/models/locomotive/concerns/content_entry/localized.rb +4 -4
- data/app/models/locomotive/concerns/content_type/sync.rb +0 -5
- data/app/models/locomotive/concerns/page/redirect.rb +1 -1
- data/app/models/locomotive/content_entry.rb +5 -11
- data/app/models/locomotive/content_type.rb +22 -0
- data/app/models/locomotive/editable_control.rb +12 -27
- data/app/models/locomotive/editable_element.rb +8 -0
- data/app/models/locomotive/editable_file.rb +0 -1
- data/app/models/locomotive/editable_text.rb +10 -10
- data/app/models/locomotive/page.rb +1 -1
- data/app/policies/locomotive/page_policy.rb +1 -1
- data/app/services/locomotive/editable_element_service.rb +47 -0
- data/app/services/locomotive/page_parsing_service.rb +85 -31
- data/app/uploaders/locomotive/editable_file_uploader.rb +5 -1
- data/app/views/locomotive/editable_elements/_edit.html.haml +49 -0
- data/app/views/locomotive/editable_elements/_edit_with_content_entry.html.haml +21 -0
- data/app/views/locomotive/editable_elements/_form.html.haml +23 -0
- data/app/views/locomotive/editable_elements/index.html.haml +8 -2
- data/app/views/locomotive/editable_elements/index_without_preview.html.haml +33 -0
- data/app/views/locomotive/layouts/{preview.html.haml → live_editing.html.haml} +9 -9
- data/app/views/locomotive/my_account/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_actions.html.haml +8 -1
- data/app/views/locomotive/pages/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_tabs.html.haml +2 -2
- data/app/views/locomotive/pages/new.html.haml +1 -1
- data/app/views/locomotive/shared/header/_site.html.haml +1 -1
- data/app/views/locomotive/shared/rte/_image_popover.html.haml +2 -2
- data/app/views/locomotive/shared/rte/_link_popover.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_page.html.haml +5 -2
- data/config/locales/admin_ui.en.yml +10 -16
- data/config/locales/inputs.en.yml +18 -11
- data/config/locales/simple_form.en.yml +13 -1
- data/config/routes.rb +3 -1
- data/lib/locomotive.rb +1 -1
- data/lib/locomotive/action_controller/responder.rb +16 -0
- data/lib/locomotive/carrierwave/patches.rb +54 -0
- data/lib/locomotive/dependencies.rb +1 -0
- data/lib/locomotive/engine.rb +9 -3
- data/lib/locomotive/middlewares.rb +1 -1
- data/lib/locomotive/middlewares/page_editing.rb +41 -0
- data/lib/locomotive/middlewares/site.rb +2 -0
- data/lib/locomotive/simple_form.rb +6 -5
- data/lib/locomotive/steam_adaptor.rb +2 -0
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +4 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/mongoid.yml +2 -2
- data/spec/models/locomotive/content_entry_spec.rb +11 -2
- data/spec/support/factories.rb +0 -1
- data/vendor/assets/javascripts/locomotive/history.js +2122 -0
- data/vendor/assets/javascripts/locomotive/subscribe.js +206 -329
- metadata +44 -127
- data/lib/locomotive/middlewares/permalink.rb +0 -22
- data/lib/locomotive/previous_liquid/asset_host.rb +0 -51
- data/lib/locomotive/previous_liquid/drops/base.rb +0 -40
- data/lib/locomotive/previous_liquid/drops/content_entry.rb +0 -78
- data/lib/locomotive/previous_liquid/drops/content_types.rb +0 -119
- data/lib/locomotive/previous_liquid/drops/current_user.rb +0 -21
- data/lib/locomotive/previous_liquid/drops/page.rb +0 -115
- data/lib/locomotive/previous_liquid/drops/proxy_collection.rb +0 -64
- data/lib/locomotive/previous_liquid/drops/session_proxy.rb +0 -16
- data/lib/locomotive/previous_liquid/drops/site.rb +0 -29
- data/lib/locomotive/previous_liquid/drops/uploader.rb +0 -21
- data/lib/locomotive/previous_liquid/errors.rb +0 -8
- data/lib/locomotive/previous_liquid/filters/base.rb +0 -61
- data/lib/locomotive/previous_liquid/filters/date.rb +0 -82
- data/lib/locomotive/previous_liquid/filters/html.rb +0 -117
- data/lib/locomotive/previous_liquid/filters/misc.rb +0 -75
- data/lib/locomotive/previous_liquid/filters/resize.rb +0 -18
- data/lib/locomotive/previous_liquid/filters/text.rb +0 -53
- data/lib/locomotive/previous_liquid/filters/translate.rb +0 -38
- data/lib/locomotive/previous_liquid/patches.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/consume.rb +0 -104
- data/lib/locomotive/previous_liquid/tags/csrf.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/editable.rb +0 -4
- data/lib/locomotive/previous_liquid/tags/editable/base.rb +0 -88
- data/lib/locomotive/previous_liquid/tags/editable/control.rb +0 -41
- data/lib/locomotive/previous_liquid/tags/editable/file.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/editable/text.rb +0 -79
- data/lib/locomotive/previous_liquid/tags/extends.rb +0 -47
- data/lib/locomotive/previous_liquid/tags/fetch_page.rb +0 -36
- data/lib/locomotive/previous_liquid/tags/google_analytics.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/hybrid.rb +0 -25
- data/lib/locomotive/previous_liquid/tags/inherited_block.rb +0 -31
- data/lib/locomotive/previous_liquid/tags/inline_editor.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/javascript.rb +0 -16
- data/lib/locomotive/previous_liquid/tags/link_to.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/locale_switcher.rb +0 -83
- data/lib/locomotive/previous_liquid/tags/model_form.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/nav.rb +0 -164
- data/lib/locomotive/previous_liquid/tags/paginate.rb +0 -114
- data/lib/locomotive/previous_liquid/tags/path_helper.rb +0 -85
- data/lib/locomotive/previous_liquid/tags/path_to.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/seo.rb +0 -72
- data/lib/locomotive/previous_liquid/tags/session_assign.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/snippet.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/with_scope.rb +0 -65
- data/spec/fixtures/portfolio/Gemfile +0 -21
- data/spec/fixtures/portfolio/app/content_types/messages.yml +0 -57
- data/spec/fixtures/portfolio/app/content_types/projects.yml +0 -74
- data/spec/fixtures/portfolio/app/views/pages/404.liquid.haml +0 -10
- data/spec/fixtures/portfolio/app/views/pages/index.liquid.haml +0 -213
- data/spec/fixtures/portfolio/app/views/snippets/footer.liquid.haml +0 -2
- data/spec/fixtures/portfolio/config.ru +0 -3
- data/spec/fixtures/portfolio/config/deploy.yml +0 -18
- data/spec/fixtures/portfolio/config/site.yml +0 -33
- data/spec/fixtures/portfolio/config/translations.yml +0 -8
- data/spec/fixtures/portfolio/data/messages.yml +0 -1
- data/spec/fixtures/portfolio/data/projects.yml +0 -41
- data/spec/fixtures/portfolio/icon.png +0 -0
- data/spec/fixtures/portfolio/public/javascripts/bootstrap.min.js +0 -6
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.js +0 -44
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.min.js +0 -11
- data/spec/fixtures/portfolio/public/javascripts/classie.js +0 -80
- data/spec/fixtures/portfolio/public/javascripts/contact_me.js +0 -65
- data/spec/fixtures/portfolio/public/javascripts/freelancer.js +0 -37
- data/spec/fixtures/portfolio/public/javascripts/jqBootstrapValidation.js +0 -912
- data/spec/fixtures/portfolio/public/samples/portfolio/cabin.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/cake.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/circus.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/game.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/safe.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/submarine.png +0 -0
- data/spec/fixtures/portfolio/public/samples/profile.png +0 -0
- data/spec/fixtures/portfolio/public/stylesheets/bootstrap.min.css +0 -7
- data/spec/fixtures/portfolio/public/stylesheets/freelancer.css +0 -445
- data/spec/lib/locomotive/liquid/tags/editable/file_spec.rb +0 -72
- data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +0 -85
- data/spec/lib/locomotive/liquid/tags/extends_spec.rb +0 -58
- data/vendor/assets/javascripts/locomotive/editable_field.js +0 -50
- data/vendor/assets/javascripts/locomotive/form_submit_notification.js +0 -39
- data/vendor/assets/javascripts/locomotive/slugify.js +0 -47
@@ -1,78 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
class ContentEntry < Base
|
5
|
-
|
6
|
-
delegate :_slug, :_permalink, :_translated, :seo_title, :meta_keywords, :meta_description, to: :@_source
|
7
|
-
|
8
|
-
def _id
|
9
|
-
@_source._id.to_s
|
10
|
-
end
|
11
|
-
|
12
|
-
def _label
|
13
|
-
@_label ||= @_source._label
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns the next content for the parent content type.
|
17
|
-
# If no content is found, nil is returned.
|
18
|
-
#
|
19
|
-
# Usage:
|
20
|
-
#
|
21
|
-
# {% if article.next %}
|
22
|
-
# <a href="/articles/{{ article.next._permalink }}">Read next article</a>
|
23
|
-
# {% endif %}
|
24
|
-
#
|
25
|
-
def next
|
26
|
-
@next ||= @_source.next.to_liquid
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns the previous content for the parent content type.
|
30
|
-
# If no content is found, nil is returned.
|
31
|
-
#
|
32
|
-
# Usage:
|
33
|
-
#
|
34
|
-
# {% if article.previous %}
|
35
|
-
# <a href="/articles/{{ article.previous._permalink }}">Read previous article</a>
|
36
|
-
# {% endif %}
|
37
|
-
#
|
38
|
-
def previous
|
39
|
-
@previous ||= @_source.previous.to_liquid
|
40
|
-
end
|
41
|
-
|
42
|
-
def errors
|
43
|
-
@_source.errors.messages.to_hash.stringify_keys
|
44
|
-
end
|
45
|
-
|
46
|
-
def before_method(meth)
|
47
|
-
return '' if @_source.nil?
|
48
|
-
|
49
|
-
if not @@forbidden_attributes.include?(meth.to_s)
|
50
|
-
value = @_source.send(meth)
|
51
|
-
|
52
|
-
if value.respond_to?(:all) # check for an association
|
53
|
-
filter_and_order_list(value)
|
54
|
-
else
|
55
|
-
value
|
56
|
-
end
|
57
|
-
else
|
58
|
-
nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
protected
|
63
|
-
|
64
|
-
def filter_and_order_list(list)
|
65
|
-
conditions, order_by = HashWithIndifferentAccess.new(_visible: true), nil
|
66
|
-
|
67
|
-
if @context['with_scope']
|
68
|
-
conditions.merge!(@context['with_scope'])
|
69
|
-
order_by = conditions.delete(:order_by).try(:split)
|
70
|
-
end
|
71
|
-
|
72
|
-
list.filtered(conditions, order_by)
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
class ContentTypes < ::Liquid::Drop
|
5
|
-
|
6
|
-
def before_method(meth)
|
7
|
-
type = @context.registers[:site].content_types.where(slug: meth.to_s).first
|
8
|
-
ContentTypeProxyCollection.new(type)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
class ContentTypeProxyCollection < ProxyCollection
|
14
|
-
|
15
|
-
def initialize(content_type)
|
16
|
-
@content_type = content_type
|
17
|
-
@collection = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def public_submission_url
|
21
|
-
site = @context.registers[:controller].send(:current_site)
|
22
|
-
@context.registers[:controller].locomotive_entry_submissions_path(site, @content_type.slug)
|
23
|
-
end
|
24
|
-
|
25
|
-
def api
|
26
|
-
Locomotive.log :warn, "[Liquid template] the api for content_types has been deprecated and replaced by public_submission_url instead."
|
27
|
-
{ 'create' => public_submission_url }
|
28
|
-
end
|
29
|
-
|
30
|
-
def before_method(meth)
|
31
|
-
klass = @content_type.entries.klass # delegate to the proxy class
|
32
|
-
|
33
|
-
if (meth.to_s =~ /^group_by_(.+)$/) == 0
|
34
|
-
klass.send(:group_by_select_option, $1, @content_type.order_by_definition)
|
35
|
-
elsif (meth.to_s =~ /^(.+)_options$/) == 0
|
36
|
-
klass.send(:"#{$1}_options").map { |option| option['name'] }
|
37
|
-
else
|
38
|
-
Locomotive.log :warn, "[Liquid template] trying to call #{meth} on a content_type object"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
protected
|
43
|
-
|
44
|
-
def collection
|
45
|
-
options = {}
|
46
|
-
|
47
|
-
if @context['with_scope']
|
48
|
-
self.modify_with_scope
|
49
|
-
|
50
|
-
options = { where: @context['with_scope'] }
|
51
|
-
|
52
|
-
options[:order_by] = options[:where].delete(:order_by)
|
53
|
-
end
|
54
|
-
|
55
|
-
@collection ||= @content_type.ordered_entries(options).visible
|
56
|
-
end
|
57
|
-
|
58
|
-
# Modify the attributes of the with_scope tag so that
|
59
|
-
# they can be resolved by MongoDB.
|
60
|
-
#
|
61
|
-
def modify_with_scope
|
62
|
-
@context['with_scope'].dup.each do |key, value|
|
63
|
-
field = @content_type.find_entries_custom_field(key.to_s)
|
64
|
-
|
65
|
-
next if field.nil?
|
66
|
-
|
67
|
-
case field.type.to_sym
|
68
|
-
when :belongs_to
|
69
|
-
self.modify_with_scope_key(key, "#{key.to_s}_id", self.object_to_id(field, value))
|
70
|
-
when :many_to_many
|
71
|
-
self.modify_with_scope_key(key, "#{key.to_s.singularize}_ids", self.object_to_id(field, value))
|
72
|
-
when :select
|
73
|
-
option = field.select_options.detect { |option| [option.name, option._id.to_s].include?(value) }
|
74
|
-
self.modify_with_scope_key(key, "#{key.to_s}_id", option.try(:_id))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Change the value of a key of the with_scope depending of its type.
|
80
|
-
# If the key is a Origin::Key, we only change the name.
|
81
|
-
# If the key is a String, we replace it.
|
82
|
-
#
|
83
|
-
# @param [ Object ] key Either a String or a Origin::Key
|
84
|
-
# @param [ String ] name The new name of the key
|
85
|
-
# @param [ String ] value The new value associated to the key
|
86
|
-
#
|
87
|
-
def modify_with_scope_key(key, name, value)
|
88
|
-
if key.respond_to?(:operator)
|
89
|
-
key.instance_variable_set :@name, name
|
90
|
-
@context['with_scope'][key] = value
|
91
|
-
else
|
92
|
-
@context['with_scope'].delete(key)
|
93
|
-
@context['with_scope'][name] = value
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# Get the _id attribute of a object or a list of objects which
|
98
|
-
# can include String (needed to retrieve a model
|
99
|
-
# based on its permalink or its label field) or ContentEntry instances.
|
100
|
-
#
|
101
|
-
# @param [ Object ] field The custom field
|
102
|
-
# @param [ Object ] value An object (content entry or label) or a list of objects
|
103
|
-
#
|
104
|
-
def object_to_id(field, value)
|
105
|
-
if value.respond_to?(:map)
|
106
|
-
value.map { |el| self.object_to_id(field, el) }
|
107
|
-
elsif value.respond_to?(:_id)
|
108
|
-
value._id
|
109
|
-
else
|
110
|
-
model = Locomotive::ContentType.class_name_to_content_type(field.class_name, @content_type.site)
|
111
|
-
model.entries.or({ _slug: value }, { model.label_field_name => value }).first.try(:_id)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
class CurrentUser < Base
|
5
|
-
|
6
|
-
def logged_in?
|
7
|
-
@_source.present?
|
8
|
-
end
|
9
|
-
|
10
|
-
def name
|
11
|
-
@_source.name if logged_in?
|
12
|
-
end
|
13
|
-
|
14
|
-
def email
|
15
|
-
@_source.email if logged_in?
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
class Page < Base
|
5
|
-
|
6
|
-
delegate :seo_title, :meta_keywords, :meta_description, :redirect_url, :handle, to: :@_source
|
7
|
-
|
8
|
-
def title
|
9
|
-
title = @_source.templatized? ? @context['entry'].try(:_label) : nil
|
10
|
-
title || @_source.title
|
11
|
-
end
|
12
|
-
|
13
|
-
def slug
|
14
|
-
slug = @_source.templatized? ? @context['entry'].try(:_slug).try(:singularize) : nil
|
15
|
-
slug || @_source.slug
|
16
|
-
end
|
17
|
-
|
18
|
-
def original_title
|
19
|
-
@_source.title
|
20
|
-
end
|
21
|
-
|
22
|
-
def original_slug
|
23
|
-
@_source.slug
|
24
|
-
end
|
25
|
-
|
26
|
-
def parent
|
27
|
-
@parent ||= @_source.parent.to_liquid
|
28
|
-
end
|
29
|
-
|
30
|
-
def breadcrumbs
|
31
|
-
@breadcrumbs ||= liquify(*@_source.ancestors_and_self)
|
32
|
-
end
|
33
|
-
|
34
|
-
def children
|
35
|
-
@children ||= liquify(*@_source.children)
|
36
|
-
end
|
37
|
-
|
38
|
-
def fullpath
|
39
|
-
@fullpath ||= @_source.fullpath
|
40
|
-
end
|
41
|
-
|
42
|
-
def depth
|
43
|
-
@_source.depth
|
44
|
-
end
|
45
|
-
|
46
|
-
def listed?
|
47
|
-
@_source.listed?
|
48
|
-
end
|
49
|
-
|
50
|
-
def published?
|
51
|
-
@_source.published?
|
52
|
-
end
|
53
|
-
|
54
|
-
def redirect?
|
55
|
-
@_source.redirect?
|
56
|
-
end
|
57
|
-
|
58
|
-
def is_layout?
|
59
|
-
@_source.is_layout?
|
60
|
-
end
|
61
|
-
|
62
|
-
def templatized?
|
63
|
-
@_source.templatized?
|
64
|
-
end
|
65
|
-
|
66
|
-
def content_type
|
67
|
-
if @_source.content_type
|
68
|
-
ContentTypeProxyCollection.new(@_source.content_type)
|
69
|
-
else
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def editable_elements
|
75
|
-
@editable_elements_hash ||= build_editable_elements_hash
|
76
|
-
end
|
77
|
-
|
78
|
-
def before_method(meth)
|
79
|
-
# @deprecated
|
80
|
-
@_source.editable_elements.where(slug: meth).try(:first).try(:content)
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def build_editable_elements_hash
|
86
|
-
{}.tap do |hash|
|
87
|
-
@_source.editable_elements.each do |el|
|
88
|
-
safe_slug = el.slug.parameterize.underscore
|
89
|
-
keys = el.block.try(:split, '/').try(:compact) || []
|
90
|
-
|
91
|
-
_hash = _build_editable_elements_hashes(hash, keys)
|
92
|
-
|
93
|
-
_hash[safe_slug] = el.content
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def _build_editable_elements_hashes(hash, keys)
|
99
|
-
_hash = hash
|
100
|
-
|
101
|
-
keys.each do |key|
|
102
|
-
safe_key = key.parameterize.underscore
|
103
|
-
|
104
|
-
_hash[safe_key] = {} if _hash[safe_key].nil?
|
105
|
-
|
106
|
-
_hash = _hash[safe_key]
|
107
|
-
end
|
108
|
-
|
109
|
-
_hash
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
|
5
|
-
class ProxyCollection < ::Liquid::Drop
|
6
|
-
|
7
|
-
def initialize(collection)
|
8
|
-
@collection = collection
|
9
|
-
end
|
10
|
-
|
11
|
-
def first
|
12
|
-
self.collection.first
|
13
|
-
end
|
14
|
-
|
15
|
-
def last
|
16
|
-
self.collection.last
|
17
|
-
end
|
18
|
-
|
19
|
-
def each(&block)
|
20
|
-
self.collection.each(&block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def each_with_index(&block)
|
24
|
-
self.collection.each_with_index(&block)
|
25
|
-
end
|
26
|
-
|
27
|
-
def count
|
28
|
-
@count ||= self.collection.count
|
29
|
-
end
|
30
|
-
|
31
|
-
def all
|
32
|
-
self.collection
|
33
|
-
end
|
34
|
-
|
35
|
-
alias :size :count
|
36
|
-
alias :length :count
|
37
|
-
|
38
|
-
def empty
|
39
|
-
self.collection.empty?
|
40
|
-
end
|
41
|
-
|
42
|
-
def any
|
43
|
-
self.collection.any?
|
44
|
-
end
|
45
|
-
|
46
|
-
def content_type
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
protected
|
51
|
-
|
52
|
-
def paginate(options = {})
|
53
|
-
@collection = collection.page(options[:page]).per(options[:per_page])
|
54
|
-
end
|
55
|
-
|
56
|
-
def collection
|
57
|
-
@collection
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Locomotive
|
2
|
-
module Liquid
|
3
|
-
module Drops
|
4
|
-
class Site < Base
|
5
|
-
|
6
|
-
delegate :name, :seo_title, :meta_keywords, :meta_description, to: :@_source
|
7
|
-
|
8
|
-
def index
|
9
|
-
@index ||= @_source.pages.root.first
|
10
|
-
end
|
11
|
-
|
12
|
-
def pages
|
13
|
-
liquify(*self.scoped_pages)
|
14
|
-
end
|
15
|
-
|
16
|
-
def domains
|
17
|
-
@_source.domains
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def scoped_pages
|
23
|
-
@_source.ordered_pages(@context['with_scope'])
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|