comfortable_mexican_sofa 1.2.8 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/comfortable_mexican_sofa/application.js +3 -3
- data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +1 -1
- data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
- data/app/controllers/cms_admin/base_controller.rb +22 -25
- data/app/controllers/cms_admin/layouts_controller.rb +21 -21
- data/app/controllers/cms_admin/pages_controller.rb +29 -29
- data/app/controllers/cms_admin/revisions_controller.rb +6 -6
- data/app/controllers/cms_admin/sites_controller.rb +21 -20
- data/app/controllers/cms_admin/snippets_controller.rb +19 -20
- data/app/controllers/cms_admin/uploads_controller.rb +6 -6
- data/app/controllers/cms_content_controller.rb +30 -16
- data/app/models/cms/layout.rb +2 -9
- data/app/models/cms/site.rb +11 -6
- data/app/views/cms_admin/layouts/_form.html.erb +6 -6
- data/app/views/cms_admin/layouts/_index_branch.html.erb +10 -10
- data/app/views/cms_admin/layouts/edit.html.erb +6 -5
- data/app/views/cms_admin/layouts/index.html.erb +3 -3
- data/app/views/cms_admin/layouts/new.html.erb +3 -3
- data/app/views/cms_admin/pages/_form.html.erb +11 -11
- data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -4
- data/app/views/cms_admin/pages/_index_branch.html.erb +15 -15
- data/app/views/cms_admin/pages/edit.html.erb +6 -5
- data/app/views/cms_admin/pages/index.html.erb +4 -4
- data/app/views/cms_admin/pages/new.html.erb +3 -3
- data/app/views/cms_admin/pages/toggle_branch.js.erb +3 -3
- data/app/views/cms_admin/revisions/show.html.erb +4 -4
- data/app/views/cms_admin/sites/_form.html.erb +5 -2
- data/app/views/cms_admin/sites/_mirrors.html.erb +6 -6
- data/app/views/cms_admin/sites/edit.html.erb +3 -3
- data/app/views/cms_admin/sites/index.html.erb +9 -9
- data/app/views/cms_admin/sites/new.html.erb +3 -3
- data/app/views/cms_admin/snippets/_form.html.erb +3 -3
- data/app/views/cms_admin/snippets/edit.html.erb +5 -5
- data/app/views/cms_admin/snippets/index.html.erb +9 -9
- data/app/views/cms_admin/snippets/new.html.erb +3 -3
- data/app/views/cms_admin/uploads/_file.html.erb +1 -1
- data/app/views/cms_admin/uploads/_index.html.erb +2 -2
- data/app/views/cms_admin/uploads/destroy.js.erb +1 -1
- data/app/views/layouts/cms_admin/_head.html.erb +2 -0
- data/app/views/layouts/cms_admin/_left.html.erb +6 -6
- data/comfortable_mexican_sofa.gemspec +10 -6
- data/config/boot.rb +3 -10
- data/config/initializers/comfortable_mexican_sofa.rb +14 -22
- data/config/locales/en.yml +179 -4
- data/config/locales/es.yml +179 -0
- data/config/routes.rb +25 -27
- data/db/migrate/01_create_cms.rb +8 -1
- data/db/migrate/upgrades/04_upgrade_to_1_3_0.rb +23 -0
- data/lib/comfortable_mexican_sofa/configuration.rb +15 -19
- data/lib/comfortable_mexican_sofa/fixtures.rb +12 -3
- data/lib/comfortable_mexican_sofa/form_builder.rb +7 -6
- data/lib/comfortable_mexican_sofa/is_mirrored.rb +9 -11
- data/lib/comfortable_mexican_sofa/tags/asset.rb +2 -2
- data/test/fixtures/cms/sites.yml +3 -1
- data/test/functional/cms_admin/base_controller_test.rb +18 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +20 -19
- data/test/functional/cms_admin/pages_controller_test.rb +73 -71
- data/test/functional/cms_admin/revisions_controller_test.rb +23 -20
- data/test/functional/cms_admin/sites_controller_test.rb +8 -8
- data/test/functional/cms_admin/snippets_controller_test.rb +17 -16
- data/test/functional/cms_admin/uploads_controller_test.rb +3 -3
- data/test/integration/authentication_test.rb +4 -4
- data/test/integration/fixtures_test.rb +1 -1
- data/test/integration/mirrors_test.rb +15 -18
- data/test/integration/routing_extensions_test.rb +4 -19
- data/test/integration/sites_test.rb +67 -48
- data/test/test_helper.rb +26 -6
- data/test/unit/configuration_test.rb +5 -5
- data/test/unit/form_builder_test.rb +69 -0
- data/test/unit/mirrors_test.rb +2 -6
- data/test/unit/models/site_test.rb +30 -3
- metadata +55 -56
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Add gem definition to your Gemfile:
|
|
12
12
|
Then from the Rails project's root run:
|
13
13
|
|
14
14
|
bundle install
|
15
|
-
rails
|
15
|
+
rails generate cms
|
16
16
|
rake db:migrate
|
17
17
|
|
18
18
|
When upgrading to a newer version just run `rails g cms` and replace files when prompted. You may also need to run `rake db:migrate` again.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.0
|
@@ -24,9 +24,9 @@ $.CMS = function(){
|
|
24
24
|
return {
|
25
25
|
|
26
26
|
enable_sortable_list: function(){
|
27
|
-
$('
|
28
|
-
handle: '
|
29
|
-
axis:
|
27
|
+
$('.sortable, ul.sortable ul').sortable({
|
28
|
+
handle: '.dragger',
|
29
|
+
axis: 'y',
|
30
30
|
update: function(){
|
31
31
|
$.post(current_path + '/reorder', '_method=put&'+$(this).sortable('serialize'));
|
32
32
|
}
|
@@ -1,43 +1,40 @@
|
|
1
1
|
class CmsAdmin::BaseController < ApplicationController
|
2
|
-
|
2
|
+
|
3
3
|
protect_from_forgery
|
4
|
-
|
4
|
+
|
5
5
|
# Authentication module must have #authenticate method
|
6
6
|
include ComfortableMexicanSofa.config.authentication.to_s.constantize
|
7
|
-
|
7
|
+
|
8
8
|
before_filter :authenticate,
|
9
|
-
:
|
10
|
-
:load_fixtures
|
9
|
+
:load_admin_site,
|
10
|
+
:load_fixtures,
|
11
|
+
:except => :jump
|
11
12
|
|
12
13
|
layout 'cms_admin'
|
13
14
|
|
15
|
+
def jump
|
16
|
+
path = ComfortableMexicanSofa.config.admin_route_redirect
|
17
|
+
return redirect_to(path) unless path.blank?
|
18
|
+
load_admin_site
|
19
|
+
redirect_to cms_admin_site_pages_path(@site) if @site
|
20
|
+
end
|
21
|
+
|
14
22
|
protected
|
15
23
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
unless ComfortableMexicanSofa.config.enable_multiple_sites
|
22
|
-
if Cms::Site.count == 0
|
23
|
-
@cms_site = Cms::Site.create!(:label => 'Default Site', :hostname => hostname)
|
24
|
-
else
|
25
|
-
@cms_site = Cms::Site.first
|
26
|
-
@cms_site.update_attribute(:hostname, hostname)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
unless @cms_site
|
31
|
-
flash[:error] = 'No Site defined for this hostname. Create it now.'
|
32
|
-
return redirect_to(cms_admin_sites_path)
|
24
|
+
def load_admin_site
|
25
|
+
unless (@site = Cms::Site.find_by_id(params[:site_id]) || Cms::Site.first)
|
26
|
+
I18n.locale = ComfortableMexicanSofa.config.admin_locale || I18n.default_locale
|
27
|
+
flash[:error] = I18n.t('cms.base.site_not_found')
|
28
|
+
return redirect_to(new_cms_admin_site_path)
|
33
29
|
end
|
30
|
+
I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale
|
34
31
|
end
|
35
|
-
|
32
|
+
|
36
33
|
def load_fixtures
|
37
34
|
return unless ComfortableMexicanSofa.config.enable_fixtures
|
38
|
-
ComfortableMexicanSofa::Fixtures.import_all(@
|
35
|
+
ComfortableMexicanSofa::Fixtures.import_all(@site.hostname)
|
39
36
|
if %w(cms_admin/layouts cms_admin/pages cms_admin/snippets).member?(params[:controller])
|
40
|
-
flash.now[:error] = '
|
37
|
+
flash.now[:error] = I18n.t('cms.base.fixtures_enabled')
|
41
38
|
end
|
42
39
|
end
|
43
40
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
before_filter :
|
4
|
-
before_filter :
|
3
|
+
before_filter :build_layout, :only => [:new, :create]
|
4
|
+
before_filter :load_layout, :only => [:edit, :update, :destroy]
|
5
5
|
|
6
6
|
def index
|
7
|
-
return redirect_to :action => :new if @
|
8
|
-
@
|
7
|
+
return redirect_to :action => :new if @site.layouts.count == 0
|
8
|
+
@layouts = @site.layouts.roots
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
@@ -17,41 +17,41 @@ class CmsAdmin::LayoutsController < CmsAdmin::BaseController
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
20
|
-
@
|
21
|
-
flash[:notice] = '
|
22
|
-
redirect_to :action => :edit, :id => @
|
20
|
+
@layout.save!
|
21
|
+
flash[:notice] = I18n.t('cms.layouts.created')
|
22
|
+
redirect_to :action => :edit, :id => @layout
|
23
23
|
rescue ActiveRecord::RecordInvalid
|
24
|
-
flash.now[:error] = '
|
24
|
+
flash.now[:error] = I18n.t('cms.layouts.creation_failure')
|
25
25
|
render :action => :new
|
26
26
|
end
|
27
27
|
|
28
28
|
def update
|
29
|
-
@
|
30
|
-
flash[:notice] = '
|
31
|
-
redirect_to :action => :edit, :id => @
|
29
|
+
@layout.update_attributes!(params[:layout])
|
30
|
+
flash[:notice] = I18n.t('cms.layouts.updated')
|
31
|
+
redirect_to :action => :edit, :id => @layout
|
32
32
|
rescue ActiveRecord::RecordInvalid
|
33
|
-
flash.now[:error] = '
|
33
|
+
flash.now[:error] = I18n.t('cms.layouts.update_failure')
|
34
34
|
render :action => :edit
|
35
35
|
end
|
36
36
|
|
37
37
|
def destroy
|
38
|
-
@
|
39
|
-
flash[:notice] = '
|
38
|
+
@layout.destroy
|
39
|
+
flash[:notice] = I18n.t('cms.layouts.deleted')
|
40
40
|
redirect_to :action => :index
|
41
41
|
end
|
42
42
|
|
43
43
|
protected
|
44
44
|
|
45
|
-
def
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
45
|
+
def build_layout
|
46
|
+
@layout = @site.layouts.new(params[:layout])
|
47
|
+
@layout.parent ||= Cms::Layout.find_by_id(params[:parent_id])
|
48
|
+
@layout.content ||= '{{ cms:page:content:text }}'
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
@
|
51
|
+
def load_layout
|
52
|
+
@layout = @site.layouts.find(params[:id])
|
53
53
|
rescue ActiveRecord::RecordNotFound
|
54
|
-
flash[:error] = '
|
54
|
+
flash[:error] = I18n.t('cms.layouts.not_found')
|
55
55
|
redirect_to :action => :index
|
56
56
|
end
|
57
57
|
|
@@ -7,8 +7,8 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController
|
|
7
7
|
before_filter :build_upload_file, :only => [:new, :edit]
|
8
8
|
|
9
9
|
def index
|
10
|
-
return redirect_to :action => :new if @
|
11
|
-
@
|
10
|
+
return redirect_to :action => :new if @site.pages.count == 0
|
11
|
+
@pages = [@site.pages.root].compact
|
12
12
|
end
|
13
13
|
|
14
14
|
def new
|
@@ -20,45 +20,45 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
|
-
@
|
24
|
-
flash[:notice] = '
|
25
|
-
redirect_to :action => :edit, :id => @
|
23
|
+
@page.save!
|
24
|
+
flash[:notice] = I18n.t('cms.pages.created')
|
25
|
+
redirect_to :action => :edit, :id => @page
|
26
26
|
rescue ActiveRecord::RecordInvalid
|
27
|
-
flash.now[:error] = '
|
27
|
+
flash.now[:error] = I18n.t('cms.pages.creation_failure')
|
28
28
|
render :action => :new
|
29
29
|
end
|
30
30
|
|
31
31
|
def update
|
32
|
-
@
|
33
|
-
flash[:notice] = '
|
34
|
-
redirect_to :action => :edit, :id => @
|
32
|
+
@page.save!
|
33
|
+
flash[:notice] = I18n.t('cms.pages.updated')
|
34
|
+
redirect_to :action => :edit, :id => @page
|
35
35
|
rescue ActiveRecord::RecordInvalid
|
36
|
-
flash.now[:error] = '
|
36
|
+
flash.now[:error] = I18n.t('cms.pages.update_failure')
|
37
37
|
render :action => :edit
|
38
38
|
end
|
39
39
|
|
40
40
|
def destroy
|
41
|
-
@
|
42
|
-
flash[:notice] = '
|
41
|
+
@page.destroy
|
42
|
+
flash[:notice] = I18n.t('cms.pages.deleted')
|
43
43
|
redirect_to :action => :index
|
44
44
|
end
|
45
45
|
|
46
46
|
def form_blocks
|
47
|
-
@
|
48
|
-
@
|
47
|
+
@page = @site.pages.find_by_id(params[:id]) || @site.pages.new
|
48
|
+
@page.layout = @site.layouts.find_by_id(params[:layout_id])
|
49
49
|
end
|
50
50
|
|
51
51
|
def toggle_branch
|
52
|
-
@
|
52
|
+
@page = @site.pages.find(params[:id])
|
53
53
|
s = (session[:cms_page_tree] ||= [])
|
54
|
-
id = @
|
54
|
+
id = @page.id.to_s
|
55
55
|
s.member?(id) ? s.delete(id) : s << id
|
56
56
|
rescue ActiveRecord::RecordNotFound
|
57
57
|
# do nothing
|
58
58
|
end
|
59
59
|
|
60
60
|
def reorder
|
61
|
-
(params[:
|
61
|
+
(params[:page] || []).each_with_index do |id, index|
|
62
62
|
if (cms_page = Cms::Page.find_by_id(id))
|
63
63
|
cms_page.update_attribute(:position, index)
|
64
64
|
end
|
@@ -69,16 +69,16 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController
|
|
69
69
|
protected
|
70
70
|
|
71
71
|
def check_for_layouts
|
72
|
-
if @
|
73
|
-
flash[:error] = '
|
74
|
-
redirect_to
|
72
|
+
if @site.layouts.count == 0
|
73
|
+
flash[:error] = I18n.t('cms.pages.layout_not_found')
|
74
|
+
redirect_to new_cms_admin_site_layout_path(@site)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
def build_cms_page
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@
|
79
|
+
@page = @site.pages.new(params[:page])
|
80
|
+
@page.parent ||= (@site.pages.find_by_id(params[:parent_id]) || @site.pages.root)
|
81
|
+
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
82
82
|
end
|
83
83
|
|
84
84
|
def build_upload_file
|
@@ -86,18 +86,18 @@ protected
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def load_cms_page
|
89
|
-
@
|
90
|
-
@
|
91
|
-
@
|
89
|
+
@page = @site.pages.find(params[:id])
|
90
|
+
@page.attributes = params[:page]
|
91
|
+
@page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first)
|
92
92
|
rescue ActiveRecord::RecordNotFound
|
93
|
-
flash[:error] = '
|
93
|
+
flash[:error] = I18n.t('cms.pages.not_found')
|
94
94
|
redirect_to :action => :index
|
95
95
|
end
|
96
96
|
|
97
97
|
def preview_cms_page
|
98
98
|
if params[:preview]
|
99
|
-
layout = @
|
100
|
-
render :inline => @
|
99
|
+
layout = @page.layout.app_layout.blank?? false : @page.layout.app_layout
|
100
|
+
render :inline => @page.content(true), :layout => layout
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -20,7 +20,7 @@ class CmsAdmin::RevisionsController < CmsAdmin::BaseController
|
|
20
20
|
|
21
21
|
def revert
|
22
22
|
@record.restore_from_revision(@revision)
|
23
|
-
flash[:notice] = '
|
23
|
+
flash[:notice] = I18n.t('cms.revisions.reverted')
|
24
24
|
redirect_to_record
|
25
25
|
end
|
26
26
|
|
@@ -35,22 +35,22 @@ protected
|
|
35
35
|
Cms::Snippet.find(params[:snippet_id])
|
36
36
|
end
|
37
37
|
rescue ActiveRecord::RecordNotFound
|
38
|
-
flash[:error] = '
|
38
|
+
flash[:error] = I18n.t('cms.revisions.record_not_found')
|
39
39
|
redirect_to cms_admin_path
|
40
40
|
end
|
41
41
|
|
42
42
|
def load_revision
|
43
43
|
@revision = @record.revisions.find(params[:id])
|
44
44
|
rescue ActiveRecord::RecordNotFound
|
45
|
-
flash[:error] = '
|
45
|
+
flash[:error] = I18n.t('cms.revisions.not_found')
|
46
46
|
redirect_to_record
|
47
47
|
end
|
48
48
|
|
49
49
|
def redirect_to_record
|
50
50
|
redirect_to case @record
|
51
|
-
when Cms::Layout then
|
52
|
-
when Cms::Page then
|
53
|
-
when Cms::Snippet then
|
51
|
+
when Cms::Layout then edit_cms_admin_site_layout_path(@site, @record)
|
52
|
+
when Cms::Page then edit_cms_admin_site_page_path(@site, @record)
|
53
|
+
when Cms::Snippet then edit_cms_admin_site_snippet_path(@site, @record)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class CmsAdmin::SitesController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
skip_before_filter :
|
3
|
+
skip_before_filter :load_admin_site,
|
4
4
|
:load_fixtures
|
5
5
|
|
6
|
-
before_filter :
|
7
|
-
before_filter :
|
6
|
+
before_filter :build_site, :only => [:new, :create]
|
7
|
+
before_filter :load_site, :only => [:edit, :update, :destroy]
|
8
8
|
|
9
9
|
def index
|
10
10
|
return redirect_to :action => :new if Cms::Site.count == 0
|
11
|
-
@
|
11
|
+
@sites = Cms::Site.all
|
12
12
|
end
|
13
13
|
|
14
14
|
def new
|
@@ -20,40 +20,41 @@ class CmsAdmin::SitesController < CmsAdmin::BaseController
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create
|
23
|
-
@
|
24
|
-
flash[:notice] = '
|
25
|
-
redirect_to :action => :edit, :id => @
|
23
|
+
@site.save!
|
24
|
+
flash[:notice] = I18n.t('cms.sites.created')
|
25
|
+
redirect_to :action => :edit, :id => @site
|
26
26
|
rescue ActiveRecord::RecordInvalid
|
27
|
-
flash.now[:error] = '
|
27
|
+
flash.now[:error] = I18n.t('cms.sites.creation_failure')
|
28
28
|
render :action => :new
|
29
29
|
end
|
30
30
|
|
31
31
|
def update
|
32
|
-
@
|
33
|
-
flash[:notice] = '
|
34
|
-
redirect_to :action => :edit, :id => @
|
32
|
+
@site.update_attributes!(params[:site])
|
33
|
+
flash[:notice] = I18n.t('cms.sites.updated')
|
34
|
+
redirect_to :action => :edit, :id => @site
|
35
35
|
rescue ActiveRecord::RecordInvalid
|
36
|
-
flash.now[:error] = '
|
36
|
+
flash.now[:error] = I18n.t('cms.sites.update_failure')
|
37
37
|
render :action => :edit
|
38
38
|
end
|
39
39
|
|
40
40
|
def destroy
|
41
|
-
@
|
42
|
-
flash[:notice] = '
|
41
|
+
@site.destroy
|
42
|
+
flash[:notice] = I18n.t('cms.sites.deleted')
|
43
43
|
redirect_to :action => :index
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
47
47
|
|
48
|
-
def
|
49
|
-
@
|
50
|
-
@
|
48
|
+
def build_site
|
49
|
+
@site = Cms::Site.new(params[:site])
|
50
|
+
@site.hostname ||= request.host.downcase
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
@
|
53
|
+
def load_site
|
54
|
+
@site = Cms::Site.find(params[:id])
|
55
|
+
I18n.locale = ComfortableMexicanSofa.config.admin_locale || @site.locale
|
55
56
|
rescue ActiveRecord::RecordNotFound
|
56
|
-
flash[:error] = '
|
57
|
+
flash[:error] = I18n.t('cms.sites.not_found')
|
57
58
|
redirect_to :action => :index
|
58
59
|
end
|
59
60
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
2
2
|
|
3
|
-
before_filter :
|
4
|
-
before_filter :
|
3
|
+
before_filter :build_snippet, :only => [:new, :create]
|
4
|
+
before_filter :load_snippet, :only => [:edit, :update, :destroy]
|
5
5
|
|
6
6
|
def index
|
7
|
-
return redirect_to :action => :new if @
|
8
|
-
@
|
7
|
+
return redirect_to :action => :new if @site.snippets.count == 0
|
8
|
+
@snippets = @site.snippets.all(:order => 'label')
|
9
9
|
end
|
10
10
|
|
11
11
|
def new
|
@@ -17,40 +17,39 @@ class CmsAdmin::SnippetsController < CmsAdmin::BaseController
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
redirect_to :action => :edit, :id => @cms_snippet
|
20
|
+
@snippet.save!
|
21
|
+
flash[:notice] = I18n.t('cms.snippets.created')
|
22
|
+
redirect_to :action => :edit, :id => @snippet
|
24
23
|
rescue ActiveRecord::RecordInvalid
|
25
|
-
flash.now[:error] = '
|
24
|
+
flash.now[:error] = I18n.t('cms.snippets.creation_failure')
|
26
25
|
render :action => :new
|
27
26
|
end
|
28
27
|
|
29
28
|
def update
|
30
|
-
@
|
31
|
-
flash[:notice] = '
|
32
|
-
redirect_to :action => :edit, :id => @
|
29
|
+
@snippet.update_attributes!(params[:snippet])
|
30
|
+
flash[:notice] = I18n.t('cms.snippets.updated')
|
31
|
+
redirect_to :action => :edit, :id => @snippet
|
33
32
|
rescue ActiveRecord::RecordInvalid
|
34
|
-
flash.now[:error] = '
|
33
|
+
flash.now[:error] = I18n.t('cms.snippets.update_failure')
|
35
34
|
render :action => :edit
|
36
35
|
end
|
37
36
|
|
38
37
|
def destroy
|
39
|
-
@
|
40
|
-
flash[:notice] = '
|
38
|
+
@snippet.destroy
|
39
|
+
flash[:notice] = I18n.t('cms.snippets.deleted')
|
41
40
|
redirect_to :action => :index
|
42
41
|
end
|
43
42
|
|
44
43
|
protected
|
45
44
|
|
46
|
-
def
|
47
|
-
@
|
45
|
+
def build_snippet
|
46
|
+
@snippet = @site.snippets.new(params[:snippet])
|
48
47
|
end
|
49
48
|
|
50
|
-
def
|
51
|
-
@
|
49
|
+
def load_snippet
|
50
|
+
@snippet = @site.snippets.find(params[:id])
|
52
51
|
rescue ActiveRecord::RecordNotFound
|
53
|
-
flash[:error] = '
|
52
|
+
flash[:error] = I18n.t('cms.snippets.not_found')
|
54
53
|
redirect_to :action => :index
|
55
54
|
end
|
56
55
|
end
|