camaleon_cms 2.3.0 → 2.3.1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aea3fc38c77542245b78e190c1fc36c308d93ac9
4
- data.tar.gz: 4e853421eb68c3785366a6c7ea79e4d4861b0a0b
3
+ metadata.gz: a2f40510933459726d45c615dddb3a2aa08a521d
4
+ data.tar.gz: 06896255a7dcecc0039d86c00ab0114e5c1c5497
5
5
  SHA512:
6
- metadata.gz: c1da62e588391c9d34a686b96a6540f2948f2cb1c18149a104166fd34f9252b828a16c810f3ed1ae827dbee6979334ad60c579ec3434d11f8485a492ece3bb42
7
- data.tar.gz: 2b3bb4960bfb772e8568ce4737a04c7db629932a6e5099057d7b0139a47ca53531c4ed0117f24290826ca038f9102e273d80c594dea57c4a50917a5616f454e1
6
+ metadata.gz: 4ec69cc71b0c772c1e3d9446526c7c0b21aad890b54a661712a46acace58645d7a10897c30d07c4fc064517199e31bd5b8fc4c334f5f9aea599a46843b9c6ef4
7
+ data.tar.gz: 2c5d72957463034ea92ea4e976636589b1416cc88ff551328b94233f774678b9265f853f1a2274755d44cf32ac876ffcf9d3b155560358c910ec12a685a81640
data/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
  * Add the gem in your Gemfile
29
29
 
30
30
  ```
31
- gem "camaleon_cms", '>=2.3.0' # Stable versions 2.2.1, 2.1.2.0, 2.1.1.4, 2.1.1, 2.1.0
31
+ gem "camaleon_cms", '>=2.3.1' # Stable versions 2.2.1, 2.1.1, 2.1.0
32
32
  # gem "camaleon_cms", github: 'owen2345/camaleon-cms' # current development version
33
33
  ```
34
34
  * Only Rails 5 support
@@ -17,7 +17,7 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
17
17
  end
18
18
 
19
19
  def login_post
20
- data_user = params[:user]
20
+ data_user = user_permit_data
21
21
  cipher = Gibberish::AES::CBC.new(cama_get_session_id)
22
22
  data_user[:password] = cipher.decrypt(data_user[:password]) rescue nil
23
23
  @user = current_site.users.find_by_username(data_user[:username])
@@ -84,7 +84,7 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
84
84
  # TODO: Move this out of the controller
85
85
  # send email reset password
86
86
  if params[:user].present?
87
- data_user = params[:user]
87
+ data_user = user_permit_data
88
88
  @user = current_site.users.find_by_email(data_user[:email])
89
89
  if @user.present?
90
90
  send_password_reset_email(@user)
@@ -103,7 +103,7 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
103
103
  if params[:user].present?
104
104
  params[:user][:role] = PluginRoutes.system_info["default_user_role"]
105
105
  params[:user][:is_valid_email] = false if current_site.need_validate_email?
106
- user_data = params.require(:user).permit!
106
+ user_data = user_permit_data
107
107
  result = cama_register_user(user_data, params[:meta])
108
108
  if result[:result] == false && result[:type] == :captcha_error
109
109
  @user.errors[:captcha] = t('camaleon_cms.admin.users.message.error_captcha')
@@ -158,4 +158,8 @@ class CamaleonCms::Admin::SessionsController < CamaleonCms::CamaleonController
158
158
  end
159
159
  end
160
160
 
161
+ def user_permit_data
162
+ params.require(:user).permit!
163
+ end
164
+
161
165
  end
@@ -16,8 +16,8 @@ class CamaleonCms::Admin::SettingsController < CamaleonCms::AdminController
16
16
  def site_saved
17
17
  @site = current_site
18
18
  if @site.update(params.require(:site).permit!)
19
- @site.set_options(params[:meta]) if params[:meta].present?
20
- @site.set_multiple_options(params[:options])
19
+ @site.set_options(params[:options]) if params[:options].present?
20
+ @site.set_metas(params[:metas]) if params[:metas].present?
21
21
  @site.set_field_values(params[:field_options])
22
22
  flash[:notice] = t('camaleon_cms.admin.settings.message.site_updated')
