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.
Files changed (75) hide show
  1. data/Gemfile +1 -1
  2. data/README.md +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/comfortable_mexican_sofa/application.js +3 -3
  5. data/app/assets/javascripts/comfortable_mexican_sofa/wymeditor/jquery.wymeditor.cms.js +1 -1
  6. data/app/assets/stylesheets/comfortable_mexican_sofa/structure.css +1 -1
  7. data/app/controllers/cms_admin/base_controller.rb +22 -25
  8. data/app/controllers/cms_admin/layouts_controller.rb +21 -21
  9. data/app/controllers/cms_admin/pages_controller.rb +29 -29
  10. data/app/controllers/cms_admin/revisions_controller.rb +6 -6
  11. data/app/controllers/cms_admin/sites_controller.rb +21 -20
  12. data/app/controllers/cms_admin/snippets_controller.rb +19 -20
  13. data/app/controllers/cms_admin/uploads_controller.rb +6 -6
  14. data/app/controllers/cms_content_controller.rb +30 -16
  15. data/app/models/cms/layout.rb +2 -9
  16. data/app/models/cms/site.rb +11 -6
  17. data/app/views/cms_admin/layouts/_form.html.erb +6 -6
  18. data/app/views/cms_admin/layouts/_index_branch.html.erb +10 -10
  19. data/app/views/cms_admin/layouts/edit.html.erb +6 -5
  20. data/app/views/cms_admin/layouts/index.html.erb +3 -3
  21. data/app/views/cms_admin/layouts/new.html.erb +3 -3
  22. data/app/views/cms_admin/pages/_form.html.erb +11 -11
  23. data/app/views/cms_admin/pages/_form_blocks.html.erb +3 -4
  24. data/app/views/cms_admin/pages/_index_branch.html.erb +15 -15
  25. data/app/views/cms_admin/pages/edit.html.erb +6 -5
  26. data/app/views/cms_admin/pages/index.html.erb +4 -4
  27. data/app/views/cms_admin/pages/new.html.erb +3 -3
  28. data/app/views/cms_admin/pages/toggle_branch.js.erb +3 -3
  29. data/app/views/cms_admin/revisions/show.html.erb +4 -4
  30. data/app/views/cms_admin/sites/_form.html.erb +5 -2
  31. data/app/views/cms_admin/sites/_mirrors.html.erb +6 -6
  32. data/app/views/cms_admin/sites/edit.html.erb +3 -3
  33. data/app/views/cms_admin/sites/index.html.erb +9 -9
  34. data/app/views/cms_admin/sites/new.html.erb +3 -3
  35. data/app/views/cms_admin/snippets/_form.html.erb +3 -3
  36. data/app/views/cms_admin/snippets/edit.html.erb +5 -5
  37. data/app/views/cms_admin/snippets/index.html.erb +9 -9
  38. data/app/views/cms_admin/snippets/new.html.erb +3 -3
  39. data/app/views/cms_admin/uploads/_file.html.erb +1 -1
  40. data/app/views/cms_admin/uploads/_index.html.erb +2 -2
  41. data/app/views/cms_admin/uploads/destroy.js.erb +1 -1
  42. data/app/views/layouts/cms_admin/_head.html.erb +2 -0
  43. data/app/views/layouts/cms_admin/_left.html.erb +6 -6
  44. data/comfortable_mexican_sofa.gemspec +10 -6
  45. data/config/boot.rb +3 -10
  46. data/config/initializers/comfortable_mexican_sofa.rb +14 -22
  47. data/config/locales/en.yml +179 -4
  48. data/config/locales/es.yml +179 -0
  49. data/config/routes.rb +25 -27
  50. data/db/migrate/01_create_cms.rb +8 -1
  51. data/db/migrate/upgrades/04_upgrade_to_1_3_0.rb +23 -0
  52. data/lib/comfortable_mexican_sofa/configuration.rb +15 -19
  53. data/lib/comfortable_mexican_sofa/fixtures.rb +12 -3
  54. data/lib/comfortable_mexican_sofa/form_builder.rb +7 -6
  55. data/lib/comfortable_mexican_sofa/is_mirrored.rb +9 -11
  56. data/lib/comfortable_mexican_sofa/tags/asset.rb +2 -2
  57. data/test/fixtures/cms/sites.yml +3 -1
  58. data/test/functional/cms_admin/base_controller_test.rb +18 -0
  59. data/test/functional/cms_admin/layouts_controller_test.rb +20 -19
  60. data/test/functional/cms_admin/pages_controller_test.rb +73 -71
  61. data/test/functional/cms_admin/revisions_controller_test.rb +23 -20
  62. data/test/functional/cms_admin/sites_controller_test.rb +8 -8
  63. data/test/functional/cms_admin/snippets_controller_test.rb +17 -16
  64. data/test/functional/cms_admin/uploads_controller_test.rb +3 -3
  65. data/test/integration/authentication_test.rb +4 -4
  66. data/test/integration/fixtures_test.rb +1 -1
  67. data/test/integration/mirrors_test.rb +15 -18
  68. data/test/integration/routing_extensions_test.rb +4 -19
  69. data/test/integration/sites_test.rb +67 -48
  70. data/test/test_helper.rb +26 -6
  71. data/test/unit/configuration_test.rb +5 -5
  72. data/test/unit/form_builder_test.rb +69 -0
  73. data/test/unit/mirrors_test.rb +2 -6
  74. data/test/unit/models/site_test.rb +30 -3
  75. metadata +55 -56
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '>=3.0.0'
4
- gem 'active_link_to', '>=0.0.7'
4
+ gem 'active_link_to', '>=0.0.0'
5
5
  gem 'paperclip', '>=2.3.11'
