camaleon_cms 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/apps/themes/new/views/index.html.erb +1 -0
  4. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.eot +0 -0
  5. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.svg +273 -214
  6. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.ttf +0 -0
  7. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.woff +0 -0
  8. data/app/assets/fonts/camaleon_cms/glyphicons-halflings-regular.woff2 +0 -0
  9. data/app/assets/javascripts/camaleon_cms/admin/_libraries.js +11 -2
  10. data/app/assets/javascripts/camaleon_cms/admin/_post.js +1 -1
  11. data/app/assets/stylesheets/camaleon_cms/bootstrap.min.css.scss +6796 -2
  12. data/app/controllers/camaleon_cms/admin/appearances/widgets/assign_controller.rb +13 -4
  13. data/app/controllers/camaleon_cms/admin/appearances/widgets/main_controller.rb +8 -4
  14. data/app/controllers/camaleon_cms/admin/appearances/widgets/sidebar_controller.rb +8 -3
  15. data/app/controllers/camaleon_cms/admin/posts/drafts_controller.rb +11 -18
  16. data/app/controllers/camaleon_cms/admin/posts_controller.rb +16 -17
  17. data/app/controllers/camaleon_cms/admin/sessions_controller.rb +10 -16
  18. data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +14 -10
  19. data/app/controllers/camaleon_cms/admin/settings/post_types_controller.rb +10 -7
  20. data/app/controllers/camaleon_cms/admin/settings/sites_controller.rb +2 -1
  21. data/app/controllers/camaleon_cms/frontend_controller.rb +8 -9
  22. data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +1 -1
  23. data/app/decorators/camaleon_cms/application_decorator.rb +1 -1
  24. data/app/decorators/camaleon_cms/custom_field_decorator.rb +0 -6
  25. data/app/decorators/camaleon_cms/metas_decorator_methods.rb +1 -1
  26. data/app/decorators/camaleon_cms/plugin_decorator.rb +11 -0
  27. data/app/decorators/camaleon_cms/post_decorator.rb +0 -11
  28. data/app/decorators/camaleon_cms/post_type_decorator.rb +1 -1
  29. data/app/decorators/camaleon_cms/site_decorator.rb +4 -2
  30. data/app/decorators/camaleon_cms/term_taxonomy_decorator.rb +12 -16
  31. data/app/decorators/camaleon_cms/user_decorator.rb +0 -6
  32. data/app/helpers/camaleon_cms/admin/menus_helper.rb +1 -1
  33. data/app/helpers/camaleon_cms/camaleon_helper.rb +1 -1
  34. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +2 -1
  35. data/app/helpers/camaleon_cms/html_helper.rb +14 -1
  36. data/app/helpers/camaleon_cms/session_helper.rb +32 -0
  37. data/app/helpers/camaleon_cms/short_code_helper.rb +2 -2
  38. data/app/helpers/camaleon_cms/site_helper.rb +3 -4
  39. data/app/helpers/camaleon_cms/uploader_helper.rb +7 -5
  40. data/app/mailers/camaleon_cms/html_mailer.rb +4 -0
  41. data/app/models/camaleon_cms/ability.rb +9 -14
  42. data/app/models/camaleon_cms/category.rb +1 -2
  43. data/app/models/camaleon_cms/custom_field_group.rb +1 -1
  44. data/app/models/camaleon_cms/plugin.rb +4 -1
  45. data/app/models/camaleon_cms/post.rb +7 -0
  46. data/app/models/camaleon_cms/post_default.rb +7 -0
  47. data/app/models/camaleon_cms/post_type.rb +6 -4
  48. data/app/models/camaleon_cms/site.rb +2 -1
  49. data/app/models/camaleon_cms/term_taxonomy.rb +1 -0
  50. data/app/models/concerns/camaleon_cms/custom_fields_read.rb +8 -6
  51. data/app/models/concerns/camaleon_cms/metas.rb +2 -2
  52. data/app/views/camaleon_cms/admin/appearances/nav_menus/_custom_menus.html.erb +1 -1
  53. data/app/views/camaleon_cms/admin/appearances/themes/index.html.erb +1 -2
  54. data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +2 -2
  55. data/app/views/camaleon_cms/admin/posts/form.html.erb +1 -1
  56. data/app/views/camaleon_cms/admin/posts/index.html.erb +2 -1
  57. data/app/views/camaleon_cms/admin/sessions/login.html.erb +1 -1
  58. data/app/views/camaleon_cms/admin/settings/_file_system_settings.html.erb +4 -0
  59. data/app/views/camaleon_cms/admin/settings/custom_fields/index.html.erb +1 -1
  60. data/app/views/camaleon_cms/admin/settings/site.html.erb +11 -4
  61. data/app/views/camaleon_cms/default_theme/category.html.erb +1 -1
  62. data/app/views/camaleon_cms/default_theme/index.html.erb +1 -1
  63. data/app/views/camaleon_cms/default_theme/layouts/cama_ajax.html.erb +1 -0
  64. data/app/views/camaleon_cms/default_theme/partials/_categories_list.html.erb +1 -1
  65. data/app/views/camaleon_cms/default_theme/partials/_post_list_item.html.erb +1 -1
  66. data/app/views/camaleon_cms/default_theme/partials/_sidebar.html.erb +1 -1
  67. data/app/views/camaleon_cms/default_theme/post_type.html.erb +1 -1
  68. data/app/views/camaleon_cms/default_theme/single.html.erb +1 -1
  69. data/app/views/layouts/camaleon_cms/admin.html.erb +3 -0
  70. data/config/initializers/action_view.rb +6 -2
  71. data/config/locales/camaleon_cms/admin/en.yml +1 -0
  72. data/config/routes/frontend.rb +11 -8
  73. data/config/system.json +1 -1
  74. data/lib/camaleon_cms/engine.rb +1 -1
  75. data/lib/camaleon_cms/version.rb +1 -1
  76. data/lib/generators/camaleon_cms/gem_plugin_template/config/camaleon_plugin.json +0 -4
  77. data/lib/generators/camaleon_cms/gem_plugin_template/config/custom_models.rb +3 -0
  78. data/lib/generators/camaleon_cms/theme_template/app/apps/themes/my_theme/views/admin/settings.html.erb +1 -3
  79. data/lib/plugin_routes.rb +4 -4
  80. data/lib/tasks/camaleon_cms/rspec_test.rake +2 -1
  81. metadata +7 -13
  82. data/app/apps/themes/new/data.json +0 -1
  83. data/app/apps/themes/new/views/partials/_breadcrumb.html.erb +0 -10
  84. data/app/apps/themes/new/views/partials/_categories_list.html.erb +0 -23
  85. data/app/apps/themes/new/views/partials/_comments.html.erb +0 -32
  86. data/app/apps/themes/new/views/partials/_comments_list.html.erb +0 -21
  87. data/app/apps/themes/new/views/partials/_flash_messages.html.erb +0 -26
  88. data/app/apps/themes/new/views/partials/_forms.html.erb +0 -19
  89. data/app/apps/themes/new/views/partials/_post_list_item.html.erb +0 -13
  90. data/app/apps/themes/new/views/partials/_search_form.html.erb +0 -9
  91. data/app/apps/themes/new/views/partials/_sidebar.html.erb +0 -60
