comfortable_mexican_sofa 1.8.5 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +3 -3
- data/README.md +10 -14
- data/Rakefile +0 -2
- data/app/assets/javascripts/comfortable_mexican_sofa/application.js.coffee +1 -2
- data/app/controllers/cms_admin/base_controller.rb +1 -1
- data/app/controllers/cms_admin/categories_controller.rb +7 -3
- data/app/controllers/cms_admin/files_controller.rb +28 -32
- data/app/controllers/cms_admin/layouts_controller.rb +12 -7
- data/app/controllers/cms_admin/pages_controller.rb +14 -10
- data/app/controllers/cms_admin/revisions_controller.rb +2 -2
- data/app/controllers/cms_admin/sites_controller.rb +9 -5
- data/app/controllers/cms_admin/snippets_controller.rb +8 -4
- data/app/controllers/cms_content_controller.rb +5 -5
- data/app/models/cms/block.rb +0 -3
- data/app/models/cms/categorization.rb +0 -2
- data/app/models/cms/category.rb +2 -4
- data/app/models/cms/file.rb +2 -10
- data/app/models/cms/layout.rb +2 -10
- data/app/models/cms/page.rb +2 -11
- data/app/models/cms/revision.rb +1 -3
- data/app/models/cms/site.rb +5 -12
- data/app/models/cms/snippet.rb +3 -8
- data/app/views/cms_admin/layouts/edit.html.haml +1 -1
- data/app/views/cms_admin/pages/_form_blocks.html.haml +1 -1
- data/app/views/cms_admin/pages/edit.html.haml +1 -1
- data/app/views/cms_admin/sites/_mirrors.html.haml +2 -1
- data/app/views/cms_admin/snippets/edit.html.haml +1 -1
- data/app/views/cms_content/render_sitemap.xml.builder +0 -1
- data/comfortable_mexican_sofa.gemspec +2 -2
- data/config/application.rb +5 -46
- data/config/boot.rb +2 -3
- data/config/cms_routes.rb +4 -0
- data/config/environments/development.rb +9 -21
- data/config/environments/test.rb +12 -15
- data/config/initializers/secret_token.rb +15 -0
- data/lib/comfortable_mexican_sofa.rb +0 -1
- data/lib/comfortable_mexican_sofa/extensions/acts_as_tree.rb +5 -4
- data/lib/comfortable_mexican_sofa/extensions/rails.rb +1 -1
- data/lib/comfortable_mexican_sofa/fixture.rb +4 -1
- data/lib/comfortable_mexican_sofa/fixture/category.rb +1 -1
- data/lib/comfortable_mexican_sofa/fixture/layout.rb +1 -1
- data/lib/comfortable_mexican_sofa/fixture/snippet.rb +1 -1
- data/lib/comfortable_mexican_sofa/routing.rb +0 -1
- data/lib/comfortable_mexican_sofa/tags/collection.rb +1 -1
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/lib/tasks/comfortable_mexican_sofa.rake +0 -5
- data/test/{functional → controllers}/cms_admin/base_controller_test.rb +0 -0
- data/test/{functional → controllers}/cms_admin/categories_controller_test.rb +0 -0
- data/test/{functional → controllers}/cms_admin/files_controller_test.rb +3 -17
- data/test/{functional → controllers}/cms_admin/layouts_controller_test.rb +9 -0
- data/test/{functional → controllers}/cms_admin/pages_controller_test.rb +19 -19
- data/test/{functional → controllers}/cms_admin/revisions_controller_test.rb +0 -0
- data/test/{functional → controllers}/cms_admin/sites_controller_test.rb +0 -0
- data/test/{functional → controllers}/cms_admin/snippets_controller_test.rb +0 -0
- data/test/{functional → controllers}/cms_content_controller_test.rb +6 -23
- data/test/gemfiles/Gemfile.rails.4.0 +17 -0
- data/test/integration/authentication_test.rb +1 -1
- data/test/integration/fixtures_test.rb +2 -2
- data/test/integration/mirrors_test.rb +2 -2
- data/test/integration/render_cms_test.rb +4 -10
- data/test/integration/sites_test.rb +4 -4
- data/test/integration/view_hooks_test.rb +1 -1
- data/test/{unit/models → models/cms}/block_test.rb +3 -3
- data/test/{unit/models → models/cms}/categorization_test.rb +2 -2
- data/test/{unit/models → models/cms}/category_test.rb +0 -0
- data/test/{unit/models → models/cms}/file_test.rb +1 -1
- data/test/{unit/models → models/cms}/layout_test.rb +2 -2
- data/test/{unit/models → models/cms}/page_test.rb +3 -3
- data/test/{unit/models → models/cms}/site_test.rb +1 -1
- data/test/{unit/models → models/cms}/snippet_test.rb +0 -0
- data/test/{unit → models}/configuration_test.rb +0 -0
- data/test/{unit → models}/fixtures/categories_test.rb +0 -0
- data/test/{unit → models}/fixtures/files_test.rb +0 -0
- data/test/{unit → models}/fixtures/layouts_test.rb +0 -0
- data/test/{unit → models}/fixtures/pages_test.rb +0 -0
- data/test/{unit → models}/fixtures/snippets_test.rb +0 -0
- data/test/{unit → models}/fixtures_test.rb +1 -1
- data/test/{unit → models}/mirrors_test.rb +0 -0
- data/test/{unit → models}/revisions_test.rb +0 -0
- data/test/{unit → models}/tag_test.rb +0 -0
- data/test/{unit → models}/tags/asset_test.rb +0 -0
- data/test/{unit → models}/tags/collection_test.rb +0 -0
- data/test/{unit → models}/tags/field_datetime_test.rb +0 -0
- data/test/{unit → models}/tags/field_integer_test.rb +0 -0
- data/test/{unit → models}/tags/field_rich_text_test.rb +0 -0
- data/test/{unit → models}/tags/field_string_test.rb +0 -0
- data/test/{unit → models}/tags/field_text_test.rb +0 -0
- data/test/{unit → models}/tags/file_test.rb +0 -0
- data/test/{unit → models}/tags/helper_test.rb +0 -0
- data/test/{unit → models}/tags/page_datetime_test.rb +0 -0
- data/test/{unit → models}/tags/page_file_test.rb +0 -0
- data/test/{unit → models}/tags/page_files_test.rb +0 -0
- data/test/{unit → models}/tags/page_integer_test.rb +0 -0
- data/test/{unit → models}/tags/page_markdown_test.rb +0 -0
- data/test/{unit → models}/tags/page_rich_text_test.rb +0 -0
- data/test/{unit → models}/tags/page_string_test.rb +0 -0
- data/test/{unit → models}/tags/page_text_test.rb +0 -0
- data/test/{unit → models}/tags/partial_test.rb +0 -0
- data/test/{unit → models}/tags/snippet_test.rb +0 -0
- data/test/{unit → models}/view_methods_test.rb +1 -1
- data/test/test_helper.rb +1 -16
- metadata +55 -59
- data/config/environments/production.rb +0 -67
- data/config/routes.rb +0 -4
- data/lib/comfortable_mexican_sofa/sitemap.rb +0 -27
- data/test/gemfiles/Gemfile.rails.3.1 +0 -19
- data/test/gemfiles/Gemfile.rails.3.2 +0 -19
- data/test/unit/fixtures/_sample.jpg.yml +0 -0
- data/test/unit/sitemap_test.rb +0 -20
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,14 +2,14 @@ language: ruby
|
|
2
2
|
before_install:
|
3
3
|
- gem update --system
|
4
4
|
- gem --version
|
5
|
+
script:
|
6
|
+
- rake db:migrate
|
5
7
|
rvm:
|
6
|
-
- 1.9.2
|
7
8
|
- 1.9.3
|
8
9
|
- 2.0.0
|
9
10
|
- jruby-19mode
|
10
11
|
gemfile:
|
11
|
-
- test/gemfiles/Gemfile.rails.
|
12
|
-
- test/gemfiles/Gemfile.rails.3.2
|
12
|
+
- test/gemfiles/Gemfile.rails.4.0
|
13
13
|
notifications:
|
14
14
|
recipients:
|
15
15
|
- oleg@khabarov.ca
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# ComfortableMexicanSofa
|
1
|
+
# ComfortableMexicanSofa
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/comfortable_mexican_sofa.png)](http://rubygems.org/gems/comfortable_mexican_sofa) [![Build Status](https://travis-ci.org/comfy/comfortable-mexican-sofa.png?branch=master)](https://travis-ci.org/comfy/comfortable-mexican-sofa) [![Dependency Status](https://gemnasium.com/comfy/comfortable-mexican-sofa.png)](https://gemnasium.com/comfy/comfortable-mexican-sofa) [![Code Climate](https://codeclimate.com/github/comfy/comfortable-mexican-sofa.png)](https://codeclimate.com/github/comfy/comfortable-mexican-sofa) [![Coverage Status](https://coveralls.io/repos/comfy/comfortable-mexican-sofa/badge.png?branch=master)](https://coveralls.io/r/comfy/comfortable-mexican-sofa)
|
3
3
|
|
4
|
-
ComfortableMexicanSofa is a powerful CMS Engine for your Rails
|
4
|
+
ComfortableMexicanSofa is a powerful CMS Engine for your Rails 4 applications.
|
5
5
|
|
6
6
|
Features
|
7
7
|
--------
|
8
|
-
* Simple integration with Rails
|
8
|
+
* Simple integration with Rails 4 apps
|
9
9
|
* Build your application in Rails, not in CMS
|
10
10
|
* Powerful page templating capability using [Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Tags)
|
11
11
|
* [Multiple Sites](https://github.com/comfy/comfortable-mexican-sofa/wiki/Sites) from a single installation
|
@@ -14,21 +14,11 @@ Features
|
|
14
14
|
* [Revision History](https://github.com/comfy/comfortable-mexican-sofa/wiki/Revisions)
|
15
15
|
* [Great extendable admin interface](https://github.com/comfy/comfortable-mexican-sofa/wiki/Reusing-sofa%27s-admin-area) built with [Bootstrap](http://twitter.github.com/bootstrap/), [CodeMirror](http://codemirror.net/) and [WYSIHTML5](http://xing.github.com/wysihtml5/)
|
16
16
|
|
17
|
-
Installation for Rails 4
|
18
|
-
------------------------
|
19
|
-
For Rails 4 apps feel free to use [2.0.0.beta1](https://github.com/comfy/comfortable-mexican-sofa/tree/1.9) release.
|
20
|
-
|
21
|
-
gem 'comfortable_mexican_sofa', '~> 2.0.0.beta1'
|
22
|
-
|
23
|
-
Or even better work with the latest 1.9 branch:
|
24
|
-
|
25
|
-
gem 'comfortable_mexican_sofa', :github => 'comfy/comfortable-mexican-sofa', :branch => '1.9'
|
26
|
-
|
27
17
|
Installation
|
28
18
|
------------
|
29
19
|
Add gem definition to your Gemfile:
|
30
20
|
|
31
|
-
gem 'comfortable_mexican_sofa'
|
21
|
+
gem 'comfortable_mexican_sofa', '~> 1.9.0'
|
32
22
|
|
33
23
|
Then from the Rails project's root run:
|
34
24
|
|
@@ -44,6 +34,12 @@ ComfortableMexicanSofa::Routing.content :path => '/', :sitemap => false
|
|
44
34
|
```
|
45
35
|
|
46
36
|
When upgrading from the older version please take a look at [Upgrading ComfortableMexicanSofa](https://github.com/comfy/comfortable-mexican-sofa/wiki/Upgrading-ComfortableMexicanSofa)
|
37
|
+
|
38
|
+
Installation for Rails 3
|
39
|
+
------------------------
|
40
|
+
For Rails 3 apps feel free to use [1.8 release](https://github.com/comfy/comfortable-mexican-sofa/tree/1.8)
|
41
|
+
|
42
|
+
gem 'comfortable_mexican_sofa', '~> 1.8.0'
|
47
43
|
|
48
44
|
Quick Start Guide
|
49
45
|
-----------------
|
data/Rakefile
CHANGED
@@ -150,8 +150,7 @@ window.CMS.uploader = ->
|
|
150
150
|
raw_string = d.body.innerHTML
|
151
151
|
json_string = raw_string.match(/\{(.|\n)*\}/)[0]
|
152
152
|
json = $.parseJSON(json_string)
|
153
|
-
files = $(
|
153
|
+
files = $('<div/>').html(json.view).hide()
|
154
154
|
$('.uploaded-files').prepend(files)
|
155
155
|
files.map ->
|
156
156
|
$(this).fadeIn()
|
157
|
-
|
@@ -5,7 +5,7 @@ class CmsAdmin::BaseController < ApplicationController
|
|
5
5
|
# Authentication module must have #authenticate method
|
6
6
|
include ComfortableMexicanSofa.config.admin_auth.to_s.constantize
|
7
7
|
|
8
|
-
|
8
|
+
before_action :authenticate,
|
9
9
|
:load_admin_site,
|
10
10
|
:set_locale,
|
11
11
|
:load_fixtures,
|
@@ -1,20 +1,20 @@
|
|
1
1
|
class CmsAdmin::CategoriesController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
3
|
+
before_action :load_category, :only => [:edit, :update, :destroy]
|
4
4
|
|
5
5
|
def edit
|
6
6
|
render
|
7
7
|
end
|
8
8
|
|
9
9
|
def create
|
10
|
-
@category = @site.categories.create!(
|
10
|
+
@category = @site.categories.create!(category_params)
|
11
11
|
rescue ActiveRecord::RecordInvalid
|
12
12
|
logger.detailed_error($!)
|
13
13
|
render :nothing => true
|
14
14
|
end
|
15
15
|
|
16
16
|
def update
|
17
|
-
@category.update_attributes!(
|
17
|
+
@category.update_attributes!(category_params)
|
18
18
|
rescue ActiveRecord::RecordInvalid
|
19
19
|
logger.detailed_error($!)
|
20
20
|
render :nothing => true
|
@@ -32,4 +32,8 @@ protected
|
|
32
32
|
render :nothing => true
|
33
33
|
end
|
34
34
|
|
35
|
+
def category_params
|
36
|
+
params.fetch(:category, {}).permit!
|
37
|
+
end
|
38
|
+
|
35
39
|
end
|
@@ -1,25 +1,17 @@
|
|
1
1
|
class CmsAdmin::FilesController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
3
|
+
skip_before_action :load_fixtures
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before_action :build_file, :only => [:new, :create]
|
6
|
+
before_action :load_file, :only => [:edit, :update, :destroy]
|
7
7
|
|
8
8
|
def index
|
9
9
|
@files = @site.files.includes(:categories).for_category(params[:category]).order('cms_files.position')
|
10
10
|
|
11
11
|
if params[:ajax]
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:filename => file.file_file_name,
|
16
|
-
:url => file.file.url }
|
17
|
-
end
|
18
|
-
else
|
19
|
-
files = @files.images.collect do |file|
|
20
|
-
{ :thumb => file.file.url(:cms_thumb),
|
21
|
-
:image => file.file.url }
|
22
|
-
end
|
12
|
+
files = @files.images.collect do |file|
|
13
|
+
{ :thumb => file.file.url(:cms_thumb),
|
14
|
+
:image => file.file.url }
|
23
15
|
end
|
24
16
|
render :json => files
|
25
17
|
else
|
@@ -34,28 +26,22 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController
|
|
34
26
|
def create
|
35
27
|
@files = []
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
file_array.each_with_index do |file, i|
|
48
|
-
file_params = params[:file].merge(:file => file)
|
49
|
-
if file_array.size > 1 && file_params[:label].present?
|
50
|
-
label = file_params[:label] + " #{i + 1}"
|
51
|
-
end
|
52
|
-
@file = @site.files.create!(file_params.merge(:label => label))
|
29
|
+
files = [file_params[:file]].flatten
|
30
|
+
files.each_with_index do |file, i|
|
31
|
+
label = (files.size > 1 && file_params[:label].present?) ?
|
32
|
+
"#{file_params[:label]} #{i + 1}" :
|
33
|
+
file_params[:label]
|
34
|
+
@file = @site.files.create!(
|
35
|
+
:file => file,
|
36
|
+
:label => label,
|
37
|
+
:description => file_params[:description]
|
38
|
+
)
|
53
39
|
@files << @file
|
54
40
|
end
|
55
41
|
|
56
42
|
if params[:ajax]
|
57
43
|
view = render_to_string(:partial => 'cms_admin/files/file', :collection => @files, :layout => false)
|
58
|
-
render :json => {:filelink => @file.file.url, :
|
44
|
+
render :json => {:filelink => @file.file.url, :view => view.gsub("\n", '')}
|
59
45
|
else
|
60
46
|
flash[:success] = I18n.t('cms.files.created')
|
61
47
|
redirect_to :action => :edit, :id => @file
|
@@ -72,7 +58,7 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController
|
|
72
58
|
end
|
73
59
|
|
74
60
|
def update
|
75
|
-
@file.update_attributes!(
|
61
|
+
@file.update_attributes!(file_params)
|
76
62
|
flash[:success] = I18n.t('cms.files.updated')
|
77
63
|
redirect_to :action => :edit, :id => @file
|
78
64
|
rescue ActiveRecord::RecordInvalid
|
@@ -113,4 +99,14 @@ protected
|
|
113
99
|
flash[:error] = I18n.t('cms.files.not_found')
|
114
100
|
redirect_to :action => :index
|
115
101
|
end
|
102
|
+
|
103
|
+
def file_params
|
104
|
+
# single file upload
|
105
|
+
unless (file = params[:file]).is_a?(Hash)
|
106
|
+
params[:file] = { }
|
107
|
+
params[:file][:file] = [file]
|
108
|
+
end
|
109
|
+
params.fetch(:file, {}).permit!
|
110
|
+
end
|
111
|
+
|
116
112
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
before_action :build_layout, :only => [:new, :create]
|
4
|
+
before_action :load_layout, :only => [:edit, :update, :destroy]
|
5
5
|
|
6
6
|
def index
|
7
7
|
return redirect_to :action => :new if @site.layouts.count == 0
|
@@ -27,7 +27,7 @@ class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def update
|
30
|
-
@layout.update_attributes!(
|
30
|
+
@layout.update_attributes!(layout_params)
|
31
31
|
flash[:success] = I18n.t('cms.layouts.updated')
|
32
32
|
redirect_to :action => :edit, :id => @layout
|
33
33
|
rescue ActiveRecord::RecordInvalid
|
@@ -52,9 +52,10 @@ class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
|
52
52
|
protected
|
53
53
|
|
54
54
|
def build_layout
|
55
|
-
@layout = @site.layouts.new(
|
56
|
-
@layout.parent
|
57
|
-
@layout.
|
55
|
+
@layout = @site.layouts.new(layout_params)
|
56
|
+
@layout.parent ||= Cms::Layout.find_by_id(params[:parent_id])
|
57
|
+
@layout.app_layout ||= @layout.parent.try(:app_layout)
|
58
|
+
@layout.content ||= '{{ cms:page:content:text }}'
|
58
59
|
end
|
59
60
|
|
60
61
|
def load_layout
|
@@ -63,5 +64,9 @@ protected
|
|
63
64
|
flash[:error] = I18n.t('cms.layouts.not_found')
|
64
65
|
redirect_to :action => :index
|
65
66
|
end
|
66
|
-
|
67
|
+
|
68
|
+
def layout_params
|
69
|
+
params.fetch(:layout, {}).permit!
|
70
|
+
end
|
71
|
+
|
67
72
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
class CmsAdmin::PagesController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
before_action :check_for_layouts, :only => [:new, :edit]
|
4
|
+
before_action :build_cms_page, :only => [:new, :create]
|
5
|
+
before_action :load_cms_page, :only => [:edit, :update, :destroy]
|
6
|
+
before_action :preview_cms_page, :only => [:create, :update]
|
7
|
+
before_action :build_file, :only => [:new, :edit]
|
8
8
|
|
9
9
|
def index
|
10
10
|
return redirect_to :action => :new if @site.pages.count == 0
|
11
|
-
@pages_by_parent = @site.pages.includes(:categories).
|
11
|
+
@pages_by_parent = @site.pages.includes(:categories).group_by(&:parent_id)
|
12
12
|
if params[:category].present?
|
13
|
-
@pages = @site.pages.includes(:categories).for_category(params[:category]).
|
13
|
+
@pages = @site.pages.includes(:categories).for_category(params[:category]).order('label')
|
14
14
|
else
|
15
15
|
@pages = [@site.pages.root].compact
|
16
16
|
end
|
@@ -56,7 +56,7 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def toggle_branch
|
59
|
-
@pages_by_parent = @site.pages.includes(:categories).
|
59
|
+
@pages_by_parent = @site.pages.includes(:categories).group_by(&:parent_id)
|
60
60
|
@page = @site.pages.find(params[:id])
|
61
61
|
s = (session[:cms_page_tree] ||= [])
|
62
62
|
id = @page.id.to_s
|
@@ -82,7 +82,7 @@ protected
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def build_cms_page
|
85
|
-
@page = @site.pages.new(
|
85
|
+
@page = @site.pages.new(page_params)
|
86
86
|
@page.parent ||= (@site.pages.find_by_id(params[:parent_id]) || @site.pages.root)
|
87
87
|
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
88
88
|
end
|
@@ -93,7 +93,7 @@ protected
|
|
93
93
|
|
94
94
|
def load_cms_page
|
95
95
|
@page = @site.pages.find(params[:id])
|
96
|
-
@page.attributes =
|
96
|
+
@page.attributes = page_params
|
97
97
|
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
98
98
|
rescue ActiveRecord::RecordNotFound
|
99
99
|
flash[:error] = I18n.t('cms.pages.not_found')
|
@@ -109,4 +109,8 @@ protected
|
|
109
109
|
render :inline => @page.content(true), :layout => layout, :content_type => 'text/html'
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
def page_params
|
114
|
+
params.fetch(:page, {}).permit!
|
115
|
+
end
|
112
116
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CmsAdmin::RevisionsController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
before_action :load_record
|
4
|
+
before_action :load_revision, :except => :index
|
5
5
|
|
6
6
|
def index
|
7
7
|
redirect_to :action => :show, :id => @record.revisions.first.try(:id) || 0
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class CmsAdmin::SitesController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
3
|
+
skip_before_action :load_admin_site,
|
4
4
|
:load_fixtures
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
before_action :build_site, :only => [:new, :create]
|
7
|
+
before_action :load_site, :only => [:edit, :update, :destroy]
|
8
8
|
|
9
9
|
def index
|
10
10
|
return redirect_to :action => :new if Cms::Site.count == 0
|
@@ -31,7 +31,7 @@ class CmsAdmin::SitesController < CmsAdmin::BaseController
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def update
|
34
|
-
@site.update_attributes!(
|
34
|
+
@site.update_attributes!(site_params)
|
35
35
|
flash[:success] = I18n.t('cms.sites.updated')
|
36
36
|
redirect_to :action => :edit, :id => @site
|
37
37
|
rescue ActiveRecord::RecordInvalid
|
@@ -49,7 +49,7 @@ class CmsAdmin::SitesController < CmsAdmin::BaseController
|
|
49
49
|
protected
|
50
50
|
|
51
51
|
def build_site
|
52
|
-
@site = Cms::Site.new(
|
52
|
+
@site = Cms::Site.new(site_params)
|
53
53
|
@site.hostname ||= request.host.downcase
|
54
54
|
end
|
55
55
|
|
@@ -60,5 +60,9 @@ protected
|
|
60
60
|
flash[:error] = I18n.t('cms.sites.not_found')
|
61
61
|
redirect_to :action => :index
|
62
62
|
end
|
63
|
+
|
64
|
+
def site_params
|
65
|
+
params.fetch(:site, {}).permit!
|
66
|
+
end
|
63
67
|
|
64
68
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
before_action :build_snippet, :only => [:new, :create]
|
4
|
+
before_action :load_snippet, :only => [:edit, :update, :destroy]
|
5
5
|
|
6
6
|
def index
|
7
7
|
return redirect_to :action => :new if @site.snippets.count == 0
|
@@ -27,7 +27,7 @@ class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def update
|
30
|
-
@snippet.update_attributes!(
|
30
|
+
@snippet.update_attributes!(snippet_params)
|
31
31
|
flash[:success] = I18n.t('cms.snippets.updated')
|
32
32
|
redirect_to :action => :edit, :id => @snippet
|
33
33
|
rescue ActiveRecord::RecordInvalid
|
@@ -52,7 +52,7 @@ class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
|
52
52
|
protected
|
53
53
|
|
54
54
|
def build_snippet
|
55
|
-
@snippet = @site.snippets.new(
|
55
|
+
@snippet = @site.snippets.new(snippet_params)
|
56
56
|
end
|
57
57
|
|
58
58
|
def load_snippet
|
@@ -61,4 +61,8 @@ protected
|
|
61
61
|
flash[:error] = I18n.t('cms.snippets.not_found')
|
62
62
|
redirect_to :action => :index
|
63
63
|
end
|
64
|
+
|
65
|
+
def snippet_params
|
66
|
+
params.fetch(:snippet, {}).permit!
|
67
|
+
end
|
64
68
|
end
|
@@ -3,13 +3,13 @@ class CmsContentController < ApplicationController
|
|
3
3
|
# Authentication module must have #authenticate method
|
4
4
|
include ComfortableMexicanSofa.config.public_auth.to_s.constantize
|
5
5
|
|
6
|
-
|
6
|
+
before_action :load_cms_site,
|
7
7
|
:load_fixtures
|
8
|
-
|
8
|
+
before_action :load_cms_page,
|
9
9
|
:authenticate,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
:only => :render_html
|
11
|
+
before_action :load_cms_layout,
|
12
|
+
:only => [:render_css, :render_js]
|
13
13
|
|
14
14
|
def render_html(status = 200)
|
15
15
|
if @cms_layout = @cms_page.layout
|
data/app/models/cms/block.rb
CHANGED