6
6
 
7
7
  group :development do
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 g cms
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.2.8
1
+ 1.3.0
@@ -24,9 +24,9 @@ $.CMS = function(){
24
24
  return {
25
25
 
26
26
  enable_sortable_list: function(){
27
- $('ul.sortable, ul.sortable ul').sortable({
28
- handle: 'div.dragger',
29
- axis: 'y',
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
  }
@@ -2,7 +2,7 @@
2
2
  var cms_wym_options = {
3
3
 
4
4
  initSkin: false,
5
- lang: 'en',
5
+ lang: $('meta[name="cms-locale"]').attr('content'),
6
6
 
7
7
  updateSelector: 'form',
8
8
  updateEvent: 'submit',
@@ -14,7 +14,7 @@ html, body {
14
14
  position: relative;
15
15
  margin: 0px 250px 0px 175px;
16
16
  min-height: 100%;
17
- background-color: #D8D8D8;
17
+ background-color: #e6e6e6;
18
18
  }
19
19
  .center_column .center_column_content {
20
20
  padding: 25px;
@@ -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
- :load_admin_cms_site,
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 load_admin_cms_site
17
- hostname = request.host.downcase
18
- @cms_site = Cms::Site.find_by_hostname!(hostname)
19
-
20
- rescue ActiveRecord::RecordNotFound
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(@cms_site.hostname)
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] = 'CMS Fixtures are enabled. All changes done here will be discarded.'
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 :build_cms_layout, :only => [:new, :create]
4
- before_filter :load_cms_layout, :only => [:edit, :update, :destroy]
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 @cms_site.layouts.count == 0
8
- @cms_layouts = @cms_site.layouts.roots
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
- @cms_layout.save!
21
- flash[:notice] = 'Layout created'
22
- redirect_to :action => :edit, :id => @cms_layout
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] = 'Failed to create layout'
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
- @cms_layout.update_attributes!(params[:cms_layout])
30
- flash[:notice] = 'Layout updated'
31
- redirect_to :action => :edit, :id => @cms_layout
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] = 'Failed to update layout'
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
- @cms_layout.destroy
39
- flash[:notice] = 'Layout deleted'
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 build_cms_layout
46
- @cms_layout = @cms_site.layouts.new(params[:cms_layout])
47
- @cms_layout.parent ||= Cms::Layout.find_by_id(params[:parent_id])
48
- @cms_layout.content ||= '{{ cms:page:content:text }}'
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 load_cms_layout
52
- @cms_layout = @cms_site.layouts.find(params[:id])
51
+ def load_layout
52
+ @layout = @site.layouts.find(params[:id])
53
53
  rescue ActiveRecord::RecordNotFound
54
- flash[:error] = 'Layout not found'
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 @cms_site.pages.count == 0
11
- @cms_pages = [@cms_site.pages.root].compact
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
- @cms_page.save!
24
- flash[:notice] = 'Page saved'
25
- redirect_to :action => :edit, :id => @cms_page
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] = 'Failed to create page'
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
- @cms_page.save!
33
- flash[:notice] = 'Page updated'
34
- redirect_to :action => :edit, :id => @cms_page
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] = 'Failed to update page'
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
- @cms_page.destroy
42
- flash[:notice] = 'Page deleted'
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
- @cms_page = @cms_site.pages.find_by_id(params[:id]) || @cms_site.pages.new
48
- @cms_page.layout = @cms_site.layouts.find_by_id(params[:layout_id])
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
- @cms_page = @cms_site.pages.find(params[:id])
52
+ @page = @site.pages.find(params[:id])
53
53
  s = (session[:cms_page_tree] ||= [])
54
- id = @cms_page.id.to_s
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[:cms_page] || []).each_with_index do |id, index|
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 @cms_site.layouts.count == 0
73
- flash[:error] = 'No Layouts found. Please create one.'
74
- redirect_to new_cms_admin_layout_path
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
- @cms_page = @cms_site.pages.new(params[:cms_page])
80
- @cms_page.parent ||= (@cms_site.pages.find_by_id(params[:parent_id]) || @cms_site.pages.root)
81
- @cms_page.layout ||= (@cms_page.parent && @cms_page.parent.layout || @cms_site.layouts.first)
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
- @cms_page = @cms_site.pages.find(params[:id])
90
- @cms_page.attributes = params[:cms_page]
91
- @cms_page.layout ||= (@cms_page.parent && @cms_page.parent.layout || @cms_site.layouts.first)
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] = 'Page not found'
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 = @cms_page.layout.app_layout.blank?? false : @cms_page.layout.app_layout
100
- render :inline => @cms_page.content(true), :layout => layout
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] = 'Content Reverted'
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] = 'Record Not Found'
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] = 'Revision Not Found'
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 edit_cms_admin_layout_path(@record)
52
- when Cms::Page then edit_cms_admin_page_path(@record)
53
- when Cms::Snippet then edit_cms_admin_snippet_path(@record)
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 :load_admin_cms_site,
3
+ skip_before_filter :load_admin_site,
4
4
  :load_fixtures