@@ -13,7 +13,7 @@ module CamaleonCms::FrontendConcern extend ActiveSupport::Concern
13
13
  # you can add custom sitemap elements in the attr "custom", like: https://github.com/owen2345/camaleon-cms/issues/106#issuecomment-146232211
14
14
  # you can customize your content for html or xml format
15
15
  def sitemap
16
- r = {layout: (params[:format] == "html" ? (self.send :_layout) : false), render: "sitemap", custom: {a: a}, format: params[:format], skip_post_ids: [], skip_posttype_ids: [], skip_cat_ids: [], skip_tag_ids: []}
16
+ r = {layout: (params[:format] == "html" ? (self.send :_layout) : false), render: "sitemap", custom: {}, format: params[:format], skip_post_ids: [], skip_posttype_ids: [], skip_cat_ids: [], skip_tag_ids: []}
17
17
  hooks_run("on_render_sitemap", r)
18
18
  @r = r
19
19
  render r[:render], layout: r[:layout]
@@ -9,7 +9,7 @@
9
9
  class CamaleonCms::ApplicationDecorator < Draper::Decorator
10
10
  delegate_all
11
11
  @_deco_locale = nil
12
- include MetasDecoratorMethods
12
+ include CamaleonCms::MetasDecoratorMethods
13
13
 
