camaleon_cms 1.0.8 → 1.0.9

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.

Potentially problematic release.


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

Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -1
  3. data/app/apps/plugins/contact_form/admin_forms_controller.rb +0 -9
  4. data/app/apps/plugins/contact_form/contact_form_helper.rb +94 -3
  5. data/app/apps/plugins/contact_form/front_controller.rb +2 -68
  6. data/app/apps/plugins/front_cache/front_cache_helper.rb +6 -2
  7. data/app/controllers/admin/appearances/widgets/assign_controller.rb +3 -3
  8. data/app/controllers/admin/appearances/widgets/sidebar_controller.rb +5 -5
  9. data/app/controllers/admin/sessions_controller.rb +1 -1
  10. data/app/controllers/api/api_controller.rb +13 -7
  11. data/app/controllers/api/v1/category_controller.rb +9 -1
  12. data/app/controllers/api/v1/contact_form_controller.rb +55 -0
  13. data/app/controllers/camaleon_controller.rb +10 -3
  14. data/app/helpers/session_helper.rb +2 -2
  15. data/app/helpers/theme_helper.rb +12 -0
  16. data/app/serializers/api/base_serializer.rb +9 -0
  17. data/app/serializers/api/v1/category_serializer.rb +8 -0
  18. data/app/views/admin/settings/custom_fields/get_items.html.erb +4 -2
  19. data/app/views/default_theme/layouts/index.html.erb +1 -1
  20. data/config/initializers/swagger.rb +18 -0
  21. data/config/locales/admin/en.yml +12 -2
  22. data/config/locales/languages.yml +14 -0
  23. data/config/locales/ru.yml +207 -0
  24. data/config/routes.rb +5 -0
  25. data/config/routes/admin.rb +2 -0
  26. data/lib/camaleon_cms/engine.rb +5 -0
  27. data/lib/camaleon_cms/version.rb +1 -1
  28. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +23 -23
  29. data/lib/generators/ctheme_template/app/apps/themes/my_theme/views/layouts/index.html.erb +1 -1
  30. data/lib/tasks/precompile_overrides.rake +6 -0
  31. data/public/docs/index.html +70 -0
  32. data/public/docs/swagger-ui/css/highlight.default.css +135 -0
  33. data/public/docs/swagger-ui/css/screen.css +1070 -0
  34. data/public/docs/swagger-ui/images/logo_small.png +0 -0
  35. data/public/docs/swagger-ui/images/throbber.gif +0 -0
  36. data/public/docs/swagger-ui/lib/backbone-min.js +38 -0
  37. data/public/docs/swagger-ui/lib/handlebars-1.0.0.js +2278 -0
  38. data/public/docs/swagger-ui/lib/highlight.7.3.pack.js +1 -0
  39. data/public/docs/swagger-ui/lib/jquery-1.8.0.min.js +2 -0
  40. data/public/docs/swagger-ui/lib/jquery.ba-bbq.min.js +18 -0
  41. data/public/docs/swagger-ui/lib/jquery.slideto.min.js +1 -0
  42. data/public/docs/swagger-ui/lib/jquery.wiggle.min.js +8 -0
  43. data/public/docs/swagger-ui/lib/shred.bundle.js +2765 -0
  44. data/public/docs/swagger-ui/lib/shred/content.js +193 -0
  45. data/public/docs/swagger-ui/lib/swagger.js +1253 -0
  46. data/public/docs/swagger-ui/lib/underscore-min.js +32 -0
  47. data/public/docs/swagger-ui/swagger-ui.js +2039 -0
  48. data/public/docs/swagger-ui/swagger-ui.min.js +1 -0
  49. metadata +56 -11
  50. data/app/views/admin/settings/shortcodes.html.erb +0 -37
  51. data/lib/generators/camaleon_cms/gem_theme_generator.rb +0 -122
  52. data/test/camaleon_cms_test.rb +0 -7
  53. data/test/integration/navigation_test.rb +0 -10
  54. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e67f1be72288c728d249247f0dfe7f6caea78f3