23
23
  redirect_to action: :site
@@ -46,6 +46,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
46
46
  rescue
47
47
  return page_not_found
48
48
  end
49
+ @object = @post_type
49
50
  @cama_visited_post_type = @post_type
50
51
  @posts = @post_type.the_posts.paginate(:page => params[:page], :per_page => current_site.front_per_page).eager_load(:metas)
51
52
  @categories = @post_type.categories.no_empty.eager_load(:metas).decorate
@@ -68,6 +69,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
68
69
  rescue
69
70
  return page_not_found
70
71
  end
72
+ @object = @post_tag
71
73
  @cama_visited_tag = @post_tag
72
74
  @posts = @post_tag.the_posts.paginate(:page => params[:page], :per_page => current_site.front_per_page).eager_load(:metas)
73
75
  r_file = lookup_context.template_exists?("post_types/#{@post_type.the_slug}/post_tag") ? "post_types/#{@post_type.the_slug}/post_tag" : 'post_tag'
@@ -119,6 +121,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
119
121
  rescue
120
122
  return page_not_found
121
123
  end
124
+ @object = @user
122
125
  @cama_visited_profile = true
123
126
  layout_ = lookup_context.template_exists?("layouts/profile") ? "profile" : nil
124
127
  r = {user: @user, layout: layout_, render: "profile"}; hooks_run("on_render_profile", r)
@@ -129,6 +132,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
129
132
  # render a post from draft
130
133
  def draft_render
131
134
  post_draft = current_site.posts.drafts.find(params[:draft_id])
135
+ @object = post_draft
132
136
  if can?(:update, post_draft)
133
137
  render_post(post_draft)
134
138
  else
@@ -156,6 +160,7 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
156
160
  end
157
161
  else
158
162
  @post = @post.decorate
163
+ @object = @post
159
164
  @cama_visited_post = @post
160
165
  @post_type = @post.the_post_type
161
166
  @comments = @post.the_comments
@@ -2,6 +2,7 @@ module CamaleonCms::Frontend::ApplicationHelper
2
2
  include CamaleonCms::Frontend::SiteHelper
3
3
  include CamaleonCms::Frontend::NavMenuHelper
4
4
  include CamaleonCms::Frontend::SeoHelper
5
+ include CamaleonCms::Frontend::ContentSelectHelper
5
6
 
6
7
  # add where conditionals to filter private/hidden/expired/drafts/unpublished
7
8
  # note: only for post records
