locomotive_cms 2.1.4 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -5
- data/app/assets/images/locomotive/icons/flags/zh-CN.png +0 -0
- data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/css/inputcontrol.css +3 -0
- data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/lib/inputcontrol-plugin.js +94 -0
- data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/package.json +1 -0
- data/app/assets/javascripts/locomotive.js +2 -1
- data/app/assets/javascripts/locomotive/models/content_type.js.coffee +6 -2
- 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/utils/aloha_settings.js.coffee +17 -7
- data/app/assets/javascripts/locomotive/utils/tinymce_settings.js.coffee +6 -0
- data/app/assets/javascripts/locomotive/views/application_view.js.coffee +13 -2
- data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +19 -2
- data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_entries/index_view.js.coffee +2 -2
- data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/content_types/custom_field_entry_view.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_all_view.js.coffee +3 -6
- data/app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee +47 -0
- data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +2 -2
- data/app/assets/javascripts/locomotive/views/shared/fields/belongs_to_view.js.coffee +32 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee +2 -2
- data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +2 -2
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +2 -0
- data/app/assets/javascripts/locomotive/views/snippets/_form_view.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/theme_assets/_form_view.js.coffee +2 -1
- data/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee +0 -1
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/es.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/et.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/it.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/ja.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nb.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nl.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/no.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pl.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pt.js +1 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/zh-cn.js +1 -0
- data/app/assets/stylesheets/locomotive.css +1 -0
- data/app/assets/stylesheets/locomotive/backoffice/codemirror_changes.css.scss +2 -0
- data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +17 -3
- data/app/controllers/locomotive/content_entries_controller.rb +6 -2
- data/app/controllers/locomotive/public/content_entries_controller.rb +6 -0
- data/app/helpers/locomotive/base_helper.rb +8 -0
- data/app/helpers/locomotive/sites_helper.rb +6 -0
- data/app/models/locomotive/content_entry.rb +35 -5
- data/app/models/locomotive/content_type.rb +26 -8
- data/app/models/locomotive/editable_element.rb +15 -1
- data/app/models/locomotive/editable_file.rb +0 -2
- data/app/models/locomotive/editable_long_text.rb +3 -3
- data/app/models/locomotive/editable_short_text.rb +3 -64
- data/app/models/locomotive/editable_text.rb +84 -0
- data/app/models/locomotive/extensions/content_entry/csv.rb +7 -3
- data/app/models/locomotive/extensions/page/editable_elements.rb +3 -5
- data/app/models/locomotive/extensions/site/locales.rb +20 -0
- data/app/models/locomotive/extensions/site/timezone.rb +35 -0
- data/app/models/locomotive/site.rb +20 -16
- data/app/models/locomotive/theme_asset.rb +1 -1
- data/app/presenters/locomotive/content_entry_presenter.rb +1 -1
- data/app/presenters/locomotive/{editable_short_text_presenter.rb → editable_text_presenter.rb} +14 -2
- data/app/views/locomotive/current_site/_form.html.haml +1 -0
- data/app/views/locomotive/custom_fields/types/_belongs_to.html.haml +6 -5
- data/app/views/locomotive/pages/_editable_elements.html.haml +1 -1
- data/app/views/locomotive/shared/_head.html.haml +2 -0
- data/app/views/locomotive/shared/_main_app_head_before_backbone.html.haml +1 -0
- data/config/locales/admin_ui.de.yml +1 -0
- data/config/locales/admin_ui.en.yml +1 -0
- data/config/locales/admin_ui.et.yml +1 -0
- data/config/locales/admin_ui.fr.yml +1 -0
- data/config/locales/admin_ui.ja.yml +1 -0
- data/config/locales/admin_ui.nb.yml +2 -0
- data/config/locales/admin_ui.pl.yml +1 -0
- data/config/locales/admin_ui.pt-BR.yml +2 -1
- data/config/locales/admin_ui.ru.yml +24 -4
- data/config/locales/admin_ui.zh-CN.yml +347 -0
- data/config/locales/carrierwave.zh-CN.yml +4 -0
- data/config/locales/default.zh-CN.yml +116 -0
- data/config/locales/devise.nb.yml +1 -0
- data/config/locales/devise.zh-CN.yml +64 -0
- data/config/locales/flash.zh-CN.yml +115 -0
- data/config/locales/formtastic.en.yml +1 -0
- data/config/locales/formtastic.ru.yml +4 -1
- data/config/locales/formtastic.zh-CN.yml +112 -0
- data/features/backoffice/content_types/localized.feature +63 -0
- data/features/backoffice/pages.feature +3 -1
- data/features/backoffice/site.feature +7 -0
- data/features/public/contact_form.feature +11 -0
- data/features/public/content_entries.feature +13 -0
- data/features/public/pages.feature +24 -0
- data/features/step_definitions/page_steps.rb +6 -0
- data/features/step_definitions/web_steps.rb +24 -7
- data/lib/generators/locomotive/install/templates/locomotive.rb +2 -2
- data/lib/generators/locomotive/install/templates/mongoid.yml +23 -29
- data/lib/locomotive.rb +1 -4
- data/lib/locomotive/configuration.rb +3 -3
- data/lib/locomotive/dependencies.rb +1 -0
- data/lib/locomotive/engine.rb +2 -1
- data/lib/locomotive/liquid/drops/page.rb +1 -1
- data/lib/locomotive/liquid/filters/date.rb +3 -1
- data/lib/locomotive/liquid/filters/misc.rb +4 -0
- data/lib/locomotive/liquid/filters/text.rb +4 -0
- data/lib/locomotive/liquid/tags/editable.rb +1 -2
- data/lib/locomotive/liquid/tags/editable/text.rb +79 -0
- data/lib/locomotive/liquid/tags/inline_editor.rb +1 -1
- data/lib/locomotive/liquid/tags/link_to.rb +72 -13
- data/lib/locomotive/liquid/tags/with_scope.rb +3 -3
- data/lib/locomotive/middlewares.rb +0 -1
- data/lib/locomotive/mongoid/patches.rb +0 -16
- data/lib/locomotive/render.rb +1 -1
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/locomotive.rake +15 -9
- data/mongodb/migrate/20130326201349_rename_entry_to_content_entry.rb +1 -1
- data/mongodb/migrate/20130621135025_create_editable_texts.rb +42 -0
- data/mongodb/migrate/20130627101548_localize_slugs_of_content_entries.rb +43 -0
- data/spec/dummy/config/initializers/locomotive.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/lib/locomotive/liquid/drops/page_spec.rb +1 -1
- data/spec/lib/locomotive/liquid/filters/misc_spec.rb +26 -0
- data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +85 -0
- data/spec/lib/locomotive/liquid/tags/link_to_spec.rb +111 -0
- data/spec/lib/locomotive/liquid/tags/with_scope_spec.rb +6 -0
- data/spec/models/locomotive/content_entry_spec.rb +27 -7
- data/spec/models/locomotive/{editable_short_text_spec.rb → editable_text_spec.rb} +53 -8
- data/spec/models/locomotive/extensions/page/editable_elements_spec.rb +6 -6
- data/spec/models/locomotive/site_spec.rb +52 -32
- data/vendor/assets/images/select2-spinner.gif +0 -0
- data/vendor/assets/images/select2.png +0 -0
- data/vendor/assets/images/select2x2.png +0 -0
- data/vendor/assets/javascripts/locomotive/liquid_mode.js +1 -1
- data/vendor/assets/javascripts/select2/select2.js +3054 -0
- data/vendor/assets/stylesheets/select2/select2.css.scss +652 -0
- metadata +77 -33
- data/app/assets/javascripts/locomotive/views/editable_elements/long_text_view.js.coffee +0 -36
- data/app/assets/javascripts/locomotive/views/editable_elements/short_text_view.js.coffee +0 -22
- data/app/presenters/locomotive/editable_long_text_presenter.rb +0 -5
- data/lib/locomotive/liquid/tags/editable/long_text.rb +0 -33
- data/lib/locomotive/liquid/tags/editable/short_text.rb +0 -41
- data/lib/locomotive/middlewares/fonts.rb +0 -42
- data/lib/locomotive/session_store.rb +0 -64
- data/spec/lib/locomotive/liquid/tags/editable/short_text_spec.rb +0 -46
- data/spec/models/locomotive/editable_long_text_spec.rb +0 -50
@@ -2,7 +2,6 @@ module Locomotive
|
|
2
2
|
class EditableFile < EditableElement
|
3
3
|
|
4
4
|
## behaviours ##
|
5
|
-
# mount_uploader :source, EditableFileUploader
|
6
5
|
mount_uploader 'source', EditableFileUploader
|
7
6
|
|
8
7
|
replace_field 'source', ::String, true
|
@@ -11,7 +10,6 @@ module Locomotive
|
|
11
10
|
field :default_source_url, localize: true
|
12
11
|
|
13
12
|
## callbacks ##
|
14
|
-
# before_save { |c| puts "#{c.block}/#{c.slug} saved called !"}
|
15
13
|
after_save :propagate_content
|
16
14
|
|
17
15
|
## methods ##
|
@@ -1,66 +1,5 @@
|
|
1
1
|
module Locomotive
|
2
|
-
class EditableShortText <
|
3
|
-
|
4
|
-
## fields ##
|
5
|
-
field :content, localize: true
|
6
|
-
field :default_content, type: Boolean, localize: true, default: true
|
7
|
-
|
8
|
-
## methods ##
|
9
|
-
|
10
|
-
def content=(value)
|
11
|
-
return if value == self.content
|
12
|
-
self.add_current_locale
|
13
|
-
self.default_content = false unless self.new_record?
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
def default_content?
|
18
|
-
!!self.default_content
|
19
|
-
end
|
20
|
-
|
21
|
-
def content_from_default=(content)
|
22
|
-
if self.default_content?
|
23
|
-
self.content_will_change!
|
24
|
-
self.attributes['content'] ||= {}
|
25
|
-
self.attributes['content'][::Mongoid::Fields::I18n.locale.to_s] = content
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def copy_attributes_from(el)
|
30
|
-
super(el)
|
31
|
-
|
32
|
-
self.attributes['content'] = el.content_translations || {}
|
33
|
-
self.attributes['default_content'] = el.default_content_translations
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_default_content_from(el)
|
37
|
-
super(el)
|
38
|
-
|
39
|
-
locale = ::Mongoid::Fields::I18n.locale.to_s
|
40
|
-
|
41
|
-
if self.default_content? || self.attributes['default_content'][locale].nil?
|
42
|
-
self.default_content = true
|
43
|
-
|
44
|
-
self.content_will_change!
|
45
|
-
self.attributes['content'][locale] = el.content
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
protected
|
50
|
-
|
51
|
-
def propagate_content
|
52
|
-
if self.content_changed?
|
53
|
-
operations = {
|
54
|
-
'$set' => {
|
55
|
-
"editable_elements.$.content.#{::Mongoid::Fields::I18n.locale}" => self.content,
|
56
|
-
"editable_elements.$.default_content.#{::Mongoid::Fields::I18n.locale}" => false,
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
self.page.collection.find(self._selector).update(operations, multi: true)
|
61
|
-
end
|
62
|
-
true
|
63
|
-
end
|
64
|
-
|
2
|
+
class EditableShortText < EditableText
|
3
|
+
# @deprecated
|
65
4
|
end
|
66
|
-
end
|
5
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Locomotive
|
2
|
+
class EditableText < EditableElement
|
3
|
+
|
4
|
+
## fields ##
|
5
|
+
field :content, localize: true
|
6
|
+
field :default_content, type: Boolean, localize: true, default: true
|
7
|
+
field :format, default: 'html'
|
8
|
+
field :rows, type: Integer, default: 15
|
9
|
+
field :line_break, type: Boolean, default: true
|
10
|
+
|
11
|
+
## callbacks ##
|
12
|
+
before_save :strip_content
|
13
|
+
|
14
|
+
## methods ##
|
15
|
+
|
16
|
+
def content=(value)
|
17
|
+
return if value == self.content
|
18
|
+
self.add_current_locale
|
19
|
+
self.default_content = false unless self.new_record?
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_content?
|
24
|
+
!!self.default_content
|
25
|
+
end
|
26
|
+
|
27
|
+
def content_from_default=(content)
|
28
|
+
if self.default_content?
|
29
|
+
self.content_will_change!
|
30
|
+
self.attributes['content'] ||= {}
|
31
|
+
self.attributes['content'][::Mongoid::Fields::I18n.locale.to_s] = content
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_attributes_from(el)
|
36
|
+
super(el)
|
37
|
+
|
38
|
+
self.attributes['content'] = el.content_translations || {}
|
39
|
+
self.attributes['default_content'] = el.default_content_translations
|
40
|
+
end
|
41
|
+
|
42
|
+
def copy_default_attributes_from(el)
|
43
|
+
super(el)
|
44
|
+
|
45
|
+
%w(format rows line_break).each do |attr|
|
46
|
+
self.send(:"#{attr}=", el.send(attr.to_sym))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_default_content_from(el)
|
51
|
+
super(el)
|
52
|
+
|
53
|
+
locale = ::Mongoid::Fields::I18n.locale.to_s
|
54
|
+
|
55
|
+
if self.default_content? || self.attributes['default_content'][locale].nil?
|
56
|
+
self.default_content = true
|
57
|
+
|
58
|
+
self.content_will_change!
|
59
|
+
self.attributes['content'][locale] = el.content
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def propagate_content
|
66
|
+
if self.content_changed?
|
67
|
+
operations = {
|
68
|
+
'$set' => {
|
69
|
+
"editable_elements.$.content.#{::Mongoid::Fields::I18n.locale}" => self.content,
|
70
|
+
"editable_elements.$.default_content.#{::Mongoid::Fields::I18n.locale}" => false,
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
self.page.collection.find(self._selector).update(operations, multi: true)
|
75
|
+
end
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
def strip_content
|
80
|
+
self.content.strip! unless self.content.blank?
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -7,16 +7,19 @@ module Locomotive
|
|
7
7
|
|
8
8
|
# Get the values from the custom fields as an array.
|
9
9
|
# Values are ordered by the position of the custom fields.
|
10
|
+
# It also adds the created_at value of the instance.
|
10
11
|
#
|
11
12
|
# @param [ Hash ] options For now, stores only the host for the File fields.
|
12
13
|
#
|
13
14
|
# @return [ Array ]
|
14
15
|
#
|
15
16
|
def to_values(options = {})
|
16
|
-
self.content_type.ordered_entries_custom_fields.map do |field|
|
17
|
+
values = self.content_type.ordered_entries_custom_fields.map do |field|
|
17
18
|
value = self.send(field.name)
|
18
19
|
self.value_from_type(field.type.to_sym, value, options)
|
19
20
|
end.compact
|
21
|
+
|
22
|
+
values << I18n.l(self.created_at, format: :long)
|
20
23
|
end
|
21
24
|
|
22
25
|
protected
|
@@ -59,13 +62,14 @@ module Locomotive
|
|
59
62
|
end
|
60
63
|
|
61
64
|
fields = content_type.ordered_entries_custom_fields
|
65
|
+
labels = fields.map(&:label) << I18n.t('mongoid.attributes.locomotive/content_entry.created_at')
|
62
66
|
|
63
67
|
CSV.generate(csv_options) do |csv|
|
64
68
|
# header
|
65
|
-
csv <<
|
69
|
+
csv << labels
|
66
70
|
# body
|
67
71
|
all.each do |entry|
|
68
|
-
csv <<
|
72
|
+
csv << entry.to_values(options)
|
69
73
|
end
|
70
74
|
end
|
71
75
|
end
|
@@ -79,16 +79,14 @@ module Locomotive
|
|
79
79
|
if existing_el.nil? # new one from parents
|
80
80
|
new_el = self.editable_elements.build({}, el.class)
|
81
81
|
new_el.copy_attributes_from(el)
|
82
|
-
|
82
|
+
elsif existing_el.from_parent? # it inherits from a parent page
|
83
83
|
existing_el.disabled = false
|
84
84
|
|
85
85
|
# make sure the default content gets updated too
|
86
86
|
existing_el.set_default_content_from(el)
|
87
87
|
|
88
|
-
#
|
89
|
-
|
90
|
-
existing_el.send(:"#{attr}=", el.send(attr.to_sym))
|
91
|
-
end
|
88
|
+
# copy _type, hint, fixed, priority and locales + type custom attributes
|
89
|
+
existing_el.copy_default_attributes_from(el)
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -74,6 +74,26 @@ module Locomotive
|
|
74
74
|
[locale.to_s] + (locales - [locale.to_s])
|
75
75
|
end
|
76
76
|
|
77
|
+
# Iterate through all the locales of the site and for each of them
|
78
|
+
# call yield with the related Mongoid::Fields::I18n locale context.
|
79
|
+
# The first locale is the default one.
|
80
|
+
#
|
81
|
+
def each_locale(&block)
|
82
|
+
self.locales.each do |locale|
|
83
|
+
::Mongoid::Fields::I18n.with_locale(locale) do
|
84
|
+
yield locale
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Call yield within the Mongoid::Fields::I18 context of the default locale.
|
90
|
+
#
|
91
|
+
def with_default_locale(&block)
|
92
|
+
::Mongoid::Fields::I18n.with_locale(self.default_locale) do
|
93
|
+
yield
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
77
97
|
protected
|
78
98
|
|
79
99
|
def add_default_locale
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Extensions
|
3
|
+
module Site
|
4
|
+
module Timezone
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
|
10
|
+
## fields ##
|
11
|
+
field :timezone_name, type: ::String, default: "UTC"
|
12
|
+
|
13
|
+
# ## validations ##
|
14
|
+
validate :wrong_timezone_name
|
15
|
+
#
|
16
|
+
# ## callbacks ##
|
17
|
+
# after_validation :add_default_locale
|
18
|
+
# before_update :verify_localized_default_pages_integrity
|
19
|
+
end
|
20
|
+
|
21
|
+
def timezone
|
22
|
+
@timezone ||= ActiveSupport::TimeZone.new(self.timezone_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
def wrong_timezone_name
|
27
|
+
unless ActiveSupport::TimeZone.new(self.timezone_name)
|
28
|
+
self.errors.add :timezone, I18n.t(:wrong_timezone_name, scope: [:errors, :messages, :site])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -8,18 +8,20 @@ module Locomotive
|
|
8
8
|
extend Extensions::Site::FirstInstallation
|
9
9
|
include Extensions::Shared::Seo
|
10
10
|
include Extensions::Site::Locales
|
11
|
+
include Extensions::Site::Timezone
|
11
12
|
|
12
13
|
## fields ##
|
13
14
|
field :name
|
14
15
|
field :robots_txt
|
15
16
|
|
16
17
|
## associations ##
|
17
|
-
has_many :pages, class_name: 'Locomotive::Page',
|
18
|
-
has_many :snippets, class_name: 'Locomotive::Snippet',
|
19
|
-
has_many :theme_assets, class_name: 'Locomotive::ThemeAsset',
|
20
|
-
has_many :content_assets, class_name: 'Locomotive::ContentAsset',
|
21
|
-
has_many :content_types, class_name: 'Locomotive::ContentType',
|
22
|
-
has_many :
|
18
|
+
has_many :pages, class_name: 'Locomotive::Page', validate: false, autosave: false
|
19
|
+
has_many :snippets, class_name: 'Locomotive::Snippet', dependent: :destroy, validate: false, autosave: false
|
20
|
+
has_many :theme_assets, class_name: 'Locomotive::ThemeAsset', dependent: :destroy, validate: false, autosave: false
|
21
|
+
has_many :content_assets, class_name: 'Locomotive::ContentAsset', dependent: :destroy, validate: false, autosave: false
|
22
|
+
has_many :content_types, class_name: 'Locomotive::ContentType', dependent: :destroy, validate: false, autosave: false
|
23
|
+
has_many :content_entries, class_name: 'Locomotive::ContentEntry', dependent: :destroy, validate: false, autosave: false
|
24
|
+
has_many :translations, class_name: 'Locomotive::Translation', dependent: :destroy, validate: false, autosave: false
|
23
25
|
embeds_many :memberships, class_name: 'Locomotive::Membership'
|
24
26
|
|
25
27
|
## validations ##
|
@@ -63,17 +65,19 @@ module Locomotive
|
|
63
65
|
# method is available
|
64
66
|
def create_default_pages!
|
65
67
|
%w{index 404}.each do |slug|
|
66
|
-
page =
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}
|
74
|
-
|
68
|
+
page = nil
|
69
|
+
|
70
|
+
self.each_locale do |locale|
|
71
|
+
page ||= self.pages.build(published: true) # first locale = default one
|
72
|
+
|
73
|
+
page.attributes = {
|
74
|
+
slug: slug,
|
75
|
+
title: ::I18n.t("attributes.defaults.pages.#{slug}.title", locale: locale),
|
76
|
+
raw_template: ::I18n.t("attributes.defaults.pages.#{slug}.body", locale: locale)
|
77
|
+
}
|
75
78
|
end
|
76
|
-
|
79
|
+
|
80
|
+
self.with_default_locale { page.save! }
|
77
81
|
end
|
78
82
|
|
79
83
|
end
|
@@ -144,7 +144,7 @@ module Locomotive
|
|
144
144
|
def escape_shortcut_urls(text)
|
145
145
|
return if text.blank?
|
146
146
|
|
147
|
-
text.gsub(/[("'](\/(stylesheets|javascripts|images|media|others)\/(([^;.]+)\/)*([a-zA-Z_\-0-9]+)\.[a-z]{2,3})(\?[0-9]+)?[)"']/) do |path|
|
147
|
+
text.gsub(/[("'](\/(stylesheets|javascripts|images|media|fonts|others)\/(([^;.]+)\/)*([a-zA-Z_\-0-9]+)\.[a-z]{2,3})(\?[0-9]+)?[)"']/) do |path|
|
148
148
|
|
149
149
|
sanitized_path = path.gsub(/[("')]/, '').gsub(/^\//, '').gsub(/\?[0-9]+$/, '')
|
150
150
|
|
@@ -19,7 +19,7 @@ module Locomotive
|
|
19
19
|
|
20
20
|
with_options only_getter: true, if: Proc.new { html_view? } do |presenter|
|
21
21
|
presenter.properties :safe_attributes
|
22
|
-
presenter.properties :select_custom_fields, :file_custom_fields, :has_many_custom_fields, :many_to_many_custom_fields
|
22
|
+
presenter.properties :select_custom_fields, :file_custom_fields, :belongs_to_custom_fields, :has_many_custom_fields, :many_to_many_custom_fields
|
23
23
|
end
|
24
24
|
|
25
25
|
## callbacks ##
|
data/app/presenters/locomotive/{editable_short_text_presenter.rb → editable_text_presenter.rb}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Locomotive
|
2
|
-
class
|
2
|
+
class EditableTextPresenter < EditableElementPresenter
|
3
3
|
|
4
4
|
## properties ##
|
5
|
-
|
6
5
|
properties :content, :default_content
|
6
|
+
properties :format, :line_break, :rows, only_getter: true
|
7
7
|
|
8
8
|
## callbacks ##
|
9
9
|
|
@@ -26,3 +26,15 @@ module Locomotive
|
|
26
26
|
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
module Locomotive
|
31
|
+
class EditableShortTextPresenter < EditableTextPresenter
|
32
|
+
# @deprecated
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Locomotive
|
37
|
+
class EditableLongTextPresenter < EditableTextPresenter
|
38
|
+
# @deprecated
|
39
|
+
end
|
40
|
+
end
|
@@ -10,6 +10,7 @@
|
|
10
10
|
= f.inputs name: :information do
|
11
11
|
= f.input :name, wrapper_html: { style: 'display: none' }
|
12
12
|
= f.input :locales, as: '::Locomotive::Locales', collection: ordered_current_site_locales, input_html: { class: 'locales' }
|
13
|
+
= f.input :timezone_name, as: :select, include_blank: false, collection: options_for_site_timezones
|
13
14
|
|
14
15
|
- if can?(:point, Locomotive::Site)
|
15
16
|
- if manage_subdomain_or_domains?
|
@@ -1,5 +1,6 @@
|
|
1
|
-
= f.input
|
2
|
-
label:
|
3
|
-
hint:
|
4
|
-
as:
|
5
|
-
|
1
|
+
= f.input :"#{name}_id",
|
2
|
+
label: field.label,
|
3
|
+
hint: field.hint,
|
4
|
+
as: :string,
|
5
|
+
wrapper_html: { class: 'select2' },
|
6
|
+
input_html: { data: { value: f.object.send(field.name.to_sym).try(:_label), url: content_entries_url(field.class_name_to_content_type.slug, :json), per_page: Locomotive.config.ui[:per_page] } }
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
%label{ for: 'page_editable_elements_attributes_{{index}}_content' } {{label}}
|
20
20
|
|
21
|
-
= text_area_tag 'page[editable_elements_attributes][{{index}}][content]', '{{content}}', id: 'page_editable_elements_attributes_{{index}}_content'
|
21
|
+
= text_area_tag 'page[editable_elements_attributes][{{index}}][content]', '{{content}}', id: 'page_editable_elements_attributes_{{index}}_content', rows: '{{rows}}'
|
22
22
|
|
23
23
|
{{#if hint}}
|
24
24
|
%p.inline-hints {{hint}}
|