14
14
  # return the keywords for this model
15
15
  def the_keywords
@@ -21,10 +21,4 @@ class CamaleonCms::CustomFieldDecorator < Draper::Decorator
21
21
  object.description
22
22
  end
23
23
  end
24
-
25
- # cache identifier, the format is: [current-site-prefix]/[object-id]-[object-last_updated]/[current locale]
26
- # key: additional key for the model
27
- def cache_prefix(key = "")
28
- "#{h.current_site.cache_prefix}/cfield#{object.id}#{"/#{key}" if key.present?}"
29
- end
30
24
  end
@@ -8,7 +8,7 @@
8
8
  =end
9
9
  module CamaleonCms::MetasDecoratorMethods
10
10
  # return meta value translated for key in this model
11
- def the_option(key)
11
+ def the_meta(key)
12
12
  object.get_meta(key, "").translate(@_deco_locale)
13
13
  end
14
14
 
@@ -0,0 +1,11 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class CamaleonCms::PluginDecorator < CamaleonCms::TermTaxonomyDecorator
10
+ delegate_all
11
+ end
@@ -191,12 +191,6 @@ class CamaleonCms::PostDecorator < CamaleonCms::ApplicationDecorator
191
191
  r[:flag] && object.status == 'published'
192
192
  end
193
193
 
194
- # check if the post can be commented
195
- def can_commented?
196
- object.manage_comments?
197
- end
198
-
199
-
200
194
  # add_post_type: true/false to include post type link
201
195
  # children: true/false (show/hide last item link)
202
196
  # show_categories: true/false, true: add categories tree to the breadcrumb
@@ -215,9 +209,4 @@ class CamaleonCms::PostDecorator < CamaleonCms::ApplicationDecorator
215
209
  object.post_type.decorate
216
210
  end
217
211
 
218
- # cache identifier, the format is: [current-site-prefix]/[object-id]-[object-last_updated]/[current locale]
219
- # key: additional key for the model
220
- def cache_prefix(key = "")
221
- "#{h.current_site.cache_prefix}/post#{object.id}#{"/#{key}" if key.present?}"
222
- end
223
212
  end
@@ -72,7 +72,7 @@ class CamaleonCms::PostTypeDecorator < CamaleonCms::TermTaxonomyDecorator
72
72
  # return thumbnail for this post type
73
73
  # default: if thumbnail is not present, will render default
74
74
  def the_thumb_url(default = nil)
75
- th = object.get_option("thumb")
75
+ th = object.get_option("thumb", object.get_option("default_thumb"))
76
76
  th.present? ? th : (default || h.asset_url("camaleon_cms/image-not-found.png"))
77
77
  end
78
78
  end
@@ -86,6 +86,8 @@ class CamaleonCms::SiteDecorator < CamaleonCms::TermTaxonomyDecorator
86
86
  end
87
87
 
88
88
  # return the post_tag object with id or slug = slug_or_id from this site
89
+ # sample: current_site.the_tag('test').the_url
90
+ # sample2: current_site.the_tag('test').the_posts
89
91
  def the_tag(slug_or_id)
90
92
  return object.post_tags.where(id: slug_or_id).first.decorate rescue nil if slug_or_id.is_a?(Integer)
91
93
  return object.post_tags.find_by_slug(slug_or_id).decorate rescue nil if slug_or_id.is_a?(String)
@@ -152,7 +154,7 @@ class CamaleonCms::SiteDecorator < CamaleonCms::TermTaxonomyDecorator
152
154
  # return root url for this site
153
155
  def the_url(*args)
154
156
  args = args.extract_options!