4
- data.tar.gz: 75092f52ee20f970a60b5f3fccd28905d1d21304
3
+ metadata.gz: d119a0fad758a8ad11ba5cc42dd42942896862ee
4
+ data.tar.gz: f7b2d4e99f044d16c5e9972f639c1bb5e9765813
5
5
  SHA512:
6
- metadata.gz: a20628ee74729584fccc227a9c1c1c80748449a9ddfa780ad21c9ec7328efd507e6da8150895dd4fe28689fe3a4ccdea49acee34133aa27514e6d61dd74b12ce
7
- data.tar.gz: 5265b4b7ebeed15f0c1f35e99f961560dfcc29c9bf73b67c9275269f248019fa7030a7cc39b15dfe00ffca48cdecb0be7a130bb701a49a0188abebc9c592728b
6
+ metadata.gz: dc0fd94340d4eb4cd7d9cf9ab4e2b0b001376b36e958885d43101e4511b4888618938aedb856bf76d8edd582d8ebe6d9cb74e27e41d14cc8e7a9cc546a9afc01
7
+ data.tar.gz: ca5f44b3daa47f296d66462ff143c4e69e4b3ad76ab49d770a78e682d865016b9deb8315748683a3483da75a56b0679a6c43adf6dac80126b736978b71466266
data/README.md CHANGED
@@ -180,4 +180,18 @@ http://camaleon.tuzitio.com/license.html/
180
180
  Visit the web site for more information: http://camaleon.tuzitio.com/
181
181
 
182
182
  ## Version History
183
- http://camaleon.tuzitio.com/version-history.html
183
+ * Version 1.0.8
184
+ - Fix logo size on admin panel
185
+ - Fixed: Raise error when visiting unexisting urls. Example: Random troll writes domain.com/asdasdasd/adfasdasd.
186
+ - Allow email domains up to 10 characters in the contact form plugin
187
+ - Added advanced shortcodes to print data in any content:Permit to generate specific data of a post. (see more details in link below)
188
+ - fixed vertical scroll for multiple modals- added a library to create inline field to upload fields.
189
+ - Added control to clean cache after restart server.
190
+ - Added hook to include custom links from plugins or themes.
191
+ - changed custom sitemap into hash.
192
+ - added sitemap skippers to filter private elements.
193
+ - fixed the_breadcrumb for current_site.
194
+ - Unify current_user removing current_resource_owner. Solved bug with login_user_with_password.
195
+ - Added generic API response methods, render_json_error & render_json_ok.
196
+
197
+ See more here: http://camaleon.tuzitio.com/version-history.html
@@ -71,15 +71,6 @@ class Plugins::ContactForm::AdminFormsController < Apps::PluginsAdminController
71
71
 
72
72
  end
73
73
 
74
- def fix_meta_value(value)
75
- if (value.is_a?(Array) || value.is_a?(Hash))
76
- value = value.to_json
77
- elsif value.is_a?(String)
78
- value = value.to_var
79
- end
80
- value
81
- end
82
-
83
74
  # here add your custom functions
84
75
  private
85
76
  def set_form
@@ -74,15 +74,106 @@ module Plugins::ContactForm::ContactFormHelper
74
74
  end
75
75
 
76
76
  def contact_form_admin_before_load
77
- admin_menu_append_menu_item("settings", {icon: "envelope-o", title: t('plugin.contact_form.contact_form'), url: admin_plugins_contact_form_admin_forms_path, datas: "data-intro='This plugin permit you to create you contact forms with desired fields and paste your short_code in any content.' data-position='right'"})
77
+ admin_menu_append_menu_item("settings", {icon: "envelope-o", title: t('plugin.contact_form.contact_form'), url: admin_plugins_contact_form_admin_forms_path, datas: "data-intro='This plugin permit you to create you contact forms with desired fields and paste your short_code in any content.' data-position='right'"})
78
78
  end
79
79
 
80
80
  def contact_form_app_before_load
