camaleon_cms 2.1.2.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/app/apps/plugins/attack/attack_helper.rb +3 -0
- data/app/apps/plugins/attack/config/custom_models.rb +4 -2
- data/app/apps/plugins/attack/config/locales/translation.yml +19 -0
- data/app/apps/plugins/attack/models/attack.rb +1 -1
- data/app/apps/plugins/front_cache/config/initializer.rb +4 -2
- data/app/apps/plugins/front_cache/config/locales/translation.yml +19 -0
- data/app/apps/themes/camaleon_first/main_helper.rb +1 -3
- data/app/apps/themes/default/views/admin/settings.html.erb +0 -1
- data/app/apps/themes/default/views/layouts/index.html.erb +5 -5
- data/app/apps/themes/new/assets/css/main.css +1 -1
- data/app/apps/themes/new/assets/js/main.js +1 -1
- data/app/apps/themes/new/views/admin/settings.html.erb +1 -1
- data/app/assets/images/camaleon_cms/language/{pt_br.png → pt-BR.png} +0 -0
- data/app/assets/javascripts/camaleon_cms/admin/_custom_fields.js +105 -51
- data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +4 -2
- data/app/assets/javascripts/camaleon_cms/admin/_translator.js +2 -2
- data/app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js +9 -7
- data/app/assets/javascripts/camaleon_cms/admin/jquery_validate/{pt_br.js → pt-BR.js} +0 -0
- data/app/assets/javascripts/camaleon_cms/admin/momentjs/{pt_br.js → pt-BR.js} +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/nav_menu.js.coffee +15 -1
- data/app/assets/javascripts/camaleon_cms/admin/tinymce/langs/{pt_br.js → pt-BR.js} +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +24 -12
- data/app/assets/stylesheets/camaleon_cms/admin/_custom_admin.css.scss +9 -0
- data/app/assets/stylesheets/camaleon_cms/admin/lte/_admin.css.scss +1 -1
- data/app/controllers/camaleon_cms/admin/appearances/nav_menus_controller.rb +13 -6
- data/app/controllers/camaleon_cms/admin/appearances/themes_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/comments_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/media_controller.rb +15 -5
- data/app/controllers/camaleon_cms/admin/plugins_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +14 -8
- data/app/controllers/camaleon_cms/admin/settings_controller.rb +22 -7
- data/app/controllers/camaleon_cms/admin/user_roles_controller.rb +1 -1
- data/app/controllers/camaleon_cms/admin/users_controller.rb +1 -1
- data/app/controllers/camaleon_cms/apps/plugins_admin_controller.rb +4 -1
- data/app/controllers/camaleon_cms/apps/plugins_front_controller.rb +5 -10
- data/app/controllers/camaleon_cms/apps/themes_front_controller.rb +1 -4
- data/app/controllers/camaleon_cms/camaleon_controller.rb +4 -13
- data/app/controllers/camaleon_cms/frontend_controller.rb +15 -9
- data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +17 -8
- data/app/decorators/camaleon_cms/application_decorator.rb +3 -3
- data/app/decorators/camaleon_cms/custom_fields_concern.rb +21 -6
- data/app/decorators/camaleon_cms/post_comment_decorator.rb +21 -0
- data/app/decorators/camaleon_cms/site_decorator.rb +5 -5
- data/app/decorators/camaleon_cms/theme_decorator.rb +10 -0
- data/app/decorators/camaleon_cms/user_decorator.rb +2 -2
- data/app/helpers/camaleon_cms/admin/custom_fields_helper.rb +24 -2
- data/app/helpers/camaleon_cms/admin/menus_helper.rb +13 -12
- data/app/helpers/camaleon_cms/frontend/application_helper.rb +1 -1
- data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +7 -6
- data/app/helpers/camaleon_cms/plugins_helper.rb +20 -18
- data/app/helpers/camaleon_cms/site_helper.rb +1 -20
- data/app/helpers/camaleon_cms/theme_helper.rb +1 -1
- data/app/helpers/camaleon_cms/uploader_helper.rb +25 -20
- data/app/helpers/camaleon_cms/user_roles_helper.rb +6 -1
- data/app/mailers/camaleon_cms/html_mailer.rb +2 -1
- data/app/models/camaleon_cms/ability.rb +3 -26
- data/app/models/camaleon_cms/custom_field.rb +2 -1
- data/app/models/camaleon_cms/custom_field_group.rb +23 -22
- data/app/models/camaleon_cms/custom_fields_relationship.rb +1 -1
- data/app/models/camaleon_cms/nav_menu.rb +1 -1
- data/app/models/camaleon_cms/nav_menu_item.rb +12 -19
- data/app/models/camaleon_cms/post.rb +1 -1
- data/app/models/camaleon_cms/post_comment.rb +3 -1
- data/app/models/camaleon_cms/post_default.rb +1 -1
- data/app/models/camaleon_cms/post_type.rb +5 -4
- data/app/models/camaleon_cms/site.rb +12 -0
- data/app/models/camaleon_cms/term_taxonomy.rb +1 -1
- data/app/models/camaleon_cms/user_role.rb +5 -1
- data/app/models/concerns/camaleon_cms/custom_fields_read.rb +99 -49
- data/app/uploaders/camaleon_cms_aws_uploader.rb +1 -1
- data/app/uploaders/camaleon_cms_local_uploader.rb +19 -3
- data/app/uploaders/camaleon_cms_uploader.rb +13 -6
- data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb +9 -2
- data/app/views/camaleon_cms/admin/appearances/nav_menus/_form.html.erb +1 -1
- data/app/views/camaleon_cms/admin/appearances/nav_menus/_menu_items.html.erb +2 -2
- data/app/views/camaleon_cms/admin/appearances/themes/index.html.erb +1 -3
- data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +1 -0
- data/app/views/camaleon_cms/admin/media/index.html.erb +3 -3
- data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +1 -1
- data/app/views/camaleon_cms/admin/posts/form.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +4 -0
- data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +6 -6
- data/app/views/camaleon_cms/admin/settings/custom_fields/_meta_data.html.erb +0 -9
- data/app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb +39 -55
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb +2 -2
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkboxes.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_colorpicker.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_date.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_editor.html.erb +2 -2
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_email.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_field_attrs.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_file.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_image.html.erb +2 -2
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_numeric.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_phone.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_posts.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_private_file.html.erb +4 -0
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_radio.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select.html.erb +3 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_select_eval.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_area.html.erb +2 -2
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_text_box.html.erb +2 -2
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_url.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_users.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/fields/_video.html.erb +1 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +8 -0
- data/app/views/camaleon_cms/admin/settings/site.html.erb +1 -20
- data/app/views/camaleon_cms/admin/settings/theme.html.erb +20 -0
- data/app/views/camaleon_cms/admin/user_roles/form.html.erb +2 -2
- data/app/views/camaleon_cms/default_theme/admin/settings.html.erb +0 -1
- data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +0 -2
- data/app/views/camaleon_cms/default_theme/partials/_search_form.html.erb +1 -1
- data/app/views/camaleon_cms/default_theme/partials/_sidebar.html.erb +3 -3
- data/app/views/layouts/camaleon_cms/admin/_footer.html.erb +1 -1
- data/config/initializers/action_view.rb +12 -7
- data/config/initializers/custom_initializers.rb +6 -12
- data/config/locales/camaleon_cms/admin/en.yml +1 -0
- data/config/locales/camaleon_cms/admin/es.yml +4 -0
- data/config/locales/camaleon_cms/admin/it.yml +1 -24
- data/config/locales/camaleon_cms/admin/js.yml +41 -0
- data/config/locales/camaleon_cms/admin/{pt_br.yml → pt-BR.yml} +48 -18
- data/config/locales/camaleon_cms/common.yml +66 -0
- data/config/locales/camaleon_cms/languages.yml +13 -0
- data/config/locales/camaleon_cms/routes.yml +2 -2
- data/config/routes/admin.rb +3 -0
- data/config/system.json +3 -3
- data/db/migrate/20160606135421_improve_menus_structure.rb +7 -0
- data/db/migrate/20160609121449_add_group_to_custom_field_values.rb +5 -0
- data/lib/camaleon_cms/engine.rb +4 -3
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/ext/string.rb +20 -0
- data/lib/ext/translator.rb +2 -2
- data/lib/generators/camaleon_cms/gem_plugin_generator.rb +1 -1
- data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +1 -1
- data/lib/generators/camaleon_cms/install_generator.rb +1 -0
- data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/main_helper.rb +1 -4
- data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/index.html.erb +1 -25
- data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/layouts/index.html.erb +17 -18
- data/lib/plugin_routes.rb +4 -4
- metadata +25 -48
- data/app/apps/plugins/contact_form/admin_forms_controller.rb +0 -85
- data/app/apps/plugins/contact_form/assets/css/admin/form-builder/formbuilder.css +0 -70
- data/app/apps/plugins/contact_form/assets/css/contact-form.css +0 -8
- data/app/apps/plugins/contact_form/assets/css/front/railsform.scss +0 -94
- data/app/apps/plugins/contact_form/assets/css/readme.txt +0 -1
- data/app/apps/plugins/contact_form/assets/js/contact_form.js +0 -2
- data/app/apps/plugins/contact_form/assets/js/form-builder/formbuilder.js +0 -1271
- data/app/apps/plugins/contact_form/assets/js/form-builder/vendor.js +0 -3072
- data/app/apps/plugins/contact_form/assets/js/readme.txt +0 -1
- data/app/apps/plugins/contact_form/config/config.json +0 -35
- data/app/apps/plugins/contact_form/config/custom_models.rb +0 -3
- data/app/apps/plugins/contact_form/config/locales/readme.txt +0 -1
- data/app/apps/plugins/contact_form/config/locales/translation.yml +0 -315
- data/app/apps/plugins/contact_form/config/routes_admin.txt +0 -4
- data/app/apps/plugins/contact_form/config/routes_front.txt +0 -2
- data/app/apps/plugins/contact_form/contact_form_helper.rb +0 -154
- data/app/apps/plugins/contact_form/contact_form_html_helper.rb +0 -140
- data/app/apps/plugins/contact_form/front_controller.rb +0 -50
- data/app/apps/plugins/contact_form/models/contact_form.rb +0 -26
- data/app/apps/plugins/contact_form/views/admin_forms/_form.html.erb +0 -33
- data/app/apps/plugins/contact_form/views/admin_forms/edit.html.erb +0 -338
- data/app/apps/plugins/contact_form/views/admin_forms/index.html.erb +0 -65
- data/app/apps/plugins/contact_form/views/admin_forms/responses.html.erb +0 -60
- data/app/apps/plugins/contact_form/views/contact_form/_email_content.html.erb +0 -26
- data/app/apps/plugins/contact_form/views/forms_shorcode.html.erb +0 -28
- data/app/apps/plugins/contact_form/views/front/index.html.erb +0 -3
- data/app/apps/themes/camaleon_first/views/admin/settings.html.erb +0 -4
- data/app/apps/themes/new/assets/css/bootstrap/bootstrap.min.css +0 -6735
- data/app/apps/themes/new/assets/js/plugins/bootstrap/bootstrap.min.js +0 -6
- data/app/apps/themes/new/assets/js/plugins/jquery/jquery.min.js +0 -4
- data/lib/generators/camaleon_cms/gem_theme_generator.rb +0 -97
- data/lib/generators/camaleon_cms/gem_theme_template/app/assets/images/themes/my_plugin/image.png +0 -0
- data/lib/generators/camaleon_cms/gem_theme_template/app/assets/javascripts/themes/my_plugin/main.js +0 -14
- data/lib/generators/camaleon_cms/gem_theme_template/app/assets/stylesheets/themes/my_plugin/main.css +0 -13
- data/lib/generators/camaleon_cms/gem_theme_template/app/helpers/themes/my_plugin/main_helper.rb +0 -26
- data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/admin/settings.html.erb +0 -4
- data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/index.html.erb +0 -25
- data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/layouts/index.html.erb +0 -70
- data/lib/generators/camaleon_cms/gem_theme_template/app/views/themes/my_plugin/partials/readme.txt +0 -1
- data/lib/generators/camaleon_cms/gem_theme_template/config/camaleon_theme.json +0 -14
|
@@ -35,6 +35,6 @@ module CamaleonCms::Frontend::ApplicationHelper
|
|
|
35
35
|
options[:locale] = nil if options[:locale].present? && current_site.get_languages.first.to_s == options[:locale].to_s
|
|
36
36
|
end
|
|
37
37
|
options.delete(:format) if PluginRoutes.system_info["skip_format_url"].present?
|
|
38
|
-
send(url_to, *(args << options))
|
|
38
|
+
send(url_to.gsub('-', '_'), *(args << options))
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -144,6 +144,7 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
144
144
|
end
|
|
145
145
|
r[:levels] = r[:levels] + 1
|
|
146
146
|
end
|
|
147
|
+
is_current_parent = true if r[:current_item]
|
|
147
148
|
levels << r[:levels]
|
|
148
149
|
res << r
|
|
149
150
|
end
|
|
@@ -183,24 +184,24 @@ module CamaleonCms::Frontend::NavMenuHelper
|
|
|
183
184
|
|
|
184
185
|
private
|
|
185
186
|
def _get_link_nav_menu(nav_menu_item)
|
|
186
|
-
type_menu = nav_menu_item.
|
|
187
|
+
type_menu = nav_menu_item.kind
|
|
187
188
|
begin
|
|
188
189
|
case type_menu
|
|
189
190
|
when 'post'
|
|
190
|
-
post = CamaleonCms::Post.find(nav_menu_item.
|
|
191
|
+
post = CamaleonCms::Post.find(nav_menu_item.url).decorate
|
|
191
192
|
return false unless post.can_visit?
|
|
192
193
|
r = {link: post.the_url(as_path: true), name: post.the_title, type_menu: type_menu, current: @cama_visited_post.present? && @cama_visited_post.id == post.id}
|
|
193
194
|
when 'category'
|
|
194
|
-
category = CamaleonCms::Category.find(nav_menu_item.
|
|
195
|
+
category = CamaleonCms::Category.find(nav_menu_item.url).decorate
|
|
195
196
|
r = {link: category.the_url(as_path: true), name: category.the_title, type_menu: type_menu, current: @cama_visited_category.present? && @cama_visited_category.id == category.id}
|
|
196
197
|
when 'post_tag'
|
|
197
|
-
post_tag = CamaleonCms::PostTag.find(nav_menu_item.
|
|
198
|
+
post_tag = CamaleonCms::PostTag.find(nav_menu_item.url).decorate
|
|
198
199
|
r = {link: post_tag.the_url(as_path: true), name: post_tag.the_title, type_menu: type_menu, current: @cama_visited_tag.present? && @cama_visited_tag.id == post_tag.id}
|
|
199
200
|
when 'post_type'
|
|
200
|
-
post_type = CamaleonCms::PostType.find(nav_menu_item.
|
|
201
|
+
post_type = CamaleonCms::PostType.find(nav_menu_item.url).decorate
|
|
201
202
|
r = {link: post_type.the_url(as_path: true), name: post_type.the_title, type_menu: type_menu, current: @cama_visited_post_type.present? && @cama_visited_post_type.id == post_type.id}
|
|
202
203
|
when 'external'
|
|
203
|
-
r = {link: nav_menu_item.
|
|
204
|
+
r = {link: nav_menu_item.url.to_s.translate, name: nav_menu_item.name.to_s.translate, type_menu: type_menu, current: false}
|
|
204
205
|
r[:link] = cama_root_path if r[:link] == "root_url"
|
|
205
206
|
r[:link] = site_current_path if site_current_path == "#{current_site.the_path}#{r[:link]}"
|
|
206
207
|
r[:current] = r[:link] == site_current_url || r[:link] == site_current_path
|
|
@@ -69,11 +69,11 @@ module CamaleonCms::PluginsHelper
|
|
|
69
69
|
# return plugin full layout path
|
|
70
70
|
# plugin_key: plugin name
|
|
71
71
|
def plugin_layout(layout_name, plugin_key = nil)
|
|
72
|
-
|
|
73
|
-
if
|
|
74
|
-
"plugins/#{
|
|
72
|
+
key = plugin_key || self_plugin_key(1)
|
|
73
|
+
if PluginRoutes.plugin_info(key)["gem_mode"]
|
|
74
|
+
"plugins/#{key}/layouts/#{layout_name}"
|
|
75
75
|
else
|
|
76
|
-
"plugins/#{
|
|
76
|
+
"plugins/#{key}/views/layouts/#{layout_name}"
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
@@ -85,12 +85,11 @@ module CamaleonCms::PluginsHelper
|
|
|
85
85
|
view_name = plugin_key
|
|
86
86
|
plugin_key = k
|
|
87
87
|
end
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"plugins/#{plugin.slug}/#{view_name}"
|
|
88
|
+
key = plugin_key || self_plugin_key(1)
|
|
89
|
+
if PluginRoutes.plugin_info(key)["gem_mode"]
|
|
90
|
+
"plugins/#{key}/#{view_name}"
|
|
92
91
|
else
|
|
93
|
-
"plugins/#{
|
|
92
|
+
"plugins/#{key}/views/#{view_name}"
|
|
94
93
|
end
|
|
95
94
|
end
|
|
96
95
|
|
|
@@ -103,12 +102,11 @@ module CamaleonCms::PluginsHelper
|
|
|
103
102
|
if plugin_key.present? && plugin_key.include?("/")
|
|
104
103
|
return plugin_asset_url(plugin_key, asset || self_plugin_key(1))
|
|
105
104
|
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"plugins/#{folder_name}/#{asset}"
|
|
105
|
+
key = plugin_key || self_plugin_key(1)
|
|
106
|
+
if PluginRoutes.plugin_info(key)["gem_mode"]
|
|
107
|
+
"plugins/#{key}/#{asset}"
|
|
110
108
|
else
|
|
111
|
-
"plugins/#{
|
|
109
|
+
"plugins/#{key}/assets/#{asset}"
|
|
112
110
|
end
|
|
113
111
|
end
|
|
114
112
|
alias_method :plugin_asset, :plugin_asset_path
|
|
@@ -120,9 +118,8 @@ module CamaleonCms::PluginsHelper
|
|
|
120
118
|
# sample:
|
|
121
119
|
# plugin_asset_url("css/main.css") => return: http://myhost.com/assets/plugins/my_plugin/assets/css/main-54505620f.css
|
|
122
120
|
def plugin_asset_url(asset, plugin_key = nil)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
p = settings["gem_mode"] ? "plugins/#{folder_name}/#{asset}" : "plugins/#{folder_name}/assets/#{asset}"
|
|
121
|
+
key = plugin_key || self_plugin_key(1)
|
|
122
|
+
p = PluginRoutes.plugin_info(key)["gem_mode"] ? "plugins/#{key}/#{asset}" : "plugins/#{key}/assets/#{asset}"
|
|
126
123
|
begin
|
|
127
124
|
asset_url(p)
|
|
128
125
|
rescue NoMethodError => e
|
|
@@ -150,7 +147,12 @@ module CamaleonCms::PluginsHelper
|
|
|
150
147
|
def self_plugin_key(index = 0)
|
|
151
148
|
k = "/plugins/"
|
|
152
149
|
f = caller[index]
|
|
153
|
-
|
|
150
|
+
if f.include?(k)
|
|
151
|
+
key = f.split(k).last.split("/").first
|
|
152
|
+
else
|
|
153
|
+
key = f.split('/gems/').last.split("/").first
|
|
154
|
+
end
|
|
155
|
+
PluginRoutes.plugin_info(key)['key'] rescue raise("Not found plugin with key: #{key} or dirname: #{key}")
|
|
154
156
|
end
|
|
155
157
|
|
|
156
158
|
# method called only from files within plugins directory
|
|
@@ -13,7 +13,7 @@ module CamaleonCms::SiteHelper
|
|
|
13
13
|
return $current_site if defined?($current_site)
|
|
14
14
|
return @current_site if defined?(@current_site)
|
|
15
15
|
if PluginRoutes.get_sites.size == 1
|
|
16
|
-
site = CamaleonCms::Site.first.decorate
|
|
16
|
+
site = CamaleonCms::Site.first.decorate rescue nil
|
|
17
17
|
else
|
|
18
18
|
host = [request.original_url.to_s.parse_domain]
|
|
19
19
|
host << request.subdomain if request.subdomain.present?
|
|
@@ -95,23 +95,4 @@ module CamaleonCms::SiteHelper
|
|
|
95
95
|
hook_run(theme, "on_inactive", theme_model) if theme_model.present?
|
|
96
96
|
# theme_model.destroy
|
|
97
97
|
end
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
# load all custom models customized by plugins or templates in custom_models.rb
|
|
101
|
-
def site_load_custom_models(site)
|
|
102
|
-
PluginRoutes.enabled_apps(site).each{ |app|
|
|
103
|
-
next if !app.present? || !app["path"].present?
|
|
104
|
-
s = File.join(app["path"], "config", "custom_models.rb")
|
|
105
|
-
eval(File.read(s)) if File.exist?(s)
|
|
106
|
-
}
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
#################### ONLY FOR CONSOLE ####################
|
|
110
|
-
# switch console sessions and redefine current for the console session
|
|
111
|
-
# site: Site model used as current site
|
|
112
|
-
# return nil
|
|
113
|
-
def site_console_switch(site = nil)
|
|
114
|
-
$current_site = site
|
|
115
|
-
site_load_custom_models($current_site)
|
|
116
|
-
end
|
|
117
98
|
end
|
|
@@ -14,7 +14,7 @@ module CamaleonCms::ThemeHelper
|
|
|
14
14
|
# return theme full asset path
|
|
15
15
|
# theme_name: theme name, if nil, then will use current theme
|
|
16
16
|
# asset: asset file name, if asset is present return full path to this asset
|
|
17
|
-
# sample: <script src="<%= theme_asset_path("js/admin.js") %>"></script> => return: /assets/themes/my_theme/assets/
|
|
17
|
+
# sample: <script src="<%= theme_asset_path("js/admin.js") %>"></script> => return: /assets/themes/my_theme/assets/js/admin-54505620f.js
|
|
18
18
|
def theme_asset_path(asset = nil, theme_name = nil)
|
|
19
19
|
if theme_name.present? && theme_name.include?("/")
|
|
20
20
|
return theme_asset_url(theme_name, current_theme.slug)
|
|
@@ -18,7 +18,8 @@ module CamaleonCms::UploaderHelper
|
|
|
18
18
|
# formats: extensions permitted, sample: jpg,png,... or generic: images | videos | audios | documents (default *)
|
|
19
19
|
# remove_source: Boolean (delete source file after saved if this is true, default false)
|
|
20
20
|
# same_name: Boolean (save the file with the same name if defined true, else search for a non used name)
|
|
21
|
-
# versions: String
|
|
21
|
+
# versions: (String) Create addtional multiple versions of the image uploaded, sample: '300x300,505x350' ==> Will create two extra images with these dimensions
|
|
22
|
+
# sample "test.png", versions: '200x200,450x450' will generate: thumb/test-png_200x200.png, test-png_450x450.png
|
|
22
23
|
# thumb_size: String (redefine the dimensions of the thumbnail, sample: '100x100' ==> only for images)
|
|
23
24
|
# temporal_time: if great than 0 seconds, then this file will expire (removed) in that time (default: 0)
|
|
24
25
|
# To manage jobs, please check http://edgeguides.rubyonrails.org/active_job_basics.html
|
|
@@ -26,9 +27,17 @@ module CamaleonCms::UploaderHelper
|
|
|
26
27
|
# sample: upload_file(params[:my_file], {formats: "images", folder: "temporal"})
|
|
27
28
|
# sample: upload_file(params[:my_file], {formats: "jpg,png,gif,mp3,mp4", temporal_time: 10.minutes, maximum: 10.megabytes})
|
|
28
29
|
def upload_file(uploaded_io, settings = {})
|
|
30
|
+
cached_name = uploaded_io.is_a?(ActionDispatch::Http::UploadedFile) ? uploaded_io.original_filename : nil
|
|
29
31
|
return {error: "File is empty", file: nil, size: nil} unless uploaded_io.present?
|
|
32
|
+
if uploaded_io.is_a?(String) && (uploaded_io.start_with?("http://") || uploaded_io.start_with?("https://")) # download url file
|
|
33
|
+
tmp = cama_tmp_upload(uploaded_io)
|
|
34
|
+
return tmp if tmp[:error].present?
|
|
35
|
+
settings[:remove_source] = true
|
|
36
|
+
uploaded_io = tmp[:file_path]
|
|
37
|
+
end
|
|
30
38
|
uploaded_io = File.open(uploaded_io) if uploaded_io.is_a?(String)
|
|
31
39
|
uploaded_io = File.open(cama_resize_upload(uploaded_io.path, settings[:dimension])) if settings[:dimension].present? # resize file into specific dimensions
|
|
40
|
+
|
|
32
41
|
settings = settings.to_sym
|
|
33
42
|
settings[:uploaded_io] = uploaded_io
|
|
34
43
|
settings = {
|
|
@@ -37,7 +46,7 @@ module CamaleonCms::UploaderHelper
|
|
|
37
46
|
formats: "*",
|
|
38
47
|
generate_thumb: true,
|
|
39
48
|
temporal_time: 0,
|
|
40
|
-
filename: (uploaded_io.original_filename rescue uploaded_io.path.split("/").last).parameterize(".").downcase.gsub(" ", "-"),
|
|
49
|
+
filename: ((cached_name || uploaded_io.original_filename) rescue uploaded_io.path.split("/").last).parameterize(".").downcase.gsub(" ", "-"),
|
|
41
50
|
file_size: File.size(uploaded_io.to_io),
|
|
42
51
|
remove_source: false,
|
|
43
52
|
same_name: false,
|
|
@@ -55,7 +64,6 @@ module CamaleonCms::UploaderHelper
|
|
|
55
64
|
res[:error] = "#{ct("file_size_exceeded", default: "File size exceeded")} (#{number_to_human_size(settings[:maximum])})"
|
|
56
65
|
return res
|
|
57
66
|
end
|
|
58
|
-
|
|
59
67
|
# save file
|
|
60
68
|
key = File.join(settings[:folder], settings[:filename]).to_s.gsub(/(\/){2,}/, "/")
|
|
61
69
|
res = cama_uploader.add_file(uploaded_io, key, {same_name: settings[:same_name]})
|
|
@@ -206,26 +214,23 @@ module CamaleonCms::UploaderHelper
|
|
|
206
214
|
# name: to indicate the name to use, sample: cama_tmp_upload('/var/www/media/132/logo 2.png', {name: 'owen.png', formats: 'images'})
|
|
207
215
|
# formats: extensions permitted, sample: jpg,png,... or generic: images | videos | audios | documents (default *)
|
|
208
216
|
# dimension: 20x30
|
|
217
|
+
# return: {file_path, error}
|
|
209
218
|
def cama_tmp_upload(uploaded_io, args = {})
|
|
210
219
|
tmp_path = args[:path] || Rails.public_path.join("tmp", current_site.id.to_s)
|
|
211
220
|
FileUtils.mkdir_p(tmp_path) unless Dir.exist?(tmp_path)
|
|
212
221
|
if uploaded_io.is_a?(String) && (uploaded_io.start_with?("http://") || uploaded_io.start_with?("https://"))
|
|
213
222
|
return {error: "#{ct("file_format_error")} (#{args[:formats]})"} unless cama_uploader.class.validate_file_format(uploaded_io, args[:formats])
|
|
214
|
-
uploaded_io = Rails.public_path.join(uploaded_io.sub(current_site.the_url, '')).to_s if uploaded_io.include?(current_site.the_url) # local file
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
path = uploader_verify_name( File.join(tmp_path, name))
|
|
218
|
-
File.open(path, 'wb'){|file| file.write(open(uploaded_io).read) }
|
|
219
|
-
path = cama_resize_upload(path, args[:dimension]) if args[:dimension].present?
|
|
220
|
-
else
|
|
221
|
-
uploaded_io = File.open(uploaded_io) if uploaded_io.is_a?(String)
|
|
222
|
-
return {error: "#{ct("file_format_error")} (#{args[:formats]})"} unless cama_uploader.class.validate_file_format(uploaded_io.path, args[:formats])
|
|
223
|
-
name = args[:name] || uploaded_io.path.split("/").last
|
|
224
|
-
name = "#{File.basename(name, File.extname(name)).underscore}#{File.extname(name)}"
|
|
225
|
-
path = uploader_verify_name( File.join(tmp_path, name))
|
|
226
|
-
File.open(path, "wb"){|f| f.write(uploaded_io.read) }
|
|
227
|
-
path = cama_resize_upload(path, args[:dimension]) if args[:dimension].present?
|
|
223
|
+
uploaded_io = Rails.public_path.join(uploaded_io.sub(current_site.the_url, '')).to_s if uploaded_io.include?(current_site.the_url) && Rails.env != 'production' # local file
|
|
224
|
+
_tmp_name = uploaded_io.split("/").last.split('?').first; args[:name] = args[:name] || _tmp_name
|
|
225
|
+
uploaded_io = open(uploaded_io)
|
|
228
226
|
end
|
|
227
|
+
uploaded_io = File.open(uploaded_io) if uploaded_io.is_a?(String)
|
|
228
|
+
return {error: "#{ct("file_format_error")} (#{args[:formats]})"} unless cama_uploader.class.validate_file_format(_tmp_name || uploaded_io.path, args[:formats])
|
|
229
|
+
return {error: "#{ct("file_size_exceeded", default: "File size exceeded")} (#{number_to_human_size(args[:maximum])})"} if args[:maximum].present? && args[:maximum] < (uploaded_io.size rescue File.size(uploaded_io))
|
|
230
|
+
name = args[:name] || uploaded_io.path.split("/").last; name = "#{File.basename(name, File.extname(name)).underscore}#{File.extname(name)}"
|
|
231
|
+
path = uploader_verify_name(File.join(tmp_path, name))
|
|
232
|
+
File.open(path, "wb"){|f| f.write(uploaded_io.read) }
|
|
233
|
+
path = cama_resize_upload(path, args[:dimension]) if args[:dimension].present?
|
|
229
234
|
{file_path: path, error: nil}
|
|
230
235
|
end
|
|
231
236
|
|
|
@@ -245,13 +250,13 @@ module CamaleonCms::UploaderHelper
|
|
|
245
250
|
|
|
246
251
|
# return the current uploader
|
|
247
252
|
def cama_uploader
|
|
253
|
+
@cama_uploader ||=
|
|
248
254
|
case current_site.get_option("filesystem_type", "local").downcase
|
|
249
255
|
when 's3' || 'aws'
|
|
250
|
-
|
|
256
|
+
CamaleonCmsAwsUploader.new({current_site: current_site})
|
|
251
257
|
else
|
|
252
|
-
|
|
258
|
+
CamaleonCmsLocalUploader.new({current_site: current_site})
|
|
253
259
|
end
|
|
254
|
-
@cama_uploader
|
|
255
260
|
end
|
|
256
261
|
|
|
257
262
|
private
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
#encoding: utf-8
|
|
10
10
|
module CamaleonCms::UserRolesHelper
|
|
11
11
|
def cama_get_roles_values
|
|
12
|
-
CamaleonCms::UserRole::ROLES
|
|
12
|
+
roles_list = CamaleonCms::UserRole::ROLES
|
|
13
|
+
# permit to add custom roles to be listed in editing roles form
|
|
14
|
+
# sample: args[:roles_list][:manager] << { key: 'my_role_key', label: "my_custom_permission", description: "lorem ipsum"}
|
|
15
|
+
# authorize! :manage, :my_role_key
|
|
16
|
+
args = {roles_list: roles_list}; hooks_run("available_user_roles_list", args)
|
|
17
|
+
args[:roles_list]
|
|
13
18
|
end
|
|
14
19
|
end
|
|
@@ -49,7 +49,8 @@ class CamaleonCms::HtmlMailer < ActionMailer::Base
|
|
|
49
49
|
theme = current_site.get_theme
|
|
50
50
|
lookup_context.prefixes.prepend("themes/#{theme.slug}") if theme.settings["gem_mode"]
|
|
51
51
|
lookup_context.prefixes.prepend("themes/#{theme.slug}/views") unless theme.settings["gem_mode"]
|
|
52
|
-
|
|
52
|
+
lookup_context.use_camaleon_partial_prefixes = true
|
|
53
|
+
(data[:files] || data[:attachments] || []).each{ |attach| attachments["#{File.basename(attach)}"] = File.open(attach, 'rb') { |f| f.read } if File.exist?(attach) }
|
|
53
54
|
|
|
54
55
|
layout = data[:layout_name].present? ? data[:layout_name] : false
|
|
55
56
|
if data[:template_name].present? # render email with template
|
|
@@ -77,33 +77,10 @@ class CamaleonCms::Ability
|
|
|
77
77
|
can :manage, :plugins if @roles_manager[:plugins] rescue false
|
|
78
78
|
can :manage, :users if @roles_manager[:users] rescue false
|
|
79
79
|
can :manage, :settings if @roles_manager[:settings] rescue false
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
@roles_manager.each do |rol_manage_key, val_role|
|
|
81
|
+
can :manage, rol_manage_key.to_sym if val_role.to_s.cama_true? rescue false
|
|
82
|
+
end
|
|
82
83
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# variants:
|
|
86
|
-
|
|
87
|
-
# can [:update, :destroy], [Article, Comment]
|
|
88
|
-
|
|
89
|
-
#alias_action :create, :read, :update, :destroy, :to => :crud
|
|
90
|
-
# can :crud, User
|
|
91
|
-
|
|
92
|
-
# can :invite, User
|
|
93
|
-
|
|
94
|
-
# can :read, Project, :priority => 1..3
|
|
95
|
-
|
|
96
|
-
# conditions:
|
|
97
|
-
# can :read, Project, :active => true, :user_id => user.id
|
|
98
|
-
# can :read, Project, :category => { :visible => true }
|
|
99
|
-
# can :manage, Project, :group => { :id => user.group_ids }
|
|
100
|
-
# can :read, Photo, Photo.scope_defined do |photo|
|
|
101
|
-
# photo.groups.empty?
|
|
102
|
-
# end
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
# See the wiki for details:
|
|
106
|
-
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
|
|
107
84
|
end
|
|
108
85
|
|
|
109
86
|
#overwrite can method to support decorator class names
|
|
@@ -18,6 +18,8 @@ class CamaleonCms::CustomField < ActiveRecord::Base
|
|
|
18
18
|
has_many :values, :class_name => "CamaleonCms::CustomFieldsRelationship", :foreign_key => :custom_field_id, dependent: :destroy
|
|
19
19
|
belongs_to :custom_field_group, class_name: "CamaleonCms::CustomFieldGroup"
|
|
20
20
|
belongs_to :parent, class_name: "CamaleonCms::CustomField", :foreign_key => :parent_id
|
|
21
|
+
alias_attribute :label, :name
|
|
22
|
+
validates_uniqueness_of :slug, scope: [:parent_id, :object_class]
|
|
21
23
|
|
|
22
24
|
scope :configuration, -> {where(parent_id: -1)}
|
|
23
25
|
scope :visible_group, -> {where(status: nil)}
|
|
@@ -29,5 +31,4 @@ class CamaleonCms::CustomField < ActiveRecord::Base
|
|
|
29
31
|
self.slug = self.name if self.slug.blank?
|
|
30
32
|
self.slug = self.slug.to_s.parameterize
|
|
31
33
|
end
|
|
32
|
-
|
|
33
34
|
end
|
|
@@ -15,28 +15,27 @@ class CamaleonCms::CustomFieldGroup < CamaleonCms::CustomField
|
|
|
15
15
|
has_many :metas, ->{ where(object_class: 'CustomFieldGroup')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :destroy
|
|
16
16
|
has_many :fields, -> {where(object_class: '_fields')}, :class_name => "CamaleonCms::CustomField", foreign_key: :parent_id, dependent: :destroy
|
|
17
17
|
belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
|
|
18
|
+
validates_uniqueness_of :slug, scope: [:object_class, :objectid]
|
|
18
19
|
before_validation :before_validating
|
|
19
20
|
|
|
20
|
-
# ------------------- fields -----------------
|
|
21
21
|
# add fields to group
|
|
22
22
|
# item:
|
|
23
23
|
# - sample: {"name"=>"Label", "slug"=>"my_slug", "description"=>"my description (optional)"}
|
|
24
24
|
# - options (textbox sample): {"field_key":"text_box","multiple":"1","required":"1","translate":"1"}
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
# -- add default for default value
|
|
30
|
-
# -- label_eval: (Boolean, default false), true => will evaluate the label and description of current field using (eval('my_label')) to have translatable|dynamic labels
|
|
25
|
+
# * field_key (string) | translate (boolean) | default_value (unique value) | default_values (array - multiple values for this field) | label_eval (boolean) | multiple_options (array)
|
|
26
|
+
# * multiple_options (used for select, radio and checkboxes ): [{"title"=>"Option Title", "value"=>"2", "default"=>"1"}, {"title"=>"abcde", "value"=>"3"}]
|
|
27
|
+
# * label_eval: (Boolean, default false), true => will evaluate the label and description of current field using (eval('my_label')) to have translatable|dynamic labels
|
|
28
|
+
#****** check all options for each case in Admin::CustomFieldsHelper ****
|
|
31
29
|
# SAMPLE: my_model.add_field({"name"=>"Sub Title", "slug"=>"subtitle"}, {"field_key"=>"text_box", "translate"=>true, default_value: "Get in Touch"})
|
|
32
|
-
|
|
33
30
|
def add_manual_field(item, options)
|
|
34
31
|
c = get_field(item[:slug] || item["slug"])
|
|
35
32
|
return c if c.present?
|
|
36
33
|
|
|
37
|
-
field_item = self.fields.
|
|
38
|
-
field_item.
|
|
39
|
-
|
|
34
|
+
field_item = self.fields.new(item)
|
|
35
|
+
if field_item.save
|
|
36
|
+
field_item.set_options(options)
|
|
37
|
+
auto_save_default_values(field_item, options)
|
|
38
|
+
end
|
|
40
39
|
field_item
|
|
41
40
|
end
|
|
42
41
|
alias_method :add_field, :add_manual_field
|
|
@@ -47,31 +46,31 @@ class CamaleonCms::CustomFieldGroup < CamaleonCms::CustomField
|
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
# only used by form on admin panel (protected)
|
|
49
|
+
# return array of failed_fields and full_fields [[failed fields], [all fields]]
|
|
50
50
|
def add_fields(items, item_options)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
order_index = 0
|
|
51
|
+
self.fields.where.not(id: items.map{|k, obj| obj['id'] }.uniq).destroy_all
|
|
52
|
+
cache_fields, order_index, errors_saved = [], 0, []
|
|
54
53
|
if items.present?
|
|
55
54
|
items.each do |i,item|
|
|
56
55
|
item[:field_order] = order_index
|
|
57
56
|
options = item_options[i] || {}
|
|
58
|
-
if item[:id].present?
|
|
59
|
-
field_item = self.fields.find(item[:id])
|
|
57
|
+
if item[:id].present? && (field_item = self.fields.where(id: item[:id]).first).present?
|
|
60
58
|
saved = field_item.update(item)
|
|
59
|
+
cache_fields << field_item
|
|
61
60
|
else
|
|
62
61
|
field_item = self.fields.new(item)
|
|
62
|
+
cache_fields << field_item
|
|
63
63
|
saved = field_item.save
|
|
64
64
|
auto_save_default_values(field_item, options) if saved
|
|
65
|
+
errors_saved << field_item unless saved
|
|
65
66
|
end
|
|
66
67
|
if saved
|
|
67
68
|
field_item.set_meta('_default', options)
|
|
68
|
-
ids_saved << field_item.id
|
|
69
69
|
order_index += 1
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
-
|
|
74
|
-
self.fields.where(id: ids_deletes).destroy_all if ids_deletes.any?
|
|
73
|
+
[errors_saved, cache_fields]
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
# generate the caption for this group
|
|
@@ -112,17 +111,19 @@ class CamaleonCms::CustomFieldGroup < CamaleonCms::CustomField
|
|
|
112
111
|
self.slug = "_group-#{self.name.to_s.parameterize}" unless self.slug.present?
|
|
113
112
|
end
|
|
114
113
|
|
|
115
|
-
# TODO VERIFY CLASS NAME
|
|
116
114
|
# auto save the default field values
|
|
117
115
|
def auto_save_default_values(field, options)
|
|
116
|
+
options = options.with_indifferent_access
|
|
118
117
|
class_name = self.object_class.split("_").first
|
|
119
|
-
if ["Post", "Category", "Plugin", "Theme"].include?(class_name) && self.objectid.present? && options[:default_value].present?
|
|
118
|
+
if ["Post", "Category", "Plugin", "Theme"].include?(class_name) && self.objectid.present? && (options[:default_value].present? || options[:default_values].present?)
|
|
120
119
|
if class_name == "Theme"
|
|
121
120
|
owner = "CamaleonCms::#{class_name}".constantize.where(id: self.objectid).first # owner model
|
|
122
121
|
else
|
|
123
122
|
owner = "CamaleonCms::#{class_name}".constantize.find(self.objectid) rescue "CamaleonCms::#{class_name}".constantize.where(slug: self.objectid).first # owner model
|
|
124
123
|
end
|
|
125
|
-
|
|
124
|
+
(options[:default_values] || [options[:default_value]] || []).each do |value|
|
|
125
|
+
owner.field_values.create!({custom_field_id: field.id, custom_field_slug: field.slug, value: fix_meta_value(value)}) if owner.present?
|
|
126
|
+
end
|
|
126
127
|
end
|
|
127
128
|
end
|
|
128
129
|
end
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
=end
|
|
9
9
|
class CamaleonCms::CustomFieldsRelationship < ActiveRecord::Base
|
|
10
10
|
self.table_name = "#{PluginRoutes.static_system_info["db_prefix"]}custom_fields_relationships"
|
|
11
|
-
attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class, :custom_field_slug
|
|
11
|
+
attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class, :custom_field_slug, :group_number
|
|
12
12
|
default_scope {order("#{CamaleonCms::CustomFieldsRelationship.table_name}.term_order ASC")}
|
|
13
13
|
# relations
|
|
14
14
|
belongs_to :custom_fields, :class_name => "CamaleonCms::CustomField", foreign_key: :custom_field_id
|