155
- args[:host] = object.main_site? ? object.slug : (object.slug.include?(".") ? object.slug : "#{object.slug}.#{PluginRoutes.system_info["base_domain"]}" )
157
+ args[:host] = object.main_site? ? PluginRoutes.system_info["base_domain"] : (object.slug.include?(".") ? object.slug : "#{object.slug}.#{PluginRoutes.system_info["base_domain"]}" )
156
158
  args[:port] = (args[:host].split(":")[1] rescue nil)
157
159
  args[:locale] = @_deco_locale unless args.include?(:locale)
158
160
  args[:host] = args[:host].split(":").first
@@ -168,7 +170,7 @@ class CamaleonCms::SiteDecorator < CamaleonCms::TermTaxonomyDecorator
168
170
  # =============================== ADMIN =======================
169
171
  # admin root url for this site
170
172
  def the_admin_url
171
- host = object.main_site? ? object.slug : (object.slug.include?(".") ? object.slug : "#{object.slug}.#{PluginRoutes.system_info["base_domain"]}" )
173
+ host = object.main_site? ? PluginRoutes.system_info["base_domain"] : (object.slug.include?(".") ? object.slug : "#{object.slug}.#{PluginRoutes.system_info["base_domain"]}" )
172
174
  port = (host.split(":")[1] rescue nil)
173
175
  h.cama_url_to_fixed("cama_admin_dashboard_url", host: host, port: port, locale: false)
174
176
  end
@@ -7,7 +7,7 @@
7
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
9
  class CamaleonCms::TermTaxonomyDecorator < CamaleonCms::ApplicationDecorator
10
- include CustomFieldsConcern
10
+ include CamaleonCms::CustomFieldsConcern
11
11
  delegate_all
12
12
 
13
13
  # return the title for current locale
@@ -84,20 +84,16 @@ class CamaleonCms::TermTaxonomyDecorator < CamaleonCms::ApplicationDecorator
84
84
  h.link_to("&rarr; #{title || h.ct("edit")}".html_safe, the_edit_url, attrs)
85
85
  end
86
86
 
87
- # cache identifier, the format is: [current-site-prefix]/[object-id]-[object-last_updated]/[current locale]
88
- # key: additional key for the model
89
- def cache_prefix(key = "")
90
- res = ""
91
- case object.class.name
92
- when "CamaleonCms::PostType"
93
- res = "#{h.current_site.cache_prefix}/ptype#{object.id}#{"/#{key}" if key.present?}"
94
- when "CamaleonCms::Category"
95
- res = "#{h.current_site.cache_prefix}/pcat#{object.id}#{"/#{key}" if key.present?}"
96
- when "CamaleonCms::PostTag"
97
- res = "#{h.current_site.cache_prefix}/ptag#{object.id}#{"/#{key}" if key.present?}"
98
- when "CamaleonCms::Site"
99
- res = "/#{object.id}/#{I18n.locale}#{"/#{key}" if key.present?}"
100
- end
101
- res
87
+ # return the user owner of this item
88
+ # sample: my_item.the_owner.the_url
89
+ def the_owner
90
+ owner.decorate rescue nil
91
+ end
92
+
93
+ # return the parent item of this item
94
+ # sample: my_item.the_parent.the_url
95
+ def the_parent
96
+ parent.decorate rescue nil
102
97
  end
98
+
103
99
  end
@@ -61,12 +61,6 @@ class CamaleonCms::UserDecorator < CamaleonCms::ApplicationDecorator
61
61
  h.current_site.posts.where(user_id: object.id)
62
62
  end
63
63
 
64
- # cache identifier, the format is: [current-site-prefix]/[object-id]-[object-last_updated]/[current locale]
65
- # key: additional key for the model
66
- def cache_prefix(key = "")
67
- "#{h.current_site.cache_prefix}/user#{object.id}#{"/#{key}" if key.present?}"
68
- end
69
-
70
64
  private
71
65
 
72
66
  def avatar_exists?
@@ -40,7 +40,7 @@ module CamaleonCms::Admin::MenusHelper
40
40
  admin_menu_add_menu("appearance", {icon: "paint-brush", title: t('camaleon_cms.admin.sidebar.appearance'), url: "", items: items, datas: "data-intro='#{t("camaleon_cms.admin.intro.appearance")}' data-position='right' data-wait='500'"}) if items.present?