81
- shortcode_add('forms', plugin_view("contact_form", "forms_shorcode"), "This is a shortocode for contact form to permit you to put your contact form in any content.
81
+ shortcode_add('forms', plugin_view("contact_form", "forms_shorcode"), "This is a shortocode for contact form to permit you to put your contact form in any content.
82
82
  Sample: [forms slug='key-for-my-form']")
83
83
  end
84
84
 
85
85
  def contact_form_front_before_load
86
- append_asset_libraries({"plugin_contact_form"=> { css: [plugin_asset_path("contact_form", "css/front/railsform")] }})
86
+ append_asset_libraries({"plugin_contact_form" => {css: [plugin_asset_path("contact_form", "css/front/railsform")]}})
87
+ end
88
+
89
+ def perform_save_form(form, values, fields, settings, success, errors)
90
+ attachments = []
91
+ if validate_to_save_form(values, fields, settings, errors)
92
+ values[:fields].each do |f|
93
+ cid = f[:cid].to_sym
94
+ if f[:field_type] == 'file'
95
+ res = upload_file(fields[cid], {maximum: 5.megabytes, folder: current_site.upload_directory("uploads")})
96
+ if res[:error].present?
97
+ errors << res[:error]
98
+ else
99
+ attachments << res['file']
100
+ end
101
+ end
102
+ end
103
+
104
+ new_settings = {"fields" => fields, "created_at" => Time.now.strftime("%Y-%m-%d %H:%M:%S").to_s}.to_json
105
+ form_new = current_site.contact_forms.new(name: "response-#{Time.now}", description: form.description, settings: fix_meta_value(new_settings), site_id: form.site_id, parent_id: form.id)
106
+
107
+ if form_new.save
108
+ begin
109
+ content = render_to_string partial: 'contact_form/submission',
110
+ layout: false,
111
+ locals: {
112
+ file_attachments: attachments,
113
+ fields: convert_form_values(
114
+ values[:fields],
115
+ fields
116
+ )
117
+ }
118
+ rescue ActionView::MissingTemplate
119
+ content = render_to_string partial: 'contact_form/views/contact_form/submission',
120
+ layout: false,
121
+ locals: {
122
+ file_attachments: attachments,
123
+ fields: convert_form_values(
124
+ values[:fields],
125
+ fields
126
+ )
127
+ }
128
+ end
129
+
130
+ sendmail(
131
+ settings[:railscf_mail][:to], settings[:railscf_mail][:subject],
132
+ content,
133
+ settings[:railscf_mail][:to],
134
+ attachments
135
+ )
136
+ success << settings[:railscf_message][:mail_sent_ok]
137
+ else
138
+ errors << settings[:railscf_message][:mail_sent_ng]
139
+ end
140
+ end
141
+ end
142
+
143
+ def validate_to_save_form(values, fields, settings, errors)
144
+ validate = true
145
+ values[:fields].each do |f|
146
+ cid = f[:cid].to_sym
147
+ label = f[:label].to_sym
148
+
149
+ case f[:field_type].to_s
150
+ when 'text', 'website', 'paragraph', 'textarea', 'email', 'radio', 'checkboxes', 'dropdown', 'file'
151
+ if f[:required] && !fields[cid].present?
152
+ errors << "#{label}: #{settings[:railscf_message][:invalid_required]}"
153
+ validate = false
154
+ end
155
+ if f[:field_type].to_s == "email"
156
+ if !fields[cid].match(/\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,10}\z/)
157
+ errors << "#{label}: #{settings[:railscf_message][:invalid_email]}"
158
+ validate = false
159
+ end
160
+ end
161
+ when 'captcha'
162
+ unless captcha_verified?
163
+ errors << "#{label}: #{settings[:railscf_message][:captcha_not_match]}"
164
+ validate = false
165
+ end
166
+ end
167
+ end
168
+ validate
169
+ end
170
+
171
+ def fix_meta_value(value)
172
+ if (value.is_a?(Array) || value.is_a?(Hash))
173
+ value = value.to_json
174
+ elsif value.is_a?(String)
175
+ value = value.to_var
176
+ end
177
+ value
87
178
  end
88
179
  end
@@ -19,76 +19,10 @@ class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
19
19
  values = JSON.parse(@form.value).to_sym
20
20
  settings = JSON.parse(@form.settings).to_sym
21
21
  fields = params[:fields]
22
- attachments = []
23
-
24
22
  errors = []
25
23
  success = []
26
24
 
27
- validate = true
28
-
29
- values[:fields].each do |f|
30
- cid = f[:cid].to_sym
31
- label = f[:label].to_sym
32
-
33
- case f[:field_type].to_s
34
- when 'text', 'website', 'paragraph', 'textarea', 'email', 'radio', 'checkboxes', 'dropdown', 'file'
35
- if f[:required] && !fields[cid].present?
36
- errors << "#{label}: #{settings[:railscf_message][:invalid_required]}"
37
- validate = false
38
- end
39
- if f[:field_type].to_s == "email"
40
- if !fields[cid].match(/\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,10}\z/)
41
- errors << "#{label}: #{settings[:railscf_message][:invalid_email]}"
42
- validate = false
43
- end
44
- end
45
- when 'captcha'
46
- unless captcha_verified?
47
- errors << "#{label}: #{settings[:railscf_message][:captcha_not_match]}"
48
- validate = false
49
- end
50
- end
51
- end
52
-
53
- if validate
54
- values[:fields].each do |f|
55
- cid = f[:cid].to_sym
56
- if f[:field_type] == 'file'
57
- res = upload_file(fields[cid], {maximum: 5.megabytes, folder: current_site.upload_directory("uploads")})
58
- if res[:error].present?
59
- errors << res[:error]
60
- else
61
- attachments << res['file']
62
- end
63
- end
64
- end
65
-
66
- new_settings = {"fields" => fields, "created_at" => Time.now.strftime("%Y-%m-%d %H:%M:%S").to_s}.to_json
67
- @form_new = current_site.contact_forms.new(name: "response-#{Time.now}", description: @form.description, settings:fix_meta_value(new_settings), site_id: @form.site_id, parent_id: @form.id)
68
-
69
- if @form_new.save
70
- content = render_to_string partial: 'contact_form/submission',
71
- layout: false,
72
- locals: {
73
- file_attachments: attachments,
74
- fields: convert_form_values(
75
- values[:fields],
76
- fields
77
- )
78
- }
79
- # send mail
80
- sendmail(
81
- settings[:railscf_mail][:to], settings[:railscf_mail][:subject],
82
- content,
83
- settings[:railscf_mail][:to],
84
- attachments
85
- )
86
- success << settings[:railscf_message][:mail_sent_ok]
87
- else
88
- errors << settings[:railscf_message][:mail_sent_ng]
89
- end
90
- end
91
-
25
+ perform_save_form(@form, values, fields, settings, success, errors)
92
26
  if success.present?