5
5
 
6
- before_filter :build_cms_site, :only => [:new, :create]
7
- before_filter :load_cms_site, :only => [:edit, :update, :destroy]
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
- @cms_sites = Cms::Site.all
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
- @cms_site.save!
24
- flash[:notice] = 'Site created'
25
- redirect_to :action => :edit, :id => @cms_site
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] = 'Failed to create site'
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
- @cms_site.update_attributes!(params[:cms_site])
33
- flash[:notice] = 'Site updated'
34
- redirect_to :action => :edit, :id => @cms_site
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] = 'Failed to update site'
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
- @cms_site.destroy
42
- flash[:notice] = 'Site deleted'
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 build_cms_site
49
- @cms_site = Cms::Site.new(params[:cms_site])
50
- @cms_site.hostname ||= request.host.downcase
48
+ def build_site
49
+ @site = Cms::Site.new(params[:site])
50
+ @site.hostname ||= request.host.downcase
51
51
  end
52
52
 
53
- def load_cms_site
54
- @cms_site = Cms::Site.find(params[:id])
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] = 'Site not found'
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 :build_cms_snippet, :only => [:new, :create]
4
- before_filter :load_cms_snippet, :only => [:edit, :update, :destroy]
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 @cms_site.snippets.count == 0
8
- @cms_snippets = @cms_site.snippets.all(:order => 'label')
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
- # raise @cms_snippet.to_yaml
21
- @cms_snippet.save!
22
- flash[:notice] = 'Snippet created'
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] = 'Failed to create snippet'
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
- @cms_snippet.update_attributes!(params[:cms_snippet])
31
- flash[:notice] = 'Snippet updated'
32
- redirect_to :action => :edit, :id => @cms_snippet
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] = 'Failed to update snippet'
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
- @cms_snippet.destroy
40
- flash[:notice] = 'Snippet deleted'
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 build_cms_snippet
47
- @cms_snippet = @cms_site.snippets.new(params[:cms_snippet])
45
+ def build_snippet
46
+ @snippet = @site.snippets.new(params[:snippet])
48
47
  end
49
48
 
50
- def load_cms_snippet
51
- @cms_snippet = @cms_site.snippets.find(params[:id])
49
+ def load_snippet
50
+ @snippet = @site.snippets.find(params[:id])
52
51
  rescue ActiveRecord::RecordNotFound
53
- flash[:error] = 'Snippet not found'
52
+ flash[:error] = I18n.t('cms.snippets.not_found')
54
53
  redirect_to :action => :index
55
54
  end
56
55
  end