41
41
 
42
42
 
43
- admin_menu_add_menu("plugins", {icon: "plug", title: "#{t('camaleon_cms.admin.sidebar.plugins')} <small class='label label-primary'>#{PluginRoutes.all_plugins.size}</small>", url: cama_admin_plugins_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.plugins")}' data-position='right'"}) if can? :manager, :plugins
43
+ admin_menu_add_menu("plugins", {icon: "plug", title: "#{t('camaleon_cms.admin.sidebar.plugins')} <small class='label label-primary'>#{PluginRoutes.all_plugins.clone.delete_if{|plugin| plugin[:domain].present? && !plugin[:domain].split(",").include?(current_site.the_slug) }.size}</small>", url: cama_admin_plugins_path, datas: "data-intro='#{t("camaleon_cms.admin.intro.plugins")}' data-position='right'"}) if can? :manager, :plugins
44
44
 
45
45
  if can? :manager, :users
46
46
  items = []
@@ -15,7 +15,7 @@ module CamaleonCms::CamaleonHelper
15
15
  # attachs: array of files to be attached to the email
16
16
  # layout_name: path of the template to render
17
17
  # template_name: template name to render in template_path
18
- def sendmail(email,subject='Tiene una notificacion',content='',from=nil,attachs=[],template_name = 'mailer', layout_name = 'mailer')
18
+ def sendmail(email,subject='Tiene una notificacion',content='',from=nil,attachs=[],template_name = 'mailer', layout_name = 'camaleon_cms/mailer')
19
19
  Thread.abort_on_exception=true
20
20
  Thread.new do
21
21
  HtmlMailer.sender(email, subject, content, from, attachs, cama_root_url, current_site, template_name, layout_name).deliver_now
@@ -161,7 +161,8 @@ module CamaleonCms::Frontend::NavMenuHelper
161
161
  post_type = CamaleonCms::PostType.find(nav_menu_item.get_option('object_id')).decorate
162
162
  {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}
163
163
  when 'external'
164
- r = {link: nav_menu_item.get_option('object_id'), name: nav_menu_item.name.to_s.translate, type_menu: type_menu, current: false}
164
+ r = {link: nav_menu_item.get_option('object_id', ""), name: nav_menu_item.name.to_s.translate, type_menu: type_menu, current: false}
165
+ r[:current] = r[:link] == site_current_url || r[:link] == site_current_path
165
166
  r[:link] = cama_url_to_fixed("cama_root_url") if r[:link] == "root_url"
166
167
  r
167
168
  else
@@ -13,8 +13,20 @@ module CamaleonCms::HtmlHelper
13
13
  @_assets_content = []
14
14
  end
15
15
 
16
+ # register a new asset library to be included on demand calling by: cama_load_libraries(...)
17
+ # sample: cama_assets_library_register("my_library", {js: ["url_js", "url_js2"], css: ["url_css1", "url_css2"]})
18
+ # cama_load_libraries("my_library")
19
+ def cama_assets_library_register(key, assets = {})
20
+ key = key.to_sym
21
+ cama_assets_libraries
22
+ @_cama_assets_libraries[key] = {css: [], js: [] } unless @_cama_assets_libraries[key].present?
23
+ @_cama_assets_libraries[key][:css] += assets[:css] if assets[:css].present?
24
+ @_cama_assets_libraries[key][:js] += assets[:js] if assets[:js].present?
25
+ end
26
+
16
27
  # enable to load admin or registered libraries (colorpicker, datepicker, form_builder, tinymce, form_ajax, cropper)
17
28
  # sample: add_asset_library("datepicker", "colorpicker")
29
+ # This will add this assets library in the admin head or in a custom place by calling: cama_draw_custom_assets()
18
30
  def cama_load_libraries(*keys)
19
31
  keys.each do |key|
20
32
  library = cama_assets_libraries[key.to_sym]
@@ -88,6 +100,7 @@ module CamaleonCms::HtmlHelper
88
100
 
89
101
  private
90
102
  def cama_assets_libraries
103
+ return @_cama_assets_libraries if @_cama_assets_libraries.present?
91
104
  libs = {}