93
27
  flash[:notice] = success.join('<br>')
94
28
  else
@@ -113,4 +47,4 @@ class Plugins::ContactForm::FrontController < Apps::PluginsFrontController
113
47
  end
114
48
  value
115
49
  end
116
- end
50
+ end
@@ -139,8 +139,12 @@ module Plugins::FrontCache::FrontCacheHelper
139
139
 
140
140
  # clear all frontend cache files
141
141
  def front_cache_clean
142
- FileUtils.rm_f(cache_store.cache_path) # clear fragment caches
143
- FileUtils.rm_rf(File.join(ActionController::Base.page_cache_directory, current_site.id.to_s)) # clear site pages cache
142
+ # TODO replace with custom cache page
143
+ begin
144
+ FileUtils.rm_f(cache_store.cache_path) # clear fragment caches
145
+ FileUtils.rm_rf(File.join(ActionController::Base.page_cache_directory, current_site.id.to_s)) # clear site pages cache
146
+ rescue
147
+ end
144
148
  end
145
149
 
146
150
  private
@@ -20,9 +20,9 @@ class Admin::Appearances::Widgets::AssignController < Admin::AppearancesControll
20
20
  @assigned = @sidebar.assigned.find(params[:id])
21
21
  if @assigned.update(params[:assign])