@@ -0,0 +1,161 @@
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
+ module CamaleonCms::Frontend::ContentSelectHelper
10
+
11
+ # select single post of post type
12
+ # the_post_type('post') do
13
+ # the_post('first-blog-post')
14
+ # end
15
+ def the_post(slug)
16
+ post = @object.the_post(slug)
17
+ process_in_block(post) do
18
+ yield(post) if block_given?
19
+ end
20
+ post
21
+ end
22
+
23
+ # select posts of post type
24
+ # the_post_type('post') do
25
+ # the_posts
26
+ # end
27
+ #
28
+ # the_post_type('post') do
29
+ # the_posts(limit: 10)
30
+ # end
31
+ def the_posts(options={})
32
+ @object.posts.visible_frontend.limit(options[:limit]).decorate
33
+ end
34
+
35
+ # select post type by just pass slug to parameter
36
+ # Example:
37
+ # the_post_type('post')
38
+ # the_post_type('page')
39
+ #
40
+ # the_post_type('post') do
41
+ # the_post('first-blog')
42
+ # end
43
+ def the_post_type(slug)
44
+ post_type = current_site.the_post_type(slug)
45
+ process_in_block(post_type) do
46
+ yield(post_type) if block_given?
47
+ end
48
+ post_type
49
+ end
50
+
51
+ # select comments of post
52
+ # the_post('blog')
53
+ # the_comments
54
+ # end
55
+ def the_comments(options={})
56
+ @object.comments.limit(options[:limit]).decorate if @object.present?
57
+ end
58
+
59
+ # select title of post
60
+ # the_post('blog') do
61
+ # the_title
62
+ # end
63
+ def the_title
64
+ @object.the_title if @object.present?
65
+ end
66
+
67
+ # select content of post
68
+ # the_post('blog') do
69
+ # the_content
70
+ # end
71
+ def the_content
72
+ @object.the_content.html_safe if @object.present?
73
+ end
74
+
75
+ # select url of post
76
+ # the_post('blog') do
77
+ # the_url
78
+ # end
79
+ def the_url
80
+ @object.the_url if @object.present?
81
+ end
82
+
83
+ # select thumbnail of post
84
+ # the_post('blog') do
85
+ # the_thumbnail
86
+ # end
87
+ def the_thumbnail
88
+ @object.the_thumb_url if @object.present?
89
+ end
90
+
91
+ # select slug of post, post type ... (@object)
92
+ # the_post('blog') do
93
+ # the_slug
94
+ # end
95
+ def the_slug
96
+ @object.the_slug if @object.present?
97
+ end
98
+
99
+ # select excerpt of post
100
+ # the_post('blog') do
101
+ # the_excerpt
102
+ # end
103
+ def the_excerpt(chars=200)
104
+ @object.the_excerpt(chars) if @object.present?
105
+ end
106
+
107
+ # select custome field from object
108
+ # the_post('blog') do
109
+ # the_field('extra-content')
110
+ # end
111
+ def the_field(slug)
112
+ @object.the_field(slug) if @object.present?
113
+ end
114
+
115
+ # loop through each post of post type
116
+ # each_post_of('post') do
117
+ # the_title
118
+ # end
119
+ #
120
+ # each_post_of('post', limit: 10) do
121
+ # the_title
122
+ # end
123
+ def each_post_of(post_type_slug, options={})
124
+ the_post_type(post_type_slug) do
125
+ the_posts(options).each do |post|
126
+ process_in_block(post) do
127
+ yield(post) if block_given?
128
+ end
129
+ end
130
+ end
131
+ end
132
+
133
+ # loop through each category of post type
134
+ # each_category_of('post') do
135
+ # the_title
136
+ # end
137
+ #
138
+ # each_category_of('post', limit: 4) do
139
+ # the_title
140
+ # end
141
+ def each_category_of(post_type_slug, options={})
142
+ the_post_type(post_type_slug) do
143
+ the_categories(options).each do |category|
144
+ process_in_block(category) do
145
+ yield(category) if block_given?
146
+ end
147
+ end
148
+ end
149
+ end
150
+
151
+ # allow object to be global varaible in block
152
+ # work_in_block_of(post) do
153
+ # the_field('extra-content')
154
+ # end
155
+ def process_in_block(object)
156
+ temp_object = @object
157
+ @object = object
158
+ yield
159
+ @object = temp_object
160
+ end
161
+ end
@@ -80,7 +80,7 @@ module CamaleonCms::Metas extend ActiveSupport::Concern
80
80
  def set_options(h = {}, meta_key = "_default")
81
81
  if h.present?
82
82
  data = options(meta_key)
83
- (h.is_a?(ActionController::Parameters) ? h.to_h: h).to_sym.each do |key, value|
83
+ (h.is_a?(ActionController::Parameters) ? h.to_hash : h).to_sym.each do |key, value|
84
84
  data[key] = fix_meta_var(value)
85
85
  end
86
86
  set_meta(meta_key, data)
@@ -4,7 +4,7 @@
4
4
  <div class="panel-body ">
5
5
  <div class="row">
6
6
  <% if @post.draft? && !@post.parent.present? %>
7
- <div class="col-md-12 input-submit"><%= f.submit "#{ (@post.new_record?) ? t('camaleon_cms.admin.page_title.create') : t('camaleon_cms.admin.button.update')}", class: "btn btn-success btn-lg btn-block", onclick: "$('#post_status').val('#{@post.get_option('draft_status')}')" %></div>
7
+ <div class="col-md-12 input-submit"><%= f.submit "#{ (@post.new_record?) ? t('camaleon_cms.admin.page_title.create') : t('camaleon_cms.admin.button.update')}", class: "btn btn-success btn-lg btn-block" %></div>
8
8
  <% elsif @post.draft? && @post.parent.present? %>
