camaleon_cms 2.4.5.7 → 2.4.5.8
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 +4 -4
- data/README.md +24 -26
- data/app/apps/plugins/visibility_post/visibility_post_helper.rb +1 -1
- data/app/assets/javascripts/camaleon_cms/admin/_post.js +14 -0
- data/app/assets/javascripts/camaleon_cms/admin/custom_fields_form.js +84 -61
- data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +8 -1
- data/app/controllers/camaleon_cms/admin/settings/custom_fields_controller.rb +14 -0
- data/app/controllers/camaleon_cms/frontend_controller.rb +3 -3
- data/app/decorators/camaleon_cms/site_decorator.rb +5 -4
- data/app/helpers/camaleon_cms/plugins_helper.rb +1 -0
- data/app/models/camaleon_cms/media.rb +1 -1
- data/app/models/camaleon_cms/post.rb +2 -2
- data/app/models/camaleon_cms/post_comment.rb +1 -1
- data/app/models/camaleon_cms/post_tag.rb +1 -1
- data/app/models/camaleon_cms/post_type.rb +1 -1
- data/app/models/camaleon_cms/term_taxonomy.rb +1 -1
- data/app/models/camaleon_cms/widget/main.rb +1 -1
- data/app/models/concerns/camaleon_cms/custom_fields_read.rb +23 -1
- data/app/models/concerns/camaleon_cms/user_methods.rb +2 -1
- data/app/views/camaleon_cms/admin/posts/_sidebar.html.erb +6 -1
- data/app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb +9 -3
- data/app/views/camaleon_cms/admin/settings/custom_fields/_render_category_simple.html.erb +25 -0
- data/app/views/camaleon_cms/admin/settings/custom_fields/form.html.erb +7 -0
- data/app/views/layouts/camaleon_cms/admin.html.erb +0 -1
- data/config/routes/admin.rb +1 -0
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/plugin_routes.rb +5 -0
- data/spec/dummy/config/application.rb +2 -2
- data/spec/factories/post.rb +44 -0
- data/spec/factories/post_type.rb +4 -12
- data/spec/factories/site.rb +13 -3
- data/spec/factories/user.rb +19 -0
- data/spec/features/admin/custom_fields_spec.rb +1 -0
- data/spec/features/frontend/pages_spec.rb +56 -6
- data/spec/models/post_spec.rb +29 -6
- metadata +26 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/support/custom_admin.html.erb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8976824a5f6bd62eb80d61020ac7beb62be9c42
|
4
|
+
data.tar.gz: 4703e813d777c89caa0b00fd6ae1b72677de7288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efaf8c70638bcc23e864e88341519a6065667d8c85ba324b2a23d8b8a9c2cd319256254d974a133993bffc9914006e63dfa6eaa92cf749273ff45135f1e44b8d
|
7
|
+
data.tar.gz: 62d294f76ddaf5cd089296e0be55db5eaa8eaecb0463ab7335705e82702e0eefc38fc131020b6c0673381790df991929c60915102124f290568703aba2b4fdc3
|
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
![](https://img.shields.io/badge/Rails-4%2B-green.svg)
|
2
|
-
![](https://img.shields.io/badge/Ruby-
|
1
|
+
![](https://img.shields.io/badge/Rails-4.2%2B-green.svg)
|
2
|
+
![](https://img.shields.io/badge/Ruby-2.2%2B-green.svg)
|
3
3
|
![](https://img.shields.io/badge/SQLITE-100%25-green.svg)
|
4
4
|
![](https://img.shields.io/badge/Mysql-100%25-green.svg)
|
5
5
|
![](https://img.shields.io/badge/Postgres-100%25-green.svg)
|
6
6
|
![](https://img.shields.io/badge/TDD-70%25-yellowgreen.svg)
|
7
7
|
![](https://img.shields.io/badge/DOCS-60%25-yellow.svg)
|
8
8
|
![](https://img.shields.io/badge/Support-Inmediate-green.svg)
|
9
|
+
[![Build Status](https://travis-ci.org/owen2345/camaleon-cms.svg?branch=master)](https://travis-ci.org/owen2345/camaleon-cms)
|
9
10
|
|
10
11
|
![](http://camaleon.tuzitio.com/media/132/logo2.png)
|
11
12
|
|
@@ -14,22 +15,19 @@
|
|
14
15
|
|
15
16
|
[Demonstration](http://camaleon.tuzitio.com/plugins/demo_manage/)
|
16
17
|
|
17
|
-
|
18
|
-
# Sponsor
|
19
|
-
|
20
|
-
[ButterCMS](https://buttercms.com/?utm_source=github&utm_medium=sponsorship-link&utm_campaign=camaleon) is an API-based CMS and blogging platform built for developers:
|
21
18
|
|
22
|
-
|
19
|
+
# Sponsor
|
23
20
|
|
21
|
+
[ButterCMS](https://buttercms.com/?utm_source=github&utm_medium=sponsorship-link&utm_campaign=camaleon) is an API-based CMS and blogging platform built for developers.
|
24
22
|
|
25
23
|
# Requirements
|
26
|
-
* Rails 4.
|
24
|
+
* Rails 4.2+
|
27
25
|
* MySQL 5+ or SQlite or PostgreSQL
|
28
|
-
* Ruby
|
26
|
+
* Ruby 2.2+
|
29
27
|
* Imagemagick
|
30
28
|
|
31
29
|
# Installation
|
32
|
-
* Install Ruby on Rails 4.
|
30
|
+
* Install Ruby on Rails 4.2+
|
33
31
|
[Visit here.](http://railsapps.github.io/installing-rails.html)
|
34
32
|
* Create your rails project
|
35
33
|
|
@@ -55,14 +53,14 @@
|
|
55
53
|
```
|
56
54
|
rails generate camaleon_cms:install
|
57
55
|
```
|
58
|
-
* (Optional) Before continue you can configure your
|
56
|
+
* (Optional) Before continue you can configure your CMS settings in (my_app/config/system.json), [here](config/system.json) you can see the full settings.
|
59
57
|
* Create database structure
|
60
58
|
```
|
61
59
|
rake camaleon_cms:generate_migrations
|
62
|
-
# before
|
60
|
+
# before running migrations you can customize copied migration files
|
63
61
|
rake db:migrate
|
64
62
|
```
|
65
|
-
|
63
|
+
|
66
64
|
* Start your server
|
67
65
|
|
68
66
|
```
|
@@ -73,7 +71,7 @@
|
|
73
71
|
|
74
72
|
# Camaleon CMS (It adapts to your needs)
|
75
73
|
|
76
|
-
Camaleon CMS is a dynamic and advanced content management system based on Ruby on Rails 4+ and Ruby
|
74
|
+
Camaleon CMS is a dynamic and advanced content management system based on Ruby on Rails 4.2+ and Ruby 2.2+. This CMS is an alternative to Wordpress for Ruby on Rails developers to manage advanced contents easily.
|
77
75
|
Camaleon CMS is a flexible manager where you can build your custom content structure without coding anything by custom fields and custom contents type.
|
78
76
|
|
79
77
|
To download or publish themes go to themes store:
|
@@ -83,13 +81,13 @@ To download or publish plugins go to plugins store:
|
|
83
81
|
http://camaleon.tuzitio.com/store/plugins
|
84
82
|
|
85
83
|
## Camaleon CMS is FREE and Open source
|
86
|
-
It was released on July, 2015 and tested previously with more than 20 projects by 6 months and on
|
84
|
+
It was released on July, 2015 and tested previously with more than 20 projects by 6 months and on August 22, 2015 was published as a gem.
|
87
85
|
|
88
86
|
![](screenshot.png)
|
89
87
|
|
90
88
|
## With Camaleon you can do:
|
91
89
|
* Multiples sites in the same installation
|
92
|
-
*
|
90
|
+
* Multi-language sites
|
93
91
|
* Design and create the architecture of your project without programming by dynamic contents and fields
|
94
92
|
* Extend or customize the functionalities by plugins
|
95
93
|
* Manage your content visualization by themes
|
@@ -100,12 +98,12 @@ It was released on July, 2015 and tested previously with more than 20 projects b
|
|
100
98
|
- Widgets
|
101
99
|
- Drag and Drop / Sortable / Multi level menus
|
102
100
|
- Templates/Layouts for pages
|
103
|
-
- Easy migration from
|
101
|
+
- Easy migration from Wordpress
|
104
102
|
|
105
103
|
## Some features are:
|
106
104
|
* Integrate into existent Ruby on Rails Projects
|
107
105
|
* Easy administration
|
108
|
-
Camaleon CMS
|
106
|
+
Camaleon CMS permits you to adapt the CMS to all your needs and not you adapt to the CMS.
|
109
107
|
I.E. you can create your custom architecture with all attributes that you need for each kind of content.
|
110
108
|
* Security
|
111
109
|
- Remote code execution
|
@@ -122,16 +120,16 @@ I.E. you can create your custom architecture with all attributes that you need f
|
|
122
120
|
- Customize your content visualization for Desktop, Mobile and Tablet
|
123
121
|
* SEO & HTML5
|
124
122
|
- Sitemap generations
|
125
|
-
- Seo
|
123
|
+
- Seo configuration
|
126
124
|
- Seo for social media
|
127
|
-
- All generated content is compatible with HTML5 and
|
125
|
+
- All generated content is compatible with HTML5 and Bootstrap 3
|
128
126
|
|
129
127
|
## Camaleon CMS come with basic and important plugins like:
|
130
|
-
*
|
131
|
-
* Visibility content
|
128
|
+
* E-commerce
|
129
|
+
* Visibility of content
|
132
130
|
* Web attack control
|
133
131
|
* Contact forms
|
134
|
-
*
|
132
|
+
* Content cache
|
135
133
|
* Content reorder
|
136
134
|
* many others [here.](https://github.com/owen2345/Camaleon-CMS-Sample)
|
137
135
|
|
@@ -146,7 +144,7 @@ If you need support, need some extra functionality or need plugins, please conta
|
|
146
144
|
* Email: owenperedo@gmail.com
|
147
145
|
* Skype: owen-2345
|
148
146
|
* Stack Overflow: Use "camaleon" as tag to ask questions related to this CMS (don't forget to include cms version + rails version).
|
149
|
-
*
|
147
|
+
* Gitter: https://gitter.im/camaleoncms/Lobby
|
150
148
|
|
151
149
|
|
152
150
|
## Author
|
@@ -170,7 +168,7 @@ RAILS_ENV=test bundle exec rake app:db:test:prepare
|
|
170
168
|
|
171
169
|
* Run testing
|
172
170
|
```
|
173
|
-
rspec
|
171
|
+
bundle exec rspec
|
174
172
|
```
|
175
173
|
|
176
174
|
## Contributing
|
@@ -178,7 +176,7 @@ rspec
|
|
178
176
|
* Create a branch (git checkout -b my_feature_branch)
|
179
177
|
* Commit your changes (git commit -am "Added a sweet feature")
|
180
178
|
* Push to the branch (git push origin my_feature_branch)
|
181
|
-
* Create a pull request from your branch into master (Please be sure to provide enough detail for us to
|
179
|
+
* Create a pull request from your branch into master (Please be sure to provide enough detail for us to understand what this change is doing)
|
182
180
|
|
183
181
|
Visit the web site for more information: http://camaleon.tuzitio.com/
|
184
182
|
|
@@ -29,7 +29,7 @@ module Plugins::VisibilityPost::VisibilityPostHelper
|
|
29
29
|
post = args[:post]
|
30
30
|
return args[:flag] = false if post.published_at.present? && post.published_at > Time.now
|
31
31
|
return if post.visibility != 'private'
|
32
|
-
args[:flag] = false unless signin? && post.visibility_value.split(",").include?(
|
32
|
+
args[:flag] = false unless signin? && post.visibility_value.split(",").include?(current_site.visitor_role)
|
33
33
|
end
|
34
34
|
|
35
35
|
def plugin_visibility_extra_columns(args)
|
@@ -236,6 +236,20 @@ function cama_init_post(obj) {
|
|
236
236
|
return false;
|
237
237
|
});
|
238
238
|
|
239
|
+
$form.on("change", ".list-categories input", function () {
|
240
|
+
showLoading();
|
241
|
+
$.get(
|
242
|
+
$form.find("#post_add_new_category").data('fields-reload-url'), {
|
243
|
+
categories: $form.find("#post_right_bar .list-categories input[name='categories[]']:checked").map(function(i, el){ return $(this).val(); }).get(),
|
244
|
+
post_id: post_id
|
245
|
+
},
|
246
|
+
function (res) {
|
247
|
+
$form.find('.c-field-group').remove();
|
248
|
+
$form.find('.panel .panel-default').after(res);
|
249
|
+
hideLoading();
|
250
|
+
});
|
251
|
+
});
|
252
|
+
|
239
253
|
// sidebar toggle
|
240
254
|
//$("#admin_content #post_right_bar-toggle").on("click", function () {
|
241
255
|
// $("#post_right_bar").is(":visible") ? $("#post_right_bar").hide() : $("#post_right_bar").show();
|
@@ -1,71 +1,94 @@
|
|
1
1
|
// add actions to assign custom fields to any model selected
|
2
2
|
jQuery(function($){
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
var panel = $("#cama_custom_field_form");
|
4
|
+
var group_class_name = panel.attr("data-group_class_name");
|
5
|
+
var $content_fields = $( "#sortable-fields", panel);
|
6
|
+
$content_fields.sortable({
|
7
|
+
handle: ".panel-sortable"
|
8
|
+
});
|
9
|
+
var slugger_count = $content_fields.children().length;
|
10
|
+
cama_custom_field_set_slug();
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
});
|
25
|
-
return false;
|
12
|
+
$("#content-items-default > a", panel).click(function(){
|
13
|
+
var href = $(this).attr('href');
|
14
|
+
showLoading();
|
15
|
+
$.post(href, function(html){
|
16
|
+
hideLoading();
|
17
|
+
var li = $('<li class="item">' + html + '</li>');
|
18
|
+
$content_fields.append(li);
|
19
|
+
cama_custom_field_set_slug(li);
|
20
|
+
var title_field = li.find("input.text-title");
|
21
|
+
title_field.val(title_field.val() + '-' + (slugger_count ++));
|
22
|
+
title_field.trigger("keyup");
|
23
|
+
$('[data-toggle="tooltip"], a[title!=""]', $content_fields).tooltip();
|
26
24
|
});
|
25
|
+
return false;
|
26
|
+
});
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
panel.on("click", ".panel-delete", function(){
|
29
|
+
var parent = $(this).parents(".item:first");
|
30
|
+
if(confirm(I18n("msg.delete_item"))){
|
31
|
+
parent.remove()
|
32
|
+
}
|
33
|
+
return false;
|
34
|
+
});
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
$('#select_assign_group', panel).change(function(){
|
37
|
+
var option = $(this).find('option:checked');
|
38
|
+
_change_additional_select(option);
|
39
|
+
var txt_help = option.data('help');
|
40
|
+
if(txt_help) txt_help = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' + txt_help + ' </div>';
|
41
|
+
$('#select_assign_group_help', panel).html(txt_help);
|
42
|
+
$('#select_assign_group_caption', panel).val(option.parent('optgroup').attr("label") + ' ' + option.text());
|
43
|
+
}).val(_search_group_class_name(group_class_name)).trigger('change');
|
44
|
+
|
45
|
+
$('#select_post_simple', panel).change(function(){
|
46
|
+
var option = $(this).find('option:checked');
|
47
|
+
var txt_help = option.data('help');
|
48
|
+
if(txt_help) txt_help = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' + txt_help + ' </div>';
|
49
|
+
$('#select_assign_group_help', panel).html(txt_help);
|
50
|
+
$('#select_assign_group_caption', panel).val(option.parent('optgroup').attr("label") + ': ' + option.text());
|
51
|
+
}).val(group_class_name).trigger('change');
|
48
52
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
$('#select_category_simple', panel).change(function(){
|
54
|
+
var option = $(this).find('option:checked');
|
55
|
+
var txt_help = option.data('help');
|
56
|
+
if(txt_help) txt_help = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' + txt_help + ' </div>';
|
57
|
+
$('#select_assign_group_help', panel).html(txt_help);
|
58
|
+
$('#select_assign_group_caption', panel).val(option.parent('optgroup').attr("label") + ': ' + option.text());
|
59
|
+
}).val(group_class_name).trigger('change');
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
);
|
68
|
-
$(this).addClass('runned')
|
69
|
-
});
|
61
|
+
function _change_additional_select(option){
|
62
|
+
var option_value = option.attr('value'),
|
63
|
+
additional_options = ['_post_simple', '_category_simple'];
|
64
|
+
|
65
|
+
for (key in additional_options) {
|
66
|
+
if (option_value === additional_options[key]){
|
67
|
+
$('#select'+additional_options[key], panel).show().removeAttr('disabled');
|
68
|
+
}else{
|
69
|
+
$('#select'+additional_options[key], panel).hide().attr('disabled','disabled');
|
70
|
+
}
|
70
71
|
}
|
72
|
+
}
|
73
|
+
|
74
|
+
function _search_group_class_name(group_class_name) {
|
75
|
+
if (group_class_name.search("Post,") == 0) group_class_name = '_post_simple';
|
76
|
+
if (group_class_name.search("Category_Post,") == 0) group_class_name = '_category_simple';
|
77
|
+
return group_class_name;
|
78
|
+
}
|
79
|
+
|
80
|
+
function cama_custom_field_set_slug(_panel){
|
81
|
+
$('.text-slug:not(.runned)', _panel || panel).each(function(){
|
82
|
+
var $parent = $(this).parents('.panel-item');
|
83
|
+
var $label = $parent.find('.span-title');
|
84
|
+
$(this).slugify($parent.find('.text-title'), {
|
85
|
+
slugFunc: function(str, originalFunc) {
|
86
|
+
$label.html(str);
|
87
|
+
return originalFunc(str);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
);
|
91
|
+
$(this).addClass('runned')
|
92
|
+
});
|
93
|
+
}
|
71
94
|
});
|
@@ -5,6 +5,11 @@ window["cama_init_media"] = (media_panel) ->
|
|
5
5
|
media_link_tab_upload = media_panel.find(".media_file_info_col .nav-tabs .link_media_upload")
|
6
6
|
|
7
7
|
################ visualize item
|
8
|
+
# loading last opened folder on current page
|
9
|
+
media_panel.ready ->
|
10
|
+
f = $('body').data('last-folder')
|
11
|
+
media_panel.trigger('navigate_to', {folder: f})
|
12
|
+
|
8
13
|
# return the data of this file
|
9
14
|
file_data = (item)->
|
10
15
|
data = item.data('eval-data') || eval("("+item.find(".data_value").val()+")")
|
@@ -128,7 +133,9 @@ window["cama_init_media"] = (media_panel) ->
|
|
128
133
|
f = media_panel.attr("data-folder")+"/"+$(this).attr("data-key")
|
129
134
|
if $(this).attr("data-key").search('/') >= 0
|
130
135
|
f = $(this).attr("data-key")
|
131
|
-
|
136
|
+
f = f.replace(/\/{2,}/g, '/')
|
137
|
+
media_panel.trigger("navigate_to", {folder: f})
|
138
|
+
$('body').attr('data-last-folder', f) # remembers last opened folder on current page
|
132
139
|
)
|
133
140
|
media_panel.bind("update_breadcrumb", ->
|
134
141
|
folder = media_panel.attr("data-folder").replace("//", "/")
|
@@ -63,6 +63,20 @@ class CamaleonCms::Admin::Settings::CustomFieldsController < CamaleonCms::Admin:
|
|
63
63
|
render json: json
|
64
64
|
end
|
65
65
|
|
66
|
+
def list
|
67
|
+
p = params.permit(:post_type, :post_id, :categories => [])
|
68
|
+
args = {}
|
69
|
+
if p[:post_id].present?
|
70
|
+
post = @current_site.the_post(p[:post_id].to_i)
|
71
|
+
post.update_categories(p[:categories])
|
72
|
+
else
|
73
|
+
post = CamaleonCms::Post.new
|
74
|
+
post.taxonomy_id = p[:post_type].to_i
|
75
|
+
args[:cat_ids] = p[:categories]
|
76
|
+
end
|
77
|
+
render partial: 'camaleon_cms/admin/settings/custom_fields/render', :locals => {record: post, field_groups: post.get_field_groups(args), show_shortcode: true}
|
78
|
+
end
|
79
|
+
|
66
80
|
private
|
67
81
|
|
68
82
|
def set_post_data
|
@@ -162,21 +162,21 @@ class CamaleonCms::FrontendController < CamaleonCms::CamaleonController
|
|
162
162
|
@post = post_or_slug_or_id
|
163
163
|
end
|
164
164
|
|
165
|
-
|
165
|
+
@post = @post.try(:decorate)
|
166
|
+
if !@post.present? || !@post.can_visit?
|
166
167
|
if params[:format] == 'html' || !params[:format].present?
|
167
168
|
page_not_found()
|
168
169
|
else
|
169
170
|
head 404
|
170
171
|
end
|
171
172
|
else
|
172
|
-
@post = @post.decorate
|
173
173
|
@object = @post
|
174
174
|
@cama_visited_post = @post
|
175
175
|
@post_type = @post.the_post_type
|
176
176
|
@comments = @post.the_comments
|
177
177
|
@categories = @post.the_categories
|
178
178
|
@post.increment_visits!
|
179
|
-
|
179
|
+
|
180
180
|
home_page = @_site_options[:home_page] rescue nil
|
181
181
|
if lookup_context.template_exists?("page_#{@post.id}")
|
182
182
|
r_file = "page_#{@post.id}"
|
@@ -112,17 +112,18 @@ class CamaleonCms::SiteDecorator < CamaleonCms::TermTaxonomyDecorator
|
|
112
112
|
# draw languages configured for this site
|
113
113
|
# list_class: (String) Custom css classes for ul list
|
114
114
|
# current_page: (boolean) true: link with translation to current url, false: link with translation to root url
|
115
|
-
|
115
|
+
# block permit to render custom link label, default: flag icon
|
116
|
+
def draw_languages(list_class = "language_list list-inline pull-right", current_page = false, current_class = "current_l", &block)
|
116
117
|
lan = object.get_languages
|
117
118
|
return if lan.size < 2
|
118
119
|
res = ["<ul class='#{list_class}'>"]
|
119
120
|
lan.each do |lang|
|
120
121
|
path = lang.to_s+'.png'
|
121
|
-
|
122
|
-
res << "<li class='#{ current_class if I18n.locale.to_s == lang.to_s}'> <a href='#{h.cama_url_to_fixed(current_page ? "url_for" : "cama_root_url", {locale: lang, cama_set_language: lang})}'>#{
|
122
|
+
label = (block ? h.capture(lang, I18n.locale.to_s == lang.to_s, &block) : "<img src='#{h.asset_path("camaleon_cms/language/#{path}")}'/>")
|
123
|
+
res << "<li class='#{ current_class if I18n.locale.to_s == lang.to_s}'> <a href='#{h.cama_url_to_fixed(current_page ? "url_for" : "cama_root_url", {locale: lang, cama_set_language: lang})}'>#{label}</a> </li>"
|
123
124
|
end
|
124
125
|
res << "</ul>"
|
125
|
-
res.join("")
|
126
|
+
res.join("").html_safe
|
126
127
|
end
|
127
128
|
|
128
129
|
# return Array of frontend languages configured for this site
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module CamaleonCms::PluginsHelper
|
2
|
+
include CamaleonCms::SiteHelper
|
2
3
|
# load all plugins + theme installed for current site
|
3
4
|
# METHOD IGNORED (is a partial solution to avoid load helpers and cache it for all sites)
|
4
5
|
# this method try to load helpers for each request without caching
|
@@ -42,7 +42,7 @@ class CamaleonCms::Media < ActiveRecord::Base
|
|
42
42
|
_p = []
|
43
43
|
folder_path.split('/').each do |f_name|
|
44
44
|
_path = ('/'+_p.join('/')).cama_fix_media_key
|
45
|
-
coll.only_folder.where(name: f_name, folder_path: _path).first_or_create
|
45
|
+
coll.only_folder.where(name: f_name, folder_path: _path).first_or_create() if "#{_path}/#{f_name}".cama_fix_media_key != '/'
|
46
46
|
_p.push(f_name)
|
47
47
|
end
|
48
48
|
end
|
@@ -43,7 +43,7 @@ class CamaleonCms::Post < CamaleonCms::PostDefault
|
|
43
43
|
has_many :drafts, ->{where(status: 'draft_child')}, class_name: "CamaleonCms::Post", foreign_key: :post_parent, dependent: :destroy
|
44
44
|
has_many :children, class_name: "CamaleonCms::Post", foreign_key: :post_parent, dependent: :destroy, primary_key: :id
|
45
45
|
|
46
|
-
belongs_to :owner, class_name:
|
46
|
+
belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
47
47
|
belongs_to :parent, class_name: "CamaleonCms::Post", foreign_key: :post_parent
|
48
48
|
belongs_to :post_type, class_name: "CamaleonCms::PostType", foreign_key: :taxonomy_id, inverse_of: :posts
|
49
49
|
|
@@ -245,7 +245,7 @@ class CamaleonCms::Post < CamaleonCms::PostDefault
|
|
245
245
|
end
|
246
246
|
|
247
247
|
# return the quantity of comments for this post
|
248
|
-
# TODO comments count
|
248
|
+
# TODO comments count to move into cache counter
|
249
249
|
def total_comments
|
250
250
|
self.get_meta("comments_count", 0).to_i
|
251
251
|
end
|
@@ -11,7 +11,7 @@ class CamaleonCms::PostComment < ActiveRecord::Base
|
|
11
11
|
has_many :children, class_name: "CamaleonCms::PostComment", foreign_key: :comment_parent, dependent: :destroy
|
12
12
|
belongs_to :post, class_name: "CamaleonCms::Post", foreign_key: :post_id
|
13
13
|
belongs_to :parent, class_name: "CamaleonCms::PostComment", foreign_key: :comment_parent
|
14
|
-
belongs_to :user, class_name:
|
14
|
+
belongs_to :user, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
15
15
|
|
16
16
|
default_scope {order("#{CamaleonCms::PostComment.table_name}.created_at DESC")}
|
17
17
|
|
@@ -3,5 +3,5 @@ class CamaleonCms::PostTag < CamaleonCms::TermTaxonomy
|
|
3
3
|
cama_define_common_relationships('PostTag')
|
4
4
|
has_many :posts, foreign_key: :objectid, through: :term_relationships, :source => :objects
|
5
5
|
belongs_to :post_type, class_name: "CamaleonCms::PostType", foreign_key: :parent_id, inverse_of: :post_tags
|
6
|
-
belongs_to :owner, class_name:
|
6
|
+
belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
7
7
|
end
|
@@ -10,7 +10,7 @@ class CamaleonCms::PostType < CamaleonCms::TermTaxonomy
|
|
10
10
|
has_many :posts_draft, class_name: "CamaleonCms::Post", foreign_key: :taxonomy_id, dependent: :destroy, source: :drafts, inverse_of: :post_type
|
11
11
|
has_many :field_group_taxonomy, -> {where("object_class LIKE ?","PostType_%")}, :class_name => "CamaleonCms::CustomField", foreign_key: :objectid, dependent: :destroy
|
12
12
|
|
13
|
-
belongs_to :owner, class_name:
|
13
|
+
belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
14
14
|
belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
|
15
15
|
|
16
16
|
scope :visible_menu, -> {where(term_group: nil)}
|
@@ -25,7 +25,7 @@ class CamaleonCms::TermTaxonomy < ActiveRecord::Base
|
|
25
25
|
has_many :term_relationships, :class_name => "CamaleonCms::TermRelationship", :foreign_key => :term_taxonomy_id, dependent: :destroy
|
26
26
|
# has_many :posts, foreign_key: :objectid, through: :term_relationships, :source => :objects
|
27
27
|
belongs_to :parent, class_name: "CamaleonCms::TermTaxonomy", foreign_key: :parent_id
|
28
|
-
belongs_to :owner, class_name:
|
28
|
+
belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
29
29
|
|
30
30
|
# return all children taxonomy
|
31
31
|
# sample: sub categories of a category
|
@@ -9,7 +9,7 @@ class CamaleonCms::Widget::Main < CamaleonCms::TermTaxonomy
|
|
9
9
|
# renderer: string (path to the template for render this widget)
|
10
10
|
|
11
11
|
has_many :metas, ->{ where(object_class: 'Widget::Main')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :destroy
|
12
|
-
belongs_to :owner, class_name:
|
12
|
+
belongs_to :owner, class_name: CamaManager.get_user_class_name, foreign_key: :user_id
|
13
13
|
belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
|
14
14
|
|
15
15
|
has_many :assigned, class_name: "CamaleonCms::Widget::Assigned", foreign_key: :visibility, dependent: :destroy
|
@@ -33,7 +33,19 @@ module CamaleonCms::CustomFieldsRead extend ActiveSupport::Concern
|
|
33
33
|
when 'Category','PostTag'
|
34
34
|
self.post_type.get_field_groups(class_name)
|
35
35
|
when 'Post'
|
36
|
-
|
36
|
+
if self.term_relationships.size.zero? && args[:cat_ids].nil?
|
37
|
+
CamaleonCms::CustomFieldGroup.where("(objectid = ? AND object_class = ?) OR (objectid = ? AND object_class = ?)", self.id || -1, class_name, self.post_type.id, "PostType_#{class_name}")
|
38
|
+
else
|
39
|
+
cat_ids = self.categories.map(&:id)
|
40
|
+
cat_ids += args[:cat_ids] unless args[:cat_ids].nil?
|
41
|
+
cat_ids += CamaleonCms::Category.find(cat_ids).map {|category| _category_parents_ids(category)}.flatten.uniq
|
42
|
+
CamaleonCms::CustomFieldGroup.where("(objectid = ? AND object_class = ?) OR
|
43
|
+
(objectid = ? AND object_class = ?) OR
|
44
|
+
(objectid IN (?) AND object_class = ?)",
|
45
|
+
self.id || -1, class_name,
|
46
|
+
self.post_type.id, "PostType_#{class_name}",
|
47
|
+
cat_ids, "Category_#{class_name}")
|
48
|
+
end
|
37
49
|
when 'NavMenuItem'
|
38
50
|
self.main_menu.custom_field_groups
|
39
51
|
when 'PostType'
|
@@ -285,4 +297,14 @@ module CamaleonCms::CustomFieldsRead extend ActiveSupport::Concern
|
|
285
297
|
self.site
|
286
298
|
end
|
287
299
|
end
|
300
|
+
|
301
|
+
def _category_parents_ids(category)
|
302
|
+
@parents ||= []
|
303
|
+
if category.parent.nil?
|
304
|
+
return @parents
|
305
|
+
else
|
306
|
+
@parents << category.parent.id
|
307
|
+
_category_parents_ids(category.parent)
|
308
|
+
end
|
309
|
+
end
|
288
310
|
end
|
@@ -15,7 +15,8 @@ module CamaleonCms::UserMethods extend ActiveSupport::Concern
|
|
15
15
|
# relations
|
16
16
|
cama_define_common_relationships('User')
|
17
17
|
has_many :all_posts, class_name: "CamaleonCms::Post", foreign_key: :user_id
|
18
|
-
has_many :all_comments, class_name:
|
18
|
+
has_many :all_comments, class_name: 'CamaleonCms::PostComment'
|
19
|
+
belongs_to :site, class_name: 'CamaleonCms::Site'
|
19
20
|
|
20
21
|
#scopes
|
21
22
|
scope :admin_scope, -> { where(:role => 'admin') }
|
@@ -90,7 +90,12 @@
|
|
90
90
|
<div class="panel-heading">
|
91
91
|
<h3 class="panel-title"><%= t('camaleon_cms.admin.post_type.categories')%> <em class="text-danger">*</em></h3>
|
92
92
|
<ul class="panel-controls">
|
93
|
-
<li><a id="post_add_new_category"
|
93
|
+
<li><a id="post_add_new_category"
|
94
|
+
data-reload-url="<%= list_cama_admin_post_type_categories_path(@post_type.id) %>"
|
95
|
+
data-fields-reload-url="<%= list_cama_admin_settings_custom_fields_path(post_type: @post_type.id) %>"
|
96
|
+
href="<%= cama_admin_post_type_categories_path(@post_type.id, cama_body_class: true) %>"
|
97
|
+
title="<%= t("camaleon_cms.admin.post.create_category", default: 'Create New Category') %>"
|
98
|
+
class="panel-add-category"><span class="fa fa-plus"></span></a></li>
|
94
99
|
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
|
95
100
|
</ul>
|
96
101
|
</div>
|
@@ -4,10 +4,11 @@
|
|
4
4
|
@item_id = @item_value[:id] || ''
|
5
5
|
@index = "#{@item_id}_#{Time.now.to_i}_#{rand(999...99999)}"
|
6
6
|
@field_config = cama_custom_field_elements[@key.to_sym]
|
7
|
+
@panel_id = "panel-field#{@index}"
|
7
8
|
colors = ['primary','success','warning','colorful','info','danger']
|
8
9
|
unless @field_config.nil?
|
9
10
|
%>
|
10
|
-
<div id="
|
11
|
+
<div id="<%= @panel_id %>" class="panel panel-default panel-<%= colors.sample %> panel-item <%= 'panel-toggled' if @item_options_value[:panel_hidden].to_s.to_bool %>">
|
11
12
|
<div class="panel-heading">
|
12
13
|
<h3 class="panel-title"><span class="span-title"><%= @item_value[:name]? @item_value[:name] : "#{t('camaleon_cms.admin.settings.untitled')}
|
13
14
|
#{@field_config[:label]}" %>
|
@@ -155,7 +156,7 @@
|
|
155
156
|
<% if @field_config[:options].key?(:default_value) %>
|
156
157
|
<div class="form-group input-group-sm">
|
157
158
|
<label><%= t('camaleon_cms.admin.table.default_value')%></label>
|
158
|
-
<%= text_field(:field_options, 'default_value', index: @index, value: @item_options_value[:default_value] || @field_config[:options][:default_value], class:
|
159
|
+
<%= text_field(:field_options, 'default_value', index: @index, value: @item_options_value[:default_value] || @field_config[:options][:default_value], class: "form-control #{'translatable' if @field_config[:options][:translate]}") %>
|
159
160
|
</div>
|
160
161
|
<% end %>
|
161
162
|
|
@@ -176,4 +177,9 @@
|
|
176
177
|
<% end %>
|
177
178
|
</div>
|
178
179
|
</div>
|
179
|
-
<% end %>
|
180
|
+
<% end %>
|
181
|
+
<script>
|
182
|
+
jQuery(function () {
|
183
|
+
$('#<%= @panel_id %>').find('.translatable').Translatable();
|
184
|
+
})
|
185
|
+
</script>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<%
|
2
|
+
def _render_category_option_html(item, pos = 0)
|
3
|
+
category = item.decorate
|
4
|
+
value = "Category_Post,#{category.id}" %>
|
5
|
+
<option value="<%= value %>" data-help="<%= "#{t('camaleon_cms.admin.settings.tooltip.add_custom_field_posts')}"+ category.the_title %>"><%= "#{('—' * pos)} #{category.the_title}" %></option>
|
6
|
+
<% end
|
7
|
+
|
8
|
+
def _render_categories(categories, _level = 0)
|
9
|
+
categories.each do |term|
|
10
|
+
_render_category_option_html(term, _level)
|
11
|
+
children = term.children
|
12
|
+
_render_categories(children, _level + 1) if children.size > 0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
%>
|
16
|
+
|
17
|
+
|
18
|
+
<select id="select_category_simple" name="custom_field_group[assign_group]" class="form-control required" style="display: none" disabled>
|
19
|
+
<% current_site.post_types.each do |pt| pt = pt.decorate
|
20
|
+
next unless pt.manage_categories? %>
|
21
|
+
<optgroup label="<%= pt.the_title %>">
|
22
|
+
<% _render_categories(pt.categories) %>
|
23
|
+
</optgroup>
|
24
|
+
<% end %>
|
25
|
+
</select>
|
@@ -91,7 +91,10 @@
|
|
91
91
|
<%# end %>
|
92
92
|
</optgroup -->
|
93
93
|
<option value="_post_simple" >Select Post Simple</option>
|
94
|
+
<option value="_category_simple" >Select Category Posts Simple</option>
|
94
95
|
</select>
|
96
|
+
|
97
|
+
<!-- select post -->
|
95
98
|
<select id="select_post_simple" name="custom_field_group[assign_group]" class="form-control required" style="display: none" disabled>
|
96
99
|
<% current_site.post_types.each do |pt| pt = pt.decorate %>
|
97
100
|
<optgroup label="<%= pt.the_title %>">
|
@@ -101,6 +104,10 @@
|
|
101
104
|
</optgroup>
|
102
105
|
<% end %>
|
103
106
|
</select>
|
107
|
+
|
108
|
+
<!-- select categories-->
|
109
|
+
<%= render partial: 'render_category_simple' %>
|
110
|
+
|
104
111
|
<input id="select_assign_group_caption" type="hidden" name="custom_field_group[caption]"/>
|
105
112
|
<div id="select_assign_group_help"></div>
|
106
113
|
</div>
|
@@ -16,7 +16,6 @@
|
|
16
16
|
var tinymce_global_settings = {language_url: "<%= asset_path("camaleon_cms/admin/tinymce/langs/#{current_locale}.js") %>", custom_css: [], custom_toolbar: [], post_render: [], init: [], setups: [], settings: []};
|
17
17
|
var I18n_data = <%= I18n.backend.respond_to?(:translations) ? I18n.backend.send(:translations)[current_locale.to_sym][:camaleon_cms][:admin][:js].to_json.html_safe : !!(I18n.backend.backends[1] && I18n.backend.backends[1].backends[1]) ? I18n.backend.backends[1].backends[1].send(:translations)[current_locale.to_sym][:camaleon_cms][:admin][:js].to_json.html_safe : "{}" rescue "{}" %>
|
18
18
|
</script>
|
19
|
-
<%= render file: Rails.root.join('..', '..', 'spec/support/custom_admin') if Rails.env.test? %>
|
20
19
|
<%= javascript_include_tag "camaleon_cms/admin/admin-manifest" %>
|
21
20
|
|
22
21
|
<%= javascript_include_tag "camaleon_cms/admin/jquery_validate/#{current_locale}.js" if current_locale != 'en' %>
|
data/config/routes/admin.rb
CHANGED
data/lib/camaleon_cms/version.rb
CHANGED
data/lib/plugin_routes.rb
CHANGED
@@ -135,6 +135,11 @@ class PluginRoutes
|
|
135
135
|
def remove_anonymous_hook(hook_key, hook_id)
|
136
136
|
(@@anonymous_hooks[hook_key.to_s] || []).delete_if{|item| item[:id] == hook_id }
|
137
137
|
end
|
138
|
+
|
139
|
+
# return the class name for user model
|
140
|
+
def get_user_class_name
|
141
|
+
static_system_info['user_model'].presence || 'CamaleonCms::User'
|
142
|
+
end
|
138
143
|
end
|
139
144
|
|
140
145
|
# reload routes
|
@@ -21,6 +21,6 @@ module Dummy
|
|
21
21
|
|
22
22
|
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
23
|
# config.active_record.raise_in_transactional_callbacks = true
|
24
|
-
config.active_record.sqlite3.represent_boolean_as_integer = true
|
24
|
+
config.active_record.sqlite3.represent_boolean_as_integer = true if Rails.version.to_f >= 5.2
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :post, class: CamaleonCms::Post do
|
3
|
+
title Faker::Name.title
|
4
|
+
sequence(:slug) { |n| "post#{n}" }
|
5
|
+
content Faker::Lorem.sentence
|
6
|
+
published_at { Time.current }
|
7
|
+
|
8
|
+
transient do
|
9
|
+
site nil
|
10
|
+
end
|
11
|
+
|
12
|
+
post_type { association :post_type, site: site || create(:site) }
|
13
|
+
owner { association :user, site: site }
|
14
|
+
|
15
|
+
factory :pending_post do
|
16
|
+
status 'pending'
|
17
|
+
end
|
18
|
+
|
19
|
+
factory :draft_post do
|
20
|
+
status 'draft'
|
21
|
+
end
|
22
|
+
|
23
|
+
factory :children_post do
|
24
|
+
parent { post }
|
25
|
+
end
|
26
|
+
|
27
|
+
factory :private_post do
|
28
|
+
visibility 'private'
|
29
|
+
visibility_value { owner.role }
|
30
|
+
end
|
31
|
+
|
32
|
+
factory :password_post do
|
33
|
+
visibility 'password'
|
34
|
+
visibility_value '12345'
|
35
|
+
end
|
36
|
+
|
37
|
+
factory :featured_post do
|
38
|
+
is_feature true
|
39
|
+
end
|
40
|
+
|
41
|
+
# data_options {} # all attrs in Post#set_setting()
|
42
|
+
# data_metas {thumb: <String thumb full url>, layout: <String layout name>, template: <String template name>, summary: <Text summary>, has_comments: <0|1>}
|
43
|
+
end
|
44
|
+
end
|
data/spec/factories/post_type.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
include CamaleonCms::SiteHelper
|
2
|
-
include CamaleonCms::HooksHelper
|
3
1
|
FactoryBot.define do
|
4
|
-
factory :
|
2
|
+
factory :post_type, class: CamaleonCms::PostType do
|
5
3
|
name { Faker::Name.unique.name }
|
6
|
-
slug {
|
4
|
+
sequence(:slug) { |n| "posttyp#{n}" }
|
7
5
|
description Faker::Lorem.sentence
|
8
|
-
|
9
|
-
|
10
|
-
skip_intro true
|
11
|
-
end
|
12
|
-
after(:create) do |site, evaluator|
|
13
|
-
site_after_install(site, evaluator.theme)
|
14
|
-
site.set_option('save_intro', true) if evaluator.skip_intro
|
15
|
-
end
|
6
|
+
data_options {}
|
7
|
+
site
|
16
8
|
end
|
17
9
|
end
|
data/spec/factories/site.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
+
include CamaleonCms::SiteHelper
|
2
|
+
include CamaleonCms::HooksHelper
|
1
3
|
FactoryBot.define do
|
2
|
-
factory :
|
4
|
+
factory :site, class: CamaleonCms::Site do
|
3
5
|
name { Faker::Name.unique.name }
|
6
|
+
slug { Capybara.current_session.server ? "#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}" : 'key' }
|
7
|
+
# sequence(:slug) { |n| Capybara.current_session.server ? "#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}" : "site#{n}" }
|
4
8
|
description Faker::Lorem.sentence
|
5
|
-
|
6
|
-
|
9
|
+
transient do
|
10
|
+
theme PluginRoutes.all_themes.first['key']
|
11
|
+
skip_intro true
|
12
|
+
end
|
13
|
+
after(:create) do |site, evaluator|
|
14
|
+
site_after_install(site, evaluator.theme)
|
15
|
+
site.set_option('save_intro', true) if evaluator.skip_intro
|
16
|
+
end
|
7
17
|
end
|
8
18
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :user, class: CamaManager.get_user_class_name do
|
3
|
+
first_name Faker::Name.first_name
|
4
|
+
last_name Faker::Name.last_name
|
5
|
+
email { Faker::Internet.unique.email }
|
6
|
+
username { Faker::Internet.unique.user_name }
|
7
|
+
password '12345678'
|
8
|
+
password_confirmation '12345678'
|
9
|
+
site
|
10
|
+
|
11
|
+
factory :user_admin do
|
12
|
+
role 'admin'
|
13
|
+
end
|
14
|
+
|
15
|
+
factory :user_shared do
|
16
|
+
site_id nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -15,6 +15,7 @@ describe "the Custom Fields", js: true do
|
|
15
15
|
fill_in "custom_field_group_description", with: 'Test name description'
|
16
16
|
page.execute_script('$("#select_assign_group").val("PostType_Post,2")')
|
17
17
|
|
18
|
+
wait 2
|
18
19
|
all('#content-items-default a').each do |link|
|
19
20
|
link.click
|
20
21
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
|
+
include CamaleonCms::PluginsHelper
|
2
3
|
describe "Post frontend", js: true do
|
3
|
-
|
4
|
-
@site = create(:site).decorate
|
5
|
-
@post = @site.the_post('sample-post').decorate
|
6
|
-
end
|
4
|
+
init_site
|
7
5
|
|
8
6
|
it 'visit post' do
|
9
7
|
visit @post.the_url(as_path: true)
|
@@ -11,13 +9,13 @@ describe "Post frontend", js: true do
|
|
11
9
|
end
|
12
10
|
|
13
11
|
describe 'comments' do
|
14
|
-
|
12
|
+
|
15
13
|
describe 'anonymous' do
|
16
14
|
before(:each) do
|
17
15
|
@post.set_meta('has_comments', '1') # enable comments for this post
|
18
16
|
@site.set_option('permit_anonimos_comment', true) # enable anonymous comment
|
19
17
|
end
|
20
|
-
|
18
|
+
|
21
19
|
it 'anonymous comment' do
|
22
20
|
visit @post.the_url(as_path: true)
|
23
21
|
expect(page).to have_text('New Comment')
|
@@ -83,4 +81,56 @@ describe "Post frontend", js: true do
|
|
83
81
|
expect(page).not_to have_text('New Comment')
|
84
82
|
end
|
85
83
|
end
|
84
|
+
|
85
|
+
describe 'post visibility' do
|
86
|
+
before(:each) do
|
87
|
+
current_site(@site)
|
88
|
+
plugin_install('visibility_post')
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'public post' do
|
92
|
+
custom_post = create(:post, site: @site).decorate
|
93
|
+
visit custom_post.the_url(as_path: true)
|
94
|
+
expect(page).to have_http_status(:success)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'public future post with login' do
|
98
|
+
custom_post = create(:post, site: @site, published_at: 1.day.from_now).decorate
|
99
|
+
admin_sign_in(custom_post.owner.username, '12345678')
|
100
|
+
visit custom_post.the_url(as_path: true)
|
101
|
+
expect(page).to have_http_status(:not_found)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'public future post without login' do
|
105
|
+
custom_post = create(:post, site: @site, published_at: 1.day.from_now).decorate
|
106
|
+
visit custom_post.the_url(as_path: true)
|
107
|
+
expect(page).to have_http_status(:not_found)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'private post without login ' do
|
111
|
+
custom_post = create(:private_post, site: @site).decorate
|
112
|
+
visit custom_post.the_url(as_path: true)
|
113
|
+
expect(page).to have_http_status(:not_found)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'private post with login' do
|
117
|
+
user = create(:user, password: '12345678', password_confirmation: '12345678', site: @site)
|
118
|
+
custom_post = create(:private_post, site: @site, owner: user).decorate
|
119
|
+
admin_sign_in(user.username, '12345678')
|
120
|
+
visit custom_post.the_url(as_path: true)
|
121
|
+
expect(page).to have_http_status(:success)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'password post without password ' do
|
125
|
+
custom_post = create(:password_post, site: @site).decorate
|
126
|
+
visit custom_post.the_url(as_path: true)
|
127
|
+
expect(page).to have_text('Enter the password:')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'password post with password ' do
|
131
|
+
custom_post = create(:password_post, site: @site).decorate
|
132
|
+
visit custom_post.the_url(as_path: true, post_password: custom_post.visibility_value)
|
133
|
+
expect(page).to have_http_status(:success)
|
134
|
+
end
|
135
|
+
end
|
86
136
|
end
|
data/spec/models/post_spec.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
include CamaleonCms::Frontend::ApplicationHelper
|
3
3
|
RSpec.describe 'PostDecorator' do
|
4
|
+
init_site
|
4
5
|
it "next and previous post related to post type" do
|
5
|
-
post_type =
|
6
|
-
post3 =
|
7
|
-
post1 =
|
8
|
-
post2 =
|
9
|
-
post2_1 =
|
10
|
-
post4 =
|
6
|
+
post_type = create(:post_type, slug: 'test-post-type', site: @site)
|
7
|
+
post3 = create(:post, post_type: post_type, slug: 'test3', post_order: 3).decorate
|
8
|
+
post1 = create(:post, post_type: post_type, slug: 'test1', post_order: 1).decorate
|
9
|
+
post2 = create(:post, post_type: post_type, slug: 'test2', post_order: 2).decorate
|
10
|
+
post2_1 = create(:post, post_type: post_type, slug: 'test2_1', post_order: 2).decorate
|
11
|
+
post4 = create(:post, post_type: post_type, slug: 'test4', post_order: 4).decorate
|
11
12
|
|
12
13
|
expect(post3.the_next_post.slug).to eq('test4')
|
13
14
|
expect(post3.the_prev_post.slug).to eq('test2_1')
|
@@ -24,4 +25,26 @@ RSpec.describe 'PostDecorator' do
|
|
24
25
|
expect(post4.the_prev_post.slug).to eq('test3')
|
25
26
|
expect(post4.the_next_post).to eq(nil)
|
26
27
|
end
|
28
|
+
|
29
|
+
it 'featured post' do
|
30
|
+
ptype = @site.post_types.last
|
31
|
+
bk = ptype.posts.featured.count
|
32
|
+
create(:featured_post, post_type: ptype)
|
33
|
+
expect(ptype.posts.reload.featured.count).to eql(bk + 1)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'post with extra data' do
|
37
|
+
ptype = @site.post_types.last
|
38
|
+
ptype.set_option('has_comments', true)
|
39
|
+
data = {
|
40
|
+
thumb: 'http://camaleon.tuzitio.com/media/132/slider/slider-camaleon.jpg',
|
41
|
+
summary: 'This is summary',
|
42
|
+
has_comments: 0
|
43
|
+
}
|
44
|
+
post = create(:post, post_type: ptype, data_metas: data).decorate
|
45
|
+
expect(post.get_meta("summary").present?).to eql(true)
|
46
|
+
expect(post.the_thumb_url).to include('slider-camaleon.jpg')
|
47
|
+
expect(post.has_thumb?).to eql(true)
|
48
|
+
expect(post.manage_comments?).to eql(true)
|
49
|
+
end
|
27
50
|
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.4.5.
|
4
|
+
version: 2.4.5.8
|
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: 2018-
|
11
|
+
date: 2018-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -366,8 +366,22 @@ dependencies:
|
|
366
366
|
- - ">="
|
367
367
|
- !ruby/object:Gem::Version
|
368
368
|
version: '0'
|
369
|
+
- !ruby/object:Gem::Dependency
|
370
|
+
name: rubocop
|
371
|
+
requirement: !ruby/object:Gem::Requirement
|
372
|
+
requirements:
|
373
|
+
- - ">="
|
374
|
+
- !ruby/object:Gem::Version
|
375
|
+
version: '0'
|
376
|
+
type: :development
|
377
|
+
prerelease: false
|
378
|
+
version_requirements: !ruby/object:Gem::Requirement
|
379
|
+
requirements:
|
380
|
+
- - ">="
|
381
|
+
- !ruby/object:Gem::Version
|
382
|
+
version: '0'
|
369
383
|
description: Camaleon CMS is a dynamic and advanced content management system based
|
370
|
-
on Ruby on Rails 4 as an alternative to Wordpress.
|
384
|
+
on Ruby on Rails 4+ as an alternative to Wordpress.
|
371
385
|
email:
|
372
386
|
- owenperedo@gmail.com
|
373
387
|
executables: []
|
@@ -799,6 +813,7 @@ files:
|
|
799
813
|
- app/views/camaleon_cms/admin/settings/custom_fields/_get_items.html.erb
|
800
814
|
- app/views/camaleon_cms/admin/settings/custom_fields/_meta_data.html.erb
|
801
815
|
- app/views/camaleon_cms/admin/settings/custom_fields/_render.html.erb
|
816
|
+
- app/views/camaleon_cms/admin/settings/custom_fields/_render_category_simple.html.erb
|
802
817
|
- app/views/camaleon_cms/admin/settings/custom_fields/fields/_audio.html.erb
|
803
818
|
- app/views/camaleon_cms/admin/settings/custom_fields/fields/_categories.html.erb
|
804
819
|
- app/views/camaleon_cms/admin/settings/custom_fields/fields/_checkbox.html.erb
|
@@ -1045,10 +1060,10 @@ files:
|
|
1045
1060
|
- spec/dummy/config/routes.rb
|
1046
1061
|
- spec/dummy/config/secrets.yml
|
1047
1062
|
- spec/dummy/db/schema.rb
|
1048
|
-
- spec/
|
1049
|
-
- spec/dummy/public/favicon.ico
|
1063
|
+
- spec/factories/post.rb
|
1050
1064
|
- spec/factories/post_type.rb
|
1051
1065
|
- spec/factories/site.rb
|
1066
|
+
- spec/factories/user.rb
|
1052
1067
|
- spec/features/admin/categories_spec.rb
|
1053
1068
|
- spec/features/admin/comments_spec.rb
|
1054
1069
|
- spec/features/admin/contact_form_spec.rb
|
@@ -1081,7 +1096,6 @@ files:
|
|
1081
1096
|
- spec/routing/post_type_routes_spec.rb
|
1082
1097
|
- spec/spec_helper.rb
|
1083
1098
|
- spec/support/common.rb
|
1084
|
-
- spec/support/custom_admin.html.erb
|
1085
1099
|
- spec/support/fixtures/rails.png
|
1086
1100
|
- spec/support/fixtures/rails_tmp.png
|
1087
1101
|
- spec/support/wait_for_ajax.rb
|
@@ -1097,21 +1111,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1097
1111
|
requirements:
|
1098
1112
|
- - ">="
|
1099
1113
|
- !ruby/object:Gem::Version
|
1100
|
-
version:
|
1114
|
+
version: '2.2'
|
1101
1115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1102
1116
|
requirements:
|
1103
1117
|
- - ">="
|
1104
1118
|
- !ruby/object:Gem::Version
|
1105
1119
|
version: '0'
|
1106
1120
|
requirements:
|
1107
|
-
- rails >= 4.
|
1108
|
-
- ruby >=
|
1121
|
+
- rails >= 4.2
|
1122
|
+
- ruby >= 2.2
|
1109
1123
|
- imagemagick
|
1110
1124
|
rubyforge_project:
|
1111
1125
|
rubygems_version: 2.6.10
|
1112
1126
|
signing_key:
|
1113
1127
|
specification_version: 4
|
1114
|
-
summary: Camaleon is a
|
1128
|
+
summary: Camaleon is a CMS for Ruby on Rails 4+ as an alternative to Wordpress.
|
1115
1129
|
test_files:
|
1116
1130
|
- spec/spec_helper.rb
|
1117
1131
|
- spec/dummy/app/controllers/application_controller.rb
|
@@ -1143,9 +1157,7 @@ test_files:
|
|
1143
1157
|
- spec/dummy/config/initializers/inflections.rb
|
1144
1158
|
- spec/dummy/config.ru
|
1145
1159
|
- spec/dummy/Rakefile
|
1146
|
-
- spec/dummy/public/favicon.ico
|
1147
1160
|
- spec/dummy/db/schema.rb
|
1148
|
-
- spec/dummy/db/test.sqlite3
|
1149
1161
|
- spec/dummy/README.rdoc
|
1150
1162
|
- spec/mailers/send_mail_spec.rb
|
1151
1163
|
- spec/features/frontend/post_type_spec.rb
|
@@ -1176,9 +1188,10 @@ test_files:
|
|
1176
1188
|
- spec/support/wait_for_ajax.rb
|
1177
1189
|
- spec/support/fixtures/rails_tmp.png
|
1178
1190
|
- spec/support/fixtures/rails.png
|
1179
|
-
- spec/support/custom_admin.html.erb
|
1180
1191
|
- spec/factories/post_type.rb
|
1181
1192
|
- spec/factories/site.rb
|
1193
|
+
- spec/factories/post.rb
|
1194
|
+
- spec/factories/user.rb
|
1182
1195
|
- spec/routing/post_type_routes_spec.rb
|
1183
1196
|
- spec/rails_helper.rb
|
1184
1197
|
- spec/helpers/uploader_helper_spec.rb
|
data/spec/dummy/db/test.sqlite3
DELETED
Binary file
|
Binary file
|