22
22
  @assigned.set_field_values(params[:field_options])
23
- flash[:notice] = "Widget assign updated"
23
+ flash[:notice] = t('admin.widgets.assign.updated')
24
24
  else
25
- flash[:error] = "Widget assign not updated"
25
+ flash[:error] = t('admin.widgets.assign.error_updated')
26
26
  end
27
27
  redirect_to admin_appearances_widgets_main_index_path
28
28
  end
@@ -37,4 +37,4 @@ class Admin::Appearances::Widgets::AssignController < Admin::AppearancesControll
37
37
  authorize! :manager, :widgets
38
38
  end
39
39
 
40
- end
40
+ end
@@ -17,9 +17,9 @@ class Admin::Appearances::Widgets::SidebarController < Admin::AppearancesControl
17
17
  def create
18
18
  @sidebar = current_site.sidebars.new(params[:widget_sidebar])
19
19
  if @sidebar.save
20
- flash[:notice] = "Sidebar Create"
20
+ flash[:notice] = t('admin.widgets.sidebar.created')
21
21
  else
22
- flash[:error] = "No created sidebar"
22
+ flash[:error] = t('admin.widgets.sidebar.error_created')
23
23
  end
24
24
  redirect_to admin_appearances_widgets_main_index_path
25
25
  end
@@ -31,9 +31,9 @@ class Admin::Appearances::Widgets::SidebarController < Admin::AppearancesControl
31
31
 
32
32
  def update
33
33
  if current_site.sidebars.find(params[:id]).update(params[:widget_sidebar])
34
- flash[:notice] = "Sidebar Update"
34
+ flash[:notice] = t('admin.widgets.sidebar.updated')
35
35
  else
36
- flash[:error] = "No Update sidebar"
36
+ flash[:error] = t('admin.widgets.sidebar.error_updated')
37
37
  end
38
38
  redirect_to admin_appearances_widgets_main_index_path
39
39
  end
@@ -47,7 +47,7 @@ class Admin::Appearances::Widgets::SidebarController < Admin::AppearancesControl
47
47
 
48
48
  def destroy
49
49
  @sidebar = current_site.sidebars.find(params[:id]).destroy
50
- flash[:notice] = "Sidebar deleted."
50
+ flash[:notice] = t('admin.widgets.sidebar.error_deleted')
51
51
  redirect_to admin_appearances_widgets_main_index_path
52
52
  end
53
53
 
@@ -36,7 +36,7 @@ class Admin::SessionsController < CamaleonController
36
36
  if captcha_validate
37
37
  flash[:error] = t('admin.login.message.fail')
38
38
  else
39
- flash[:error] = "Invalid captcha"
39
+ flash[:error] = t('admin.login.message.invalid_caption')
40
40
  end
41
41
  @user = current_site.users.new(data_user)
42
42
  render 'admin/sessions/login'
@@ -1,17 +1,20 @@
1
1
  class Api::ApiController < CamaleonController
2
2
  #before_action -> { doorkeeper_authorize! :client }
3
-
4
3
  def account
5
4
  render json: current_user
6
5
  end
7
6
 
8
- def render_json_error(internal_message = 'Unexpected error', code = 100, status = 404, user_message = 'Unexpected error')
7
+ def render_json_error(error, status = 404)
8
+ render json: error, status: status
9
+ end
10
+
11
+ def render_json_error_message(internal_message = 'Unexpected error', code = 100, status = 404, user_message = 'Unexpected error')
9
12
  error = {
10
- 'userMessage': user_message,
11
- 'internalMessage': internal_message,
12
- 'code': code
13
+ userMessage: user_message,
14
+ internalMessage: internal_message,
15
+ code: code
13
16
  }
14
- render :json => error, :status => status
17
+ render_json_error(error, status)
15
18
  end
16
19
 
17
20
  def render_json_ok(message = 'Success', status = 200, more_info = {})
@@ -19,7 +22,10 @@ class Api::ApiController < CamaleonController
19
22
  message: message,
20
23
  more_info: more_info