92
105
  libs[:colorpicker] = {js: ['camaleon_cms/admin/bootstrap-colorpicker'], css: ["camaleon_cms/admin/colorpicker.css"]}
93
106
  libs[:datepicker] = {js: ['camaleon_cms/admin/bootstrap-datepicker']}
@@ -101,6 +114,6 @@ module CamaleonCms::HtmlHelper
101
114
  libs[:validate] = {js: ['camaleon_cms/admin/jquery.validate']}
102
115
  libs[:nav_menu] = {css: ['camaleon_cms/admin/nestable/jquery.nestable', "camaleon_cms/admin/nav-menu"], js: ["camaleon_cms/admin/jquery.nestable", 'camaleon_cms/admin/nav-menu']}
103
116
  libs[:admin_intro] = {js: ['camaleon_cms/admin/introjs/intro.min'], css: ["camaleon_cms/admin/introjs/introjs.min"]}
104
- libs
117
+ @_cama_assets_libraries = libs
105
118
  end
106
119
  end
@@ -40,6 +40,36 @@ module CamaleonCms::SessionHelper
40
40
  @user && @user.authenticate(password)
41
41
  end
42
42
 
43
+ ##
44
+ # User registration.
45
+ #
46
+ # user_data must contain:
47
+ # - email
48
+ # - username
49
+ # - password
50
+ # - password_confirmation
51
+ #
52
+ # meta must contain:
53
+ # - first_name
54
+ # - last_name
55
+ #
56
+ def cama_register_user(user_data, meta)
57
+ @user = current_site.users.new(user_data)
58
+ r = {user: @user, params: params}; hook_run('user_before_register', r)
59
+
60
+ if current_site.security_user_register_captcha_enabled? && !cama_captcha_verified?
61
+ {:result => false, :type => :captcha_error, :message => t('camaleon_cms.admin.users.message.error_captcha')}
62
+ else
63
+ if @user.save
64
+ @user.set_meta_from_form(meta)
65
+ r = {user: @user, message: t('camaleon_cms.admin.users.message.created'), redirect_url: cama_admin_login_path}; hooks_run('user_after_register', r)
66
+ {:result => true, :message => r[:message], :redirect_url => r[:redirect_url]}
67
+ else
68
+ {:result => false, :type => :no_saved}
69
+ end
70
+ end
71
+ end
72
+
43
73
  # check if current host is heroku
44
74
  def cama_on_heroku?
45
75
  ENV.keys.any? { |var_name| var_name.match(/(heroku|dyno)/i) }
@@ -76,6 +106,7 @@ module CamaleonCms::SessionHelper
76
106
  def cama_sign_in?
77
107
  !cama_current_user.nil?
78
108
  end
109
+
79
110
  alias_method :signin?, :cama_sign_in?
80
111
 
81
112
  # return the role for current user
@@ -99,6 +130,7 @@ module CamaleonCms::SessionHelper
99
130
  @current_user = (current_site.users_include_admins.find_by_auth_token(c[0]).decorate rescue nil)
100
131
  end
101
132
  end
133
+
102
134
  alias_method :current_user, :cama_current_user
103
135
 
104
136
  # check if a visitor was logged in
@@ -18,7 +18,7 @@ module CamaleonCms::ShortCodeHelper
18
18
  Sample: [widget widget_key]")
19
19
 
20
20
  shortcode_add("load_libraries",
21
- lambda{|attrs, args| add_asset_library(*attrs["data"].to_s.split(",")); return ""; },
21
+ lambda{|attrs, args| cama_load_libraries(*attrs["data"].to_s.split(",")); return ""; },
22
22
  "Permit to load libraries on demand, sample: [load_libraries data='datepicker,tinymce']")
23
23
 
