billy_cms 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/billy_cms/backend/app.js.erb +2 -2
- data/app/controllers/api/api_controller.rb +23 -0
- data/app/controllers/api/attributes_controller.rb +63 -0
- data/app/controllers/api/page_types_controller.rb +11 -0
- data/app/controllers/api/pages_controller.rb +61 -0
- data/config/routes.rb +8 -0
- data/lib/billy_cms/version.rb +1 -1
- metadata +7 -6
- data/app/controllers/billy_cms/api/api_controller.rb +0 -25
- data/app/controllers/billy_cms/api/attributes_controller.rb +0 -65
- data/app/controllers/billy_cms/api/page_types_controller.rb +0 -13
- data/app/controllers/billy_cms/api/pages_controller.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15bc4ec8c016530fced76042b9ae95d1650e5fdc
|
4
|
+
data.tar.gz: 434f25354c705ecf7d4d5cafea20444af5adacfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5698688ce205483968355021a0fc273e56407e90af00832e0d45b6551d515d5b35a197f7a64bdae74b8e4274bc68a60d115e9aac69ff571840d4adcb90a64b80
|
7
|
+
data.tar.gz: e5970c0b54b6e89d577a5d94da14e3ca4fe61f5979dede5fbf26ad39e87175b78ec2b8858dcc6935197ac5c80a3b22715ad9ef2036f0480b4dc3769561da8019
|
@@ -55,12 +55,12 @@ app.controller('ApplicationCtrl', ['$scope', '$http', 'BillyObject', 'PageType',
|
|
55
55
|
version : 1
|
56
56
|
};
|
57
57
|
$http.get('/billy_cms/api/page_types').then(function(result) {
|
58
|
-
ctrl.allPageTypes = result.data.
|
58
|
+
ctrl.allPageTypes = result.data.map(function(pageTypeData) {
|
59
59
|
return new PageType(pageTypeData);
|
60
60
|
});
|
61
61
|
});
|
62
62
|
$http.get('/billy_cms/api/pages').then(function(result) {
|
63
|
-
ctrl.rawPagesData = result.data.
|
63
|
+
ctrl.rawPagesData = result.data.map(function(page) { return new BillyObject(page); });
|
64
64
|
ctrl.recreateTreeFromRawData();
|
65
65
|
});
|
66
66
|
this.tree = [];
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Api
|
2
|
+
class ApiController < ActionController::Base
|
3
|
+
protect_from_forgery with: :null_session
|
4
|
+
skip_before_filter :verify_authenticity_token
|
5
|
+
|
6
|
+
before_filter :ensure_user_is_admin
|
7
|
+
|
8
|
+
def current_user
|
9
|
+
@current_user ||= begin
|
10
|
+
users = User.where(id: session[:user_id]).presence
|
11
|
+
session[:user_id] && users ? users.first : false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def ensure_user_is_admin
|
18
|
+
unless current_user && current_user.admin?
|
19
|
+
render text: 'Forbidden', status: 403
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Api
|
2
|
+
class AttributesController < ApiController
|
3
|
+
def index
|
4
|
+
render json: BillyCms::AdditionalAttribute.all
|
5
|
+
end
|
6
|
+
|
7
|
+
def show
|
8
|
+
render json: BillyCms::AdditionalAttribute.find(params[:id])
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
render nothing: true, status: 400 unless params[:attribute]
|
13
|
+
attribute = BillyCms::AdditionalAttribute.find params[:id]
|
14
|
+
if attribute.update_attributes attribute_params
|
15
|
+
render json: {
|
16
|
+
success: true,
|
17
|
+
attribute: attribute
|
18
|
+
}
|
19
|
+
else
|
20
|
+
render json: {
|
21
|
+
success: false,
|
22
|
+
error: attribute.error_messages,
|
23
|
+
}, status: 500
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
render nothing: true, status: 400 unless params[:attribute]
|
29
|
+
attribute = BillyCms::AdditionalAttribute.new attribute_params
|
30
|
+
if attribute.save
|
31
|
+
render json: {
|
32
|
+
success: true,
|
33
|
+
attribute: attribute
|
34
|
+
}
|
35
|
+
else
|
36
|
+
render json: {
|
37
|
+
success: false,
|
38
|
+
error: attribute.error_messages,
|
39
|
+
}, status: 500
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
render :nothing, status: 400 unless params[:id]
|
45
|
+
if BillyCms::AdditionalAttribute.delete(params[:id])
|
46
|
+
render json: {
|
47
|
+
success: true
|
48
|
+
}
|
49
|
+
else
|
50
|
+
render json: {
|
51
|
+
success: false,
|
52
|
+
error: attribute.error_messages,
|
53
|
+
}, status: 500
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def attributes_params
|
60
|
+
params.require(:attribute).permit(:title, :attribute, :attribute_type) if current_user.admin?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Api
|
2
|
+
class PagesController < ApiController
|
3
|
+
def index
|
4
|
+
render json: BillyCms::Page.all
|
5
|
+
end
|
6
|
+
|
7
|
+
def update
|
8
|
+
render nothing: true, status: 400 unless params[:page]
|
9
|
+
page = BillyCms::Page.find params[:id]
|
10
|
+
if page.update_attributes page_params
|
11
|
+
render json: {
|
12
|
+
success: true,
|
13
|
+
page: page
|
14
|
+
}
|
15
|
+
else
|
16
|
+
render json: {
|
17
|
+
success: false,
|
18
|
+
error: page.errors.full_messages,
|
19
|
+
}, status: 500
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
render nothing: true, status: 400 unless params[:page]
|
25
|
+
page = BillyCms::Page.new page_params
|
26
|
+
if page.save
|
27
|
+
render json: {
|
28
|
+
success: true,
|
29
|
+
page: page
|
30
|
+
}
|
31
|
+
else
|
32
|
+
render json: {
|
33
|
+
success: false,
|
34
|
+
error: page.error_messages,
|
35
|
+
}, status: 500
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
render :nothing, status: 400 unless params[:id]
|
41
|
+
if BillyCms::Page.delete(params[:id])
|
42
|
+
render json: {
|
43
|
+
success: true
|
44
|
+
}
|
45
|
+
else
|
46
|
+
render json: {
|
47
|
+
success: false,
|
48
|
+
error: page.error_messages,
|
49
|
+
}, status: 500
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def page_params
|
56
|
+
page = BillyCms::Page.find(params[:id]) if params[:id].present?
|
57
|
+
allowed_types = page ? page.additional_attributes.map(&:name).map(&:to_sym) : []
|
58
|
+
params.require(:page).permit(:title, :content, :parent_page_id, :order_key, :hide_from_navigation, :page_type, additional_attributes_values: allowed_types) if current_user.admin?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/config/routes.rb
ADDED
data/lib/billy_cms/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: billy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unsdrei GbR
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -143,10 +143,10 @@ files:
|
|
143
143
|
- app/assets/stylesheets/billy_cms/editmode.scss
|
144
144
|
- app/assets/stylesheets/billy_cms/index.scss
|
145
145
|
- app/assets/stylesheets/billy_cms/jstree.scss
|
146
|
-
- app/controllers/
|
147
|
-
- app/controllers/
|
148
|
-
- app/controllers/
|
149
|
-
- app/controllers/
|
146
|
+
- app/controllers/api/api_controller.rb
|
147
|
+
- app/controllers/api/attributes_controller.rb
|
148
|
+
- app/controllers/api/page_types_controller.rb
|
149
|
+
- app/controllers/api/pages_controller.rb
|
150
150
|
- app/controllers/billy_cms/backend_controller.rb
|
151
151
|
- app/controllers/billy_cms/base_controller.rb
|
152
152
|
- app/helpers/billy_cms/cms_path_helper.rb
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- bin/console
|
173
173
|
- bin/setup
|
174
174
|
- config/initializers/active_model_serializers.rb
|
175
|
+
- config/routes.rb
|
175
176
|
- lib/billy_cms.rb
|
176
177
|
- lib/billy_cms/version.rb
|
177
178
|
homepage: ''
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module BillyCms
|
2
|
-
module Api
|
3
|
-
class ApiController < ActionController::Base
|
4
|
-
protect_from_forgery with: :null_session
|
5
|
-
skip_before_filter :verify_authenticity_token
|
6
|
-
|
7
|
-
before_filter :ensure_user_is_admin
|
8
|
-
|
9
|
-
def current_user
|
10
|
-
@current_user ||= begin
|
11
|
-
users = User.where(id: session[:user_id]).presence
|
12
|
-
session[:user_id] && users ? users.first : false
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def ensure_user_is_admin
|
19
|
-
unless current_user && current_user.admin?
|
20
|
-
render text: 'Forbidden', status: 403
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
module BillyCms
|
2
|
-
module Api
|
3
|
-
class AttributesController < ApiController
|
4
|
-
def index
|
5
|
-
render json: AdditionalAttribute.all
|
6
|
-
end
|
7
|
-
|
8
|
-
def show
|
9
|
-
render json: AdditionalAttribute.find(params[:id])
|
10
|
-
end
|
11
|
-
|
12
|
-
def update
|
13
|
-
render nothing: true, status: 400 unless params[:attribute]
|
14
|
-
attribute = AdditionalAttribute.find params[:id]
|
15
|
-
if attribute.update_attributes attribute_params
|
16
|
-
render json: {
|
17
|
-
success: true,
|
18
|
-
attribute: attribute
|
19
|
-
}
|
20
|
-
else
|
21
|
-
render json: {
|
22
|
-
success: false,
|
23
|
-
error: attribute.error_messages,
|
24
|
-
}, status: 500
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def create
|
29
|
-
render nothing: true, status: 400 unless params[:attribute]
|
30
|
-
attribute = AdditionalAttribute.new attribute_params
|
31
|
-
if attribute.save
|
32
|
-
render json: {
|
33
|
-
success: true,
|
34
|
-
attribute: attribute
|
35
|
-
}
|
36
|
-
else
|
37
|
-
render json: {
|
38
|
-
success: false,
|
39
|
-
error: attribute.error_messages,
|
40
|
-
}, status: 500
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def destroy
|
45
|
-
render :nothing, status: 400 unless params[:id]
|
46
|
-
if AdditionalAttribute.delete(params[:id])
|
47
|
-
render json: {
|
48
|
-
success: true
|
49
|
-
}
|
50
|
-
else
|
51
|
-
render json: {
|
52
|
-
success: false,
|
53
|
-
error: attribute.error_messages,
|
54
|
-
}, status: 500
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def attributes_params
|
61
|
-
params.require(:attribute).permit(:title, :attribute, :attribute_type) if current_user.admin?
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module BillyCms
|
2
|
-
module Api
|
3
|
-
class PagesController < ApiController
|
4
|
-
def index
|
5
|
-
render json: Page.all
|
6
|
-
end
|
7
|
-
|
8
|
-
def update
|
9
|
-
render nothing: true, status: 400 unless params[:page]
|
10
|
-
page = Page.find params[:id]
|
11
|
-
if page.update_attributes page_params
|
12
|
-
render json: {
|
13
|
-
success: true,
|
14
|
-
page: page
|
15
|
-
}
|
16
|
-
else
|
17
|
-
render json: {
|
18
|
-
success: false,
|
19
|
-
error: page.errors.full_messages,
|
20
|
-
}, status: 500
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def create
|
25
|
-
render nothing: true, status: 400 unless params[:page]
|
26
|
-
page = Page.new page_params
|
27
|
-
if page.save
|
28
|
-
render json: {
|
29
|
-
success: true,
|
30
|
-
page: page
|
31
|
-
}
|
32
|
-
else
|
33
|
-
render json: {
|
34
|
-
success: false,
|
35
|
-
error: page.error_messages,
|
36
|
-
}, status: 500
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def destroy
|
41
|
-
render :nothing, status: 400 unless params[:id]
|
42
|
-
if Page.delete(params[:id])
|
43
|
-
render json: {
|
44
|
-
success: true
|
45
|
-
}
|
46
|
-
else
|
47
|
-
render json: {
|
48
|
-
success: false,
|
49
|
-
error: page.error_messages,
|
50
|
-
}, status: 500
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def page_params
|
57
|
-
page = Page.find(params[:id]) if params[:id].present?
|
58
|
-
allowed_types = page ? page.additional_attributes.map(&:name).map(&:to_sym) : []
|
59
|
-
params.require(:page).permit(:title, :content, :parent_page_id, :order_key, :hide_from_navigation, :page_type, additional_attributes_values: allowed_types) if current_user.admin?
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|