locomotive_cms 2.0.0.rc2 → 2.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +4 -4
- data/app/assets/images/locomotive/icons/start.png +0 -0
- data/app/assets/javascripts/locomotive/models/page.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/models/site.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +11 -4
- data/app/assets/javascripts/locomotive/views/editable_elements/control_view.js.coffee +24 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_all_view.js.coffee +4 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/short_text_view.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +19 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +6 -0
- data/app/assets/stylesheets/locomotive/backoffice/application.css.scss +8 -0
- data/app/assets/stylesheets/locomotive/inline_editor/layout.css.scss +1 -0
- data/app/controllers/locomotive/pages_controller.rb +4 -3
- data/app/helpers/locomotive/pages_helper.rb +13 -0
- data/app/models/locomotive/editable_control.rb +56 -0
- data/app/models/locomotive/editable_element.rb +90 -18
- data/app/models/locomotive/editable_file.rb +63 -1
- data/app/models/locomotive/editable_long_text.rb +2 -0
- data/app/models/locomotive/editable_short_text.rb +32 -5
- data/app/models/locomotive/extensions/page/editable_elements.rb +14 -45
- data/app/models/locomotive/extensions/page/listed.rb +1 -0
- data/app/models/locomotive/extensions/page/parse.rb +10 -3
- data/app/models/locomotive/extensions/page/render.rb +80 -0
- data/app/models/locomotive/extensions/page/templatized.rb +43 -2
- data/app/models/locomotive/extensions/site/subdomain_domains.rb +1 -0
- data/app/models/locomotive/page.rb +7 -1
- data/app/models/locomotive/site.rb +4 -0
- data/app/presenters/locomotive/content_entry_presenter.rb +1 -1
- data/app/presenters/locomotive/editable_control_presenter.rb +18 -0
- data/app/presenters/locomotive/page_presenter.rb +2 -2
- data/app/views/locomotive/pages/_editable_elements.html.haml +12 -0
- data/app/views/locomotive/pages/_form.html.haml +6 -4
- data/app/views/locomotive/pages/_page.html.haml +3 -0
- data/app/views/locomotive/shared/menu/_contents.html.haml +1 -1
- data/config/locales/admin_ui.fr.yml +29 -3
- data/config/locales/default.en.yml +1 -1
- data/config/locales/default.fr.yml +23 -16
- data/config/locales/formtastic.en.yml +1 -7
- data/config/locales/formtastic.fr.yml +7 -14
- data/lib/locomotive.rb +1 -1
- data/lib/locomotive/engine.rb +8 -8
- data/lib/locomotive/liquid.rb +1 -0
- data/lib/locomotive/liquid/drops/content_entry.rb +2 -2
- data/lib/locomotive/liquid/drops/page.rb +1 -1
- data/lib/locomotive/liquid/errors.rb +2 -0
- data/lib/locomotive/liquid/filters/base.rb +47 -0
- data/lib/locomotive/liquid/filters/html.rb +16 -76
- data/lib/locomotive/liquid/filters/misc.rb +43 -18
- data/lib/locomotive/liquid/filters/text.rb +18 -0
- data/lib/locomotive/liquid/tags/editable.rb +1 -1
- data/lib/locomotive/liquid/tags/editable/base.rb +15 -24
- data/lib/locomotive/liquid/tags/editable/control.rb +31 -0
- data/lib/locomotive/liquid/tags/editable/file.rb +17 -1
- data/lib/locomotive/liquid/tags/editable/long_text.rb +5 -3
- data/lib/locomotive/liquid/tags/editable/short_text.rb +9 -3
- data/lib/locomotive/liquid/tags/extends.rb +3 -1
- data/lib/locomotive/liquid/tags/locale_switcher.rb +2 -2
- data/lib/locomotive/liquid/tags/nav.rb +26 -7
- data/lib/locomotive/liquid/tags/paginate.rb +9 -2
- data/lib/locomotive/middlewares.rb +2 -1
- data/lib/locomotive/middlewares/inline_editor.rb +31 -0
- data/lib/locomotive/render.rb +5 -29
- data/lib/locomotive/version.rb +1 -1
- data/vendor/assets/javascripts/locomotive/cmd.js +31 -0
- data/vendor/assets/javascripts/locomotive/menu_toggler.js +1 -1
- metadata +89 -74
- data/app/middlewares/locomotive/inline_editor_middleware.rb +0 -24
- data/lib/locomotive/liquid/tags/blueprint.rb +0 -21
- data/lib/locomotive/liquid/tags/editable/content.rb +0 -49
- data/lib/locomotive/liquid/tags/jquery.rb +0 -17
data/README.textile
CHANGED
@@ -24,8 +24,8 @@ h2. Gems
|
|
24
24
|
|
25
25
|
Here is a short list of main gems / technologies used in the application.
|
26
26
|
|
27
|
-
* Rails 3.2
|
28
|
-
* Mongoid 2.4.
|
27
|
+
* Rails 3.2.3
|
28
|
+
* Mongoid 2.4.6 (with MongoDB 2.0)
|
29
29
|
* Liquid
|
30
30
|
* Devise
|
31
31
|
* Carrierwave
|
@@ -44,7 +44,7 @@ We work on the procedure to upgrade from a previous version of the engine (below
|
|
44
44
|
|
45
45
|
h2. Community
|
46
46
|
|
47
|
-
* Get help or discuss locomotive CMS at the "LocomotiveCMS Discussion Forums":http://locomotive.vanillaforums.com/
|
47
|
+
* Get help or discuss locomotive CMS at the "LocomotiveCMS Google group":https://groups.google.com/forum/?fromgroups#!forum/locomotivecms or the "LocomotiveCMS Discussion Forums":http://locomotive.vanillaforums.com/ (deprecated)
|
48
48
|
* Join us on IRC "#locomotivecms at irc.freenode.net!":http://webchat.freenode.net/
|
49
49
|
* "Follow us on twitter":http://twitter.com/locomotiveapp
|
50
50
|
|
@@ -60,7 +60,7 @@ Locomotive CMS is an open source project, we encourage contributions. If you hav
|
|
60
60
|
* Make the tests pass
|
61
61
|
* "Create a GitHub pull request":http://help.github.com/send-pull-requests
|
62
62
|
|
63
|
-
For new features (especially large ones) it is best to create a topic on the "
|
63
|
+
For new features (especially large ones) it is best to create a topic on the "Google group":https://groups.google.com/forum/?fromgroups#!forum/locomotivecms first to make sure it fits into the goals of the project.
|
64
64
|
|
65
65
|
h2. Team
|
66
66
|
|
Binary file
|
@@ -16,7 +16,7 @@ class Locomotive.Models.Page extends Backbone.Model
|
|
16
16
|
|
17
17
|
toJSON: ->
|
18
18
|
_.tap super, (hash) =>
|
19
|
-
_.each ['content_type_id_text', 'edit_url', 'parent_id_text'], (key) => delete hash[key]
|
19
|
+
_.each ['content_type_id_text', 'edit_url', 'parent_id_text', 'response_type_text'], (key) => delete hash[key]
|
20
20
|
|
21
21
|
delete hash['editable_elements']
|
22
22
|
hash.editable_elements = @get('editable_elements').toJSONForSave() if @get('editable_elements')? && @get('editable_elements').length > 0
|
@@ -24,7 +24,7 @@ class Locomotive.Models.Site extends Backbone.Model
|
|
24
24
|
delete hash.memberships
|
25
25
|
hash.memberships_attributes = @get('memberships').toJSONForSave() if @get('memberships')? && @get('memberships').length > 0
|
26
26
|
delete hash.domains
|
27
|
-
hash.domains = _.map(@get('domains'), (domain) -> domain.get('name'))
|
27
|
+
hash.domains = _.map(@get('domains'), (domain) -> domain.get('name'))
|
28
28
|
|
29
29
|
class Locomotive.Models.CurrentSite extends Locomotive.Models.Site
|
30
30
|
|
@@ -48,6 +48,11 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
48
48
|
enable_richtexteditor: ->
|
49
49
|
_.each @$('li.input.rte textarea.html'), (textarea) =>
|
50
50
|
settings = _.extend {}, @tinyMCE_settings(),
|
51
|
+
oninit: ((editor) =>
|
52
|
+
$.cmd 'S', (() =>
|
53
|
+
$(textarea).val(editor.getBody().innerHTML).trigger('change')
|
54
|
+
@$('form').trigger('submit')
|
55
|
+
), [], ignoreCase: true, document: editor.dom.doc),
|
51
56
|
onchange_callback: (editor) =>
|
52
57
|
$(textarea).val(editor.getBody().innerHTML).trigger('change')
|
53
58
|
|
@@ -68,18 +73,20 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|
68
73
|
new_entry = new Locomotive.Models.ContentEntry(@options["#{name}_new_entry"])
|
69
74
|
view = new Locomotive.Views.Shared.Fields.HasManyView model: @model, name: name, new_entry: new_entry, inverse_of: inverse_of
|
70
75
|
|
71
|
-
|
76
|
+
if view.ui_enabled()
|
77
|
+
@_has_many_field_views.push(view)
|
72
78
|
|
73
|
-
|
79
|
+
@$("##{@model.paramRoot}_#{name}_input label").after(view.render().el)
|
74
80
|
|
75
81
|
enable_many_to_many_fields: ->
|
76
82
|
_.each @model.get('many_to_many_custom_fields'), (field) =>
|
77
83
|
name = field[0]
|
78
84
|
view = new Locomotive.Views.Shared.Fields.ManyToManyView model: @model, name: name, all_entries: @options["all_#{name}_entries"]
|
79
85
|
|
80
|
-
|
86
|
+
if view.ui_enabled()
|
87
|
+
@_many_to_many_field_views.push(view)
|
81
88
|
|
82
|
-
|
89
|
+
@$("##{@model.paramRoot}_#{name}_input label").after(view.render().el)
|
83
90
|
|
84
91
|
slugify_label_field: ->
|
85
92
|
@$('li.input.highlighted > input[type=text]').slugify(target: @$('#content_entry__slug'))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Locomotive.Views.EditableElements ||= {}
|
2
|
+
|
3
|
+
class Locomotive.Views.EditableElements.ControlView extends Backbone.View
|
4
|
+
|
5
|
+
tagName: 'li'
|
6
|
+
|
7
|
+
className: 'control input'
|
8
|
+
|
9
|
+
render: ->
|
10
|
+
$(@el).html(ich.editable_control_input(@model.toJSON()))
|
11
|
+
|
12
|
+
@bind_model()
|
13
|
+
|
14
|
+
return @
|
15
|
+
|
16
|
+
after_render: ->
|
17
|
+
# do nothing
|
18
|
+
|
19
|
+
refresh: ->
|
20
|
+
@bind_model()
|
21
|
+
|
22
|
+
bind_model: ->
|
23
|
+
Backbone.ModelBinding.bind @, { select: 'class' }
|
24
|
+
|
@@ -32,6 +32,9 @@ class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
|
|
32
32
|
view.model = @collection.get(view.model.get('id'))
|
33
33
|
view.refresh()
|
34
34
|
|
35
|
+
unbind_model: ->
|
36
|
+
_.each @_editable_elements_views, (view) => Backbone.ModelBinding.unbind(view)
|
37
|
+
|
35
38
|
render_elements: ->
|
36
39
|
index = 0
|
37
40
|
|
@@ -45,6 +48,7 @@ class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
|
|
45
48
|
when 'EditableShortText' then Locomotive.Views.EditableElements.ShortTextView
|
46
49
|
when 'EditableLongText' then Locomotive.Views.EditableElements.LongTextView
|
47
50
|
when 'EditableFile' then Locomotive.Views.EditableElements.FileView
|
51
|
+
when 'EditableControl' then Locomotive.Views.EditableElements.ControlView
|
48
52
|
|
49
53
|
view = new view_class(model: element)
|
50
54
|
@$("#block-#{block.index} > fieldset > ol").append(view.render().el)
|
@@ -13,6 +13,11 @@ class Locomotive.Views.EditableElements.ShortTextView extends Backbone.View
|
|
13
13
|
|
14
14
|
after_render: ->
|
15
15
|
settings = _.extend {}, @tinymce_settings(),
|
16
|
+
oninit: ((editor) =>
|
17
|
+
$.cmd 'S', (() =>
|
18
|
+
@model.set(content: editor.getBody().innerHTML)
|
19
|
+
$(@el).parents('form').trigger('submit')
|
20
|
+
), [], ignoreCase: true, document: editor.dom.doc),
|
16
21
|
onchange_callback: (editor) =>
|
17
22
|
@model.set(content: editor.getBody().innerHTML)
|
18
23
|
|
@@ -37,6 +37,9 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
|
37
37
|
# the url gets modified by different ways so reflect the changes in the UI
|
38
38
|
@listen_for_url_changes()
|
39
39
|
|
40
|
+
# enable response type
|
41
|
+
@enable_response_type_select()
|
42
|
+
|
40
43
|
# enable check boxes
|
41
44
|
@enable_templatized_checkbox()
|
42
45
|
|
@@ -90,6 +93,7 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
|
90
93
|
|
91
94
|
# Just re-connect the model and the views (+ redraw the file fields)
|
92
95
|
refresh_editable_elements: ->
|
96
|
+
@editable_elements_view.unbind_model()
|
93
97
|
@editable_elements_view.collection = @model.get('editable_elements')
|
94
98
|
@editable_elements_view.refresh()
|
95
99
|
|
@@ -108,6 +112,19 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
|
108
112
|
data: { parent_id: @$('#page_parent_id').val(), slug: @$('#page_slug').val() }
|
109
113
|
success: (data) =>
|
110
114
|
@$('#page_slug_input .inline-hints').html(data.url).effect('highlight')
|
115
|
+
if data.templatized_parent
|
116
|
+
@$('li#page_slug_input').show()
|
117
|
+
@$('li#page_templatized_input, li#page_target_klass_name_input').hide()
|
118
|
+
else
|
119
|
+
@$('li#page_templatized_input, li#page_target_klass_name_input').show()
|
120
|
+
|
121
|
+
enable_response_type_select: ->
|
122
|
+
@$('li#page_response_type_input').change (event) =>
|
123
|
+
if $(event.target).val() == 'text/html'
|
124
|
+
@$('li#page_redirect_input, li#page_redirect_url_input').show()
|
125
|
+
else
|
126
|
+
@model.set redirect: false
|
127
|
+
@$('li#page_redirect_input, li#page_redirect_url_input').hide()
|
111
128
|
|
112
129
|
enable_templatized_checkbox: ->
|
113
130
|
@_enable_checkbox 'templatized',
|
@@ -117,6 +134,8 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
|
117
134
|
off_callback: =>
|
118
135
|
@$('li#page_target_klass_name_input').hide()
|
119
136
|
|
137
|
+
@$('li#page_templatized_input').hide() if @model.get('templatized_from_parent') == true
|
138
|
+
|
120
139
|
enable_redirect_checkbox: ->
|
121
140
|
@_enable_checkbox 'redirect',
|
122
141
|
features: ['templatized', 'cache_strategy']
|
@@ -13,6 +13,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
|
13
13
|
# make inputs foldable (if specified)
|
14
14
|
@make_inputs_foldable()
|
15
15
|
|
16
|
+
# allow users to save with CTRL+S or CMD+s
|
17
|
+
@enable_save_with_keys_combination()
|
18
|
+
|
16
19
|
return @
|
17
20
|
|
18
21
|
save: (event) ->
|
@@ -68,6 +71,9 @@ class Locomotive.Views.Shared.FormView extends Backbone.View
|
|
68
71
|
else
|
69
72
|
content.slideUp 100, -> parent.addClass('folded')
|
70
73
|
|
74
|
+
enable_save_with_keys_combination: ->
|
75
|
+
$.cmd 'S', (() => @$('form').trigger('submit')), [], ignoreCase: true
|
76
|
+
|
71
77
|
after_inputs_fold: ->
|
72
78
|
# overide this method if necessary
|
73
79
|
|
@@ -80,6 +80,7 @@ ul.list {
|
|
80
80
|
|
81
81
|
span.untranslated {
|
82
82
|
@include label;
|
83
|
+
background-color: #F89406;
|
83
84
|
top: -1px;
|
84
85
|
left: 5px;
|
85
86
|
}
|
@@ -219,6 +220,13 @@ ul.list {
|
|
219
220
|
&.hidden a { font-style: italic; font-weight: normal; }
|
220
221
|
|
221
222
|
span.untranslated {
|
223
|
+
@include label;
|
224
|
+
background-color: #F89406;
|
225
|
+
top: 3px;
|
226
|
+
left: 5px;
|
227
|
+
}
|
228
|
+
|
229
|
+
span.response-type {
|
222
230
|
@include label;
|
223
231
|
top: 3px;
|
224
232
|
left: 5px;
|
@@ -53,9 +53,10 @@ module Locomotive
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def get_path
|
56
|
-
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink)
|
57
|
-
|
58
|
-
|
56
|
+
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink).tap do |p|
|
57
|
+
p.valid?; p.send(:build_fullpath)
|
58
|
+
end
|
59
|
+
render :json => { :url => public_page_url(page), :slug => page.slug, :templatized_parent => page.templatized_from_parent? }
|
59
60
|
end
|
60
61
|
|
61
62
|
end
|
@@ -50,5 +50,18 @@ module Locomotive
|
|
50
50
|
]
|
51
51
|
end
|
52
52
|
|
53
|
+
def options_for_page_response_type
|
54
|
+
[
|
55
|
+
['HTML', 'text/html'],
|
56
|
+
['RSS', 'application/rss+xml'],
|
57
|
+
['XML', 'text/xml'],
|
58
|
+
['JSON', 'application/json']
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
def page_response_type_to_string(page)
|
63
|
+
options_for_page_response_type.detect { |t| t.last == page.response_type }.try(:first) || '—'
|
64
|
+
end
|
65
|
+
|
53
66
|
end
|
54
67
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Locomotive
|
2
|
+
class EditableControl < EditableElement
|
3
|
+
|
4
|
+
## fields ##
|
5
|
+
field :content
|
6
|
+
field :options, :type => Array, :default => []
|
7
|
+
|
8
|
+
## methods ##
|
9
|
+
|
10
|
+
def options=(value)
|
11
|
+
if value.respond_to?(:split)
|
12
|
+
value = value.split(/\s*\,\s*/).map do |option|
|
13
|
+
first, last = *option.split(/\s*=\s*/)
|
14
|
+
last ||= first
|
15
|
+
{ 'value' => first, 'text' => last }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
super(value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def default_content?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_attributes_from(el)
|
27
|
+
super(el)
|
28
|
+
|
29
|
+
%w(content options).each do |meth|
|
30
|
+
self.attributes[meth] = el.attributes[meth]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def as_json(options = {})
|
35
|
+
Locomotive::EditableControlPresenter.new(self).as_json
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def propagate_content
|
41
|
+
if self.content_changed?
|
42
|
+
operations = {
|
43
|
+
'$set' => {
|
44
|
+
'editable_elements.$.content' => self.content,
|
45
|
+
'editable_elements.$.options' => self.options,
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
self.page.collection.update self._selector, operations, :multi => true
|
50
|
+
end
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -1,29 +1,101 @@
|
|
1
1
|
module Locomotive
|
2
2
|
class EditableElement
|
3
3
|
|
4
|
-
|
4
|
+
include ::Mongoid::Document
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
field :from_parent, :type => Boolean, :default => false
|
6
|
+
## fields ##
|
7
|
+
field :slug
|
8
|
+
field :block
|
9
|
+
field :hint
|
10
|
+
field :priority, :type => Integer, :default => 0
|
11
|
+
field :fixed, :type => Boolean, :default => false
|
12
|
+
field :disabled, :type => Boolean, :default => false, :localize => true
|
13
|
+
field :from_parent, :type => Boolean, :default => false
|
14
|
+
field :locales, :type => Array, :default => []
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
## associations ##
|
17
|
+
embedded_in :page, :class_name => 'Locomotive::Page', :inverse_of => :editable_elements
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
## validations ##
|
20
|
+
validates_presence_of :slug
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
## callbacks ##
|
23
|
+
after_save :propagate_content, :if => :fixed?
|
25
24
|
|
26
|
-
|
25
|
+
## scopes ##
|
26
|
+
scope :by_priority, :order_by => [[:priority, :desc]]
|
27
|
+
|
28
|
+
## methods ##
|
29
|
+
|
30
|
+
def disabled?
|
31
|
+
!!self.disabled # the original method does not work quite well with the localization
|
32
|
+
end
|
33
|
+
|
34
|
+
# Determines if the current element can be edited in the back-office
|
35
|
+
#
|
36
|
+
def editable?
|
37
|
+
!self.disabled? && self.locales.include?(::Mongoid::Fields::I18n.locale.to_s) && (!self.fixed? || !self.from_parent?)
|
38
|
+
end
|
39
|
+
|
40
|
+
def _run_rearrange_callbacks
|
41
|
+
# callback from page/tree. not needed in the editable elements
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_content?
|
45
|
+
# needs to be overridden for each kind of elements
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
# Copy attributes extracted from the corresponding Liquid tag
|
50
|
+
# Each editable element overrides this method.
|
51
|
+
#
|
52
|
+
# @param [ Hash ] attributes The up-to-date attributes
|
53
|
+
#
|
54
|
+
def copy_attributes(attributes)
|
55
|
+
self.attributes = attributes
|
56
|
+
end
|
57
|
+
|
58
|
+
# Copy attributes from an existing editable element coming
|
59
|
+
# from the parent page. Each editable element may or not
|
60
|
+
# override this method. The source element is a new record.
|
61
|
+
#
|
62
|
+
# @param [ EditableElement] el The source element
|
63
|
+
#
|
64
|
+
def copy_attributes_from(el)
|
65
|
+
self.attributes = el.attributes.reject { |attr| !%w(slug block hint priority fixed disabled locales from_parent).include?(attr) }
|
66
|
+
self.from_parent = true
|
67
|
+
end
|
68
|
+
|
69
|
+
# Make sure the current locale is added to the list
|
70
|
+
# of locales for the current element so that we know
|
71
|
+
# in which languages the element was translated.
|
72
|
+
#
|
73
|
+
def add_current_locale
|
74
|
+
locale = ::Mongoid::Fields::I18n.locale.to_s
|
75
|
+
self.locales << locale unless self.locales.include?(locale)
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def _selector
|
81
|
+
locale = ::Mongoid::Fields::I18n.locale
|
82
|
+
{
|
83
|
+
'site_id' => self.page.site_id,
|
84
|
+
"template_dependencies.#{locale}" => { '$in' => [self.page._id] },
|
85
|
+
'editable_elements.fixed' => true,
|
86
|
+
'editable_elements.block' => self.block,
|
87
|
+
'editable_elements.slug' => self.slug
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
# Update the value (or content) of the elements matching the same block/slug
|
92
|
+
# as the current element in all the pages inheriting from the current page.
|
93
|
+
# This method is called only if the element has the "fixed" property set to true.
|
94
|
+
# It also needs to be overridden for each kind of elements (file, short text, ...etc)
|
95
|
+
#
|
96
|
+
def propagate_content
|
97
|
+
true
|
98
|
+
end
|
27
99
|
|
28
100
|
end
|
29
101
|
end
|