21
24
  }
22
- render :json => msg, :status => status
25
+ render json: msg, status: status
23
26
  end
24
27
 
28
+ def render_json_not_found
29
+ render nothing: true, status: 404
30
+ end
25
31
  end
@@ -1,7 +1,15 @@
1
1
  class Api::V1::CategoryController < Api::ApiController
2
2
 
3
+ swagger_controller :categories, 'Categories'
4
+
5
+ swagger_api :categories do
6
+ summary 'Categories'
7
+ notes 'Notes...'
8
+ end
9
+
3
10
  def categories
4
- render json: current_site.full_categories
11
+ @categories = current_site.full_categories
12
+ render json: ActiveModel::ArraySerializer.new(@categories, each_serializer: Api::V1::CategorySerializer)
5
13
  end
6
14
 
7
15
  end
@@ -0,0 +1,55 @@
1
+ class Api::V1::ContactFormController < Api::ApiController
2
+ #TODO this controller must be into ContactForm plugin app
3
+ skip_before_filter :verify_authenticity_token
4
+
5
+ swagger_controller :contact_form, 'ContactForm'
6
+
7
+ swagger_api :contact_form_by_slug do
8
+ summary "Fetch a single Contact Form by slug"
9
+ param :path, :slug, :string, :required, 'Contact form slug'
10
+ response :ok, 'Success', :ContactForm
11
+ response :not_found
12
+ end
13
+
14
+ def contact_form_by_slug
15
+ form = current_site.contact_forms.where("parent_id is null and slug = '#{params[:slug]}'").first
16
+ if form.nil?
17
+ render_json_not_found
18
+ else
19
+ render json: {
20
+ :id => form.id,
21
+ :fields => JSON.parse(form.value).to_sym[:fields],
22
+ :settings => JSON.parse(form.settings).to_sym
23
+ }
24
+ end
25
+ end
26
+
27
+ swagger_api :save_form do
28
+ summary "Submit a contact form"
29
+ param :form, :id, :integer, :required, 'Contact form id'
30
+ param :form, :fields, :array, :required, 'Fields'
31
+ response :ok, 'Success'
32
+ response :not_found
33
+ end
34
+
35
+ def save_form
36
+ form = current_site.contact_forms.find_by_id(params[:id])
37
+ unless form.nil?
38
+ values = JSON.parse(form.value).to_sym
39
+ settings = JSON.parse(form.settings).to_sym
40
+ fields = params[:fields]
41
+ errors = []
42
+ success = []
43
+
44
+ perform_save_form(form, values, fields, settings, success, errors)
45
+ if success.present?
46
+ render_json_ok(success.join('<br>'))
47
+ else
48
+ render_json_ok({:errors => :errors, :fields => fields})
49
+ end
50
+ else
51
+ render_json_not_found
52
+ end
53
+ end
54
+
55
+ end
@@ -49,9 +49,16 @@ class CamaleonController < ApplicationController
49
49
  # including all helpers (system, themes, plugins) for this site
50
50
  PluginRoutes.enabled_apps(current_site, current_theme.slug).each{|plugin| plugin_load_helpers(plugin) }
51
51
 
52
- # set default cache directory for current site
53
- cache_store.cache_path = File.join(cache_store.cache_path.split("site-#{current_site.id}").first, "site-#{current_site.id}")
54
- # Rails.cache.write("#{current_site.id}-#{Time.now}", 1)
52
+ # Set default cache file store directory for current site
53
+ # Sample: Rails.cache.write("#{current_site.id}-#{Time.now}", 1)
54
+ begin
55
+ cache_store.cache_path = File.join(cache_store.cache_path.split("site-#{current_site.id}").first, "site-#{current_site.id}")
56
+ rescue
57
+ # skip error for non cache file, sample: dalli
58
+ # you need to define your cache store settings by config file or using the hook "app_before_load"
59
+ # for multi site support you can use namespace: "site-#{current_site.id}"
60
+ end
61
+
55
62
 
56
63
  # initializing short codes
57
64
  shortcodes_init()