24
24
  shortcode_add("asset",
@@ -145,7 +145,7 @@ module CamaleonCms::ShortCodeHelper
145
145
  # determine the content to replace instead the shortcode
146
146
  # return string
147
147
  def _eval_shortcode(code, attrs, args={}, template = nil)
148
- template ||= (@_shortcodes_template[code].present? ? @_shortcodes_template[code] : "shortcode_templates/#{code}")
148
+ template ||= (@_shortcodes_template[code].present? ? @_shortcodes_template[code] : "camaleon_cms/shortcode_templates/#{code}")
149
149
  if @_shortcodes_template[code].class.name == "Proc"
150
150
  res = @_shortcodes_template[code].call(_shortcode_parse_attr(attrs), args)
151
151
  else
@@ -12,9 +12,8 @@ module CamaleonCms::SiteHelper
12
12
  @current_site = site.decorate if site.present?
13
13
  return $current_site if defined?($current_site)
14
14
  return @current_site if defined?(@current_site)
15
- all_sites = CamaleonCms::Site.all
16
- if all_sites.size == 1
17
- site = all_sites.first.decorate
15
+ if PluginRoutes.get_sites.size == 1
16
+ site = PluginRoutes.get_sites.first.decorate
18
17
  else
19
18
  host = request.original_url.to_s.parse_domain
20
19
  if host == PluginRoutes.system_info["base_domain"]
@@ -33,7 +32,7 @@ module CamaleonCms::SiteHelper
33
32
  def cama_site_check_existence()
34
33
  if !current_site.present?
35
34
  if (PluginRoutes.main_site).present?
36
- base_domain = PluginRoutes.main_site.slug
35
+ base_domain = PluginRoutes.system_info["base_domain"]
37
36
  redirect_to cama_root_url(host: base_domain.split(":").first, port: (base_domain.split(":")[1] rescue nil))
38
37
  else
39
38
  redirect_to cama_admin_installers_path
@@ -57,7 +57,7 @@ module CamaleonCms::UploaderHelper
57
57
  settings[:formats] = "zip,7z,rar,tar,bz2,gz,rar2"
58
58
  end
59
59
 
60
- unless settings[:formats].downcase.split(",").include?(File.extname(file_path).sub(".", "").downcase)
60
+ unless settings[:formats].downcase.split(",").include?(File.extname(settings[:filename]).sub(".", "").downcase)
61
61
  res[:error] = ct("file_format_error")
62
62
  return res
63
63
  end
@@ -123,7 +123,9 @@ module CamaleonCms::UploaderHelper
123
123
  # add a new folder in fog
124
124
  def cama_uploader_add_folder(folder)
125
125
  cama_uploader_init_connection(true)
126
- @fog_connection_bucket_dir.files.create({:key => "#{current_site.id}/#{folder}/".gsub(/(\/){2,}/, "/"), content: "", :public => true})
126
+ key = "#{current_site.id}/#{folder}/".split("/").clean_empty.join("/")
127
+ key += '/_tmp.txt' unless @fog_connection.class.name.include?("AWS")
128
+ @fog_connection_bucket_dir.files.create({:key => key, content: "", :public => true})
127
129
  end
128
130
 
129
131
  # initialize fog uploader and trigger hook to customize fog storage
@@ -186,7 +188,7 @@ module CamaleonCms::UploaderHelper
186
188
  folder_src[:folders][file.key.split("/").last] = {folders: {}, files: []}
187
189
  else
188
190
  r_file = cama_uploader_parse_file(file)
189
- folder_src[:files] << r_file if r_file["url"].present? # skip non public url files (protected)
191
+ folder_src[:files] << r_file if r_file["url"].present? && !file.key.include?('/_tmp.txt') # skip non public url files (protected)
190
192
  end
191
193
  end
192
194
  end
@@ -211,10 +213,10 @@ module CamaleonCms::UploaderHelper
211
213
 
212
214
  # parse file information of FOG file
213
215
  def cama_uploader_parse_file(file)
214
- res = {"name"=> File.basename(file.key), "size"=> file.content_length, "url"=> (file.public_url rescue "#{@fog_connection.endpoint}/#{file.key}"), "deleteUrl"=> "" }
216
+ res = {"name"=> File.basename(file.key), "file"=> file.key, "size"=> file.content_length, "url"=> (file.public_url rescue [current_site.get_option("filesystem_s3_endpoint"), file.key ].join("/")), "deleteUrl"=> "" }
215
217
  ext = File.extname(file.key).sub(".", "").downcase
216
218
  res["format"] = "unknown"
217
- if "jpg,jpeg,png,gif,bmp".split(",").include?(ext)
219
+ if "jpg,jpeg,png,gif,bmp,ico".split(",").include?(ext)
218
220
  if File.extname(res["name"]) == ".gif"
219
221
  res["thumb"] = res["url"]
220
222
  else
@@ -37,6 +37,10 @@ class CamaleonCms::HtmlMailer < ActionMailer::Base
37
37
  }