9
9
  <div class="col-md-12 input-submit"><%= f.submit "#{ t('camaleon_cms.admin.button.recover') }", class: "btn btn-success btn-lg btn-block", onclick: "$('#post_status').val('#{@post.get_option('draft_status')}')" %></div>
10
10
  <% else %>
@@ -40,7 +40,7 @@
40
40
  <label class=" control-label"><%= t('camaleon_cms.admin.post_type.published')%></label>
41
41
  <select id="post_status" name="post[status]" class="form-control select">
42
42
  <% if can? :publish_post, @post_type %>
43
- <option class="<%= 'hidden' if @post.draft? %>" value="published" <%= (@post[:status] == "published") ? "selected": "" %> ><%= t('camaleon_cms.admin.post_type.published')%></option>
43
+ <option class="" value="published" <%= (@post[:status] == "published") ? "selected": "" %> ><%= t('camaleon_cms.admin.post_type.published')%></option>
44
44
  <% end %>
45
45
  <option value="pending" <%= (@post[:status] == "pending") ? "selected": "" %>><%= t('camaleon_cms.admin.table.pending')%></option>
46
46
  <option value="draft" <%= (@post[:status] == "draft") ? "selected": "" %>><%= t('camaleon_cms.admin.table.draft')%></option>
@@ -46,7 +46,7 @@
46
46
  </div>
47
47
  <div class="form-group">
48
48
  <label for=""><%= t('camaleon_cms.admin.settings.allow_user_registration') %></label><br>
49
- <%= check_box :meta, :permit_create_account, {checked: @site.get_option('permit_create_account', false), class: "icheckbox0"}, "true", "" %>
49
+ <%= check_box :options, :permit_create_account, {checked: @site.get_option('permit_create_account', false), class: "icheckbox0"}, "true", "" %>
50
50
  </div>
51
51
  <div class="form-group">
52
52
  <label for=""><%= t('camaleon_cms.admin.settings.security.captcha_user_register') %></label><br>
@@ -1,3 +1,3 @@
1
1
  module CamaleonCms
2
- VERSION = '2.3.0'
2
+ VERSION = '2.3.1'
3
3
  end
data/lib/plugin_routes.rb CHANGED
@@ -95,6 +95,14 @@ class PluginRoutes
95
95
  cache_variable("statis_system_info", settings)
96
96
  end
97
97
  alias_method :system_info, :static_system_info
98
+
99
+ def isRails4?
100
+ Rails.version.to_s[0].to_i == 4
101
+ end
102
+
103
+ def isRails5?
104
+ Rails.version.to_s[0].to_i == 5
105
+ end
98
106
  end
99
107
 
100
108
  # reload routes
@@ -339,3 +347,28 @@ class PluginRoutes
339
347
  Gem.available?(name)
340
348
  end
341
349
  end
350
+
351
+ #********* fix missing helper method for breadcrumb on rails gem **********#
352
+ if PluginRoutes.isRails5?
353
+ module BreadcrumbsOnRails
354
+ module ActionController extend ActiveSupport::Concern
355
+ def self.included(base = nil, &block)
356
+ if base.nil?
357
+ @_included_block = block
358
+ else
359
+ super
360
+ end
361
+ end
362
+
363
+ included do |base|
364
+ extend ClassMethods
365
+ helper HelperMethods if respond_to? :helper
366
+ helper_method :add_breadcrumb, :breadcrumbs if respond_to? :helper_method
367
+
368
+ unless base.respond_to?(:before_action)
369
+ base.alias_method :before_action, :before_filter
370
+ end
371
+ end
372
+ end
373
+ end
374
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camaleon_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: draper
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
@@ -498,6 +498,7 @@ files:
498
498
  - app/helpers/camaleon_cms/content_helper.rb
499
499
  - app/helpers/camaleon_cms/email_helper.rb
500
500
  - app/helpers/camaleon_cms/frontend/application_helper.rb
501
+ - app/helpers/camaleon_cms/frontend/content_select_helper.rb
501
502
  - app/helpers/camaleon_cms/frontend/nav_menu_helper.rb
502
503
  - app/helpers/camaleon_cms/frontend/seo_helper.rb
503
504
  - app/helpers/camaleon_cms/frontend/site_helper.rb