38
38
  end
39
39
 
40
+ views_dir = "app/apps/"
41
+ self.prepend_view_path(File.join($camaleon_engine_dir, views_dir).to_s)
42
+ self.prepend_view_path(Rails.root.join(views_dir).to_s)
43
+
40
44
  theme = current_site.get_theme
41
45
  lookup_context.prefixes.prepend("themes/#{theme.slug}") if theme.settings["gem_mode"]
42
46
  lookup_context.prefixes.prepend("themes/#{theme.slug}/views") unless theme.settings["gem_mode"]
@@ -30,34 +30,34 @@ class CamaleonCms::Ability
30
30
  ids_delete_other = @roles_post_type[:delete_other] || []
31
31
  ids_delete_publish = @roles_post_type[:delete_publish] || []
32
32
 
33
- can :posts, PostType do |pt|
33
+ can :posts, CamaleonCms::PostType do |pt|
34
34
  (ids_edit + ids_edit_other + ids_edit_publish).to_i.include?(pt.id) rescue false
35
35
  end
36
36
 
37
- can :create_post, PostType do |pt|
37
+ can :create_post, CamaleonCms::PostType do |pt|
38
38
  ids_edit.to_i.include?(pt.id) rescue false
39
39
  end
40
- can :publish_post, PostType do |pt|
40
+ can :publish_post, CamaleonCms::PostType do |pt|
41
41
  ids_publish.to_i.include?(pt.id) rescue false
42
42
  end
43
43
 
44
- can :categories, PostType do |pt|
44
+ can :categories, CamaleonCms::PostType do |pt|
45
45
  @roles_post_type[:manage_categories].to_i.include?(pt.id) rescue false
46
46
  end
47
- can :post_tags, PostType do |pt|
47
+ can :post_tags, CamaleonCms::PostType do |pt|
48
48
  @roles_post_type[:manage_tags].to_i.include?(pt.id) rescue false
49
49
  end
50
50
 
51
- can :update, Post do |post|
51
+ can :update, CamaleonCms::Post do |post|
52
52
  pt_id = post.post_type.id
53
53
  r = false
54
54
  r ||= (ids_edit).to_i.include?(pt_id) && post.user_id == user.id rescue false
55
- r ||= (ids_edit_publish ).to_i.include?(pt_id) && post.published? rescue false
56
- r ||= (ids_edit_other).to_i.include?(pt_id) && post.user_id != user.id rescue false
55
+ r ||= (ids_edit_publish).to_i.include?(pt_id) && post.published? rescue false
56
+ r ||= (ids_edit_other).to_i.include?(pt_id) && post.user_id != user.id rescue false
57
57
  r
58
58
  end
59
59
 
60
- can :destroy, Post do |post|
60
+ can :destroy, CamaleonCms::Post do |post|
61
61
  pt_id = post.post_type.id
62
62
  r = false
63
63
  r ||= (ids_delete).to_i.include?(pt_id) && post.user_id == user.id rescue false
@@ -67,7 +67,6 @@ class CamaleonCms::Ability
67
67
  end
68
68
 
69
69
 
70
-
71
70
  #others
72
71
  can :manage, :media if @roles_manager[:media] rescue false
73
72
  can :manage, :comments if @roles_manager[:comments] rescue false
@@ -83,8 +82,6 @@ class CamaleonCms::Ability
83
82
  end
84
83
 
85
84
 
86
-
87
-
88
85
  # variants:
89
86
 
90
87
  # can [:update, :destroy], [Article, Comment]
@@ -105,8 +102,6 @@ class CamaleonCms::Ability
105
102
  # end
106
103
 
107
104
 
108
-
109
-
110
105
  # See the wiki for details:
111
106
  # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
112
107
  end