locomotive_cms 0.0.2.9 → 0.0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/Gemfile +1 -0
  2. data/app/controllers/admin/accounts_controller.rb +5 -11
  3. data/app/controllers/admin/asset_collections_controller.rb +5 -46
  4. data/app/controllers/admin/assets_controller.rb +12 -30
  5. data/app/controllers/admin/base_controller.rb +15 -19
  6. data/app/controllers/admin/content_types_controller.rb +1 -46
  7. data/app/controllers/admin/contents_controller.rb +15 -42
  8. data/app/controllers/admin/current_sites_controller.rb +10 -11
  9. data/app/controllers/admin/custom_fields_controller.rb +1 -1
  10. data/app/controllers/admin/layouts_controller.rb +2 -46
  11. data/app/controllers/admin/memberships_controller.rb +5 -18
  12. data/app/controllers/admin/my_accounts_controller.rb +11 -9
  13. data/app/controllers/admin/pages_controller.rb +6 -45
  14. data/app/controllers/admin/sitemaps_controller.rb +16 -0
  15. data/app/controllers/admin/sites_controller.rb +12 -19
  16. data/app/controllers/admin/snippets_controller.rb +2 -45
  17. data/app/controllers/admin/theme_assets_controller.rb +13 -54
  18. data/app/helpers/admin/assets_helper.rb +1 -1
  19. data/app/helpers/admin/base_helper.rb +2 -2
  20. data/app/helpers/admin/pages_helper.rb +13 -0
  21. data/app/models/membership.rb +4 -1
  22. data/app/models/page.rb +8 -1
  23. data/app/models/page_part.rb +1 -4
  24. data/app/views/admin/asset_collections/_asset.html.haml +1 -1
  25. data/app/views/admin/asset_collections/edit.html.haml +7 -7
  26. data/app/views/admin/asset_collections/new.html.haml +1 -1
  27. data/app/views/admin/assets/_form.html.haml +1 -1
  28. data/app/views/admin/assets/edit.html.haml +3 -3
  29. data/app/views/admin/assets/new.html.haml +2 -2
  30. data/app/views/admin/content_types/edit.html.haml +1 -1
  31. data/app/views/admin/contents/edit.html.haml +1 -1
  32. data/app/views/admin/contents/index.html.haml +1 -1
  33. data/app/views/admin/contents/new.html.haml +1 -1
  34. data/app/views/admin/current_sites/edit.html.haml +3 -3
  35. data/app/views/admin/layouts/edit.html.haml +2 -2
  36. data/app/views/admin/layouts/index.html.haml +1 -1
  37. data/app/views/admin/my_accounts/edit.html.haml +3 -3
  38. data/app/views/admin/pages/edit.html.haml +1 -1
  39. data/app/views/admin/pages/index.html.haml +1 -1
  40. data/app/views/admin/shared/_head.html.haml +1 -1
  41. data/app/views/admin/shared/menu/_assets.html.haml +2 -2
  42. data/app/views/admin/sitemaps/show.xml.builder +18 -0
  43. data/app/views/admin/snippets/edit.html.haml +2 -2
  44. data/app/views/admin/snippets/index.html.haml +1 -1
  45. data/app/views/admin/theme_assets/_form.html.haml +9 -9
  46. data/app/views/admin/theme_assets/edit.html.haml +4 -4
  47. data/app/views/admin/theme_assets/index.html.haml +1 -1
  48. data/app/views/admin/theme_assets/new.html.haml +1 -1
  49. data/app/views/layouts/admin/application.html.haml +1 -0
  50. data/config/initializers/locomotive.rb +21 -0
  51. data/config/locales/admin_ui_en.yml +2 -66
  52. data/config/locales/admin_ui_fr.yml +0 -64
  53. data/config/locales/flash.en.yml +116 -0
  54. data/config/locales/flash.fr.yml +116 -0
  55. data/config/routes.rb +3 -0
  56. data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +14 -0
  57. data/lib/generators/locomotive/install/install_generator.rb +15 -2
  58. data/lib/generators/locomotive/install/templates/README +17 -0
  59. data/lib/locomotive.rb +3 -0
  60. data/lib/locomotive/admin_responder.rb +28 -0
  61. data/lib/locomotive/inherited_resources.rb +46 -0
  62. data/lib/locomotive/liquid/drops/page.rb +1 -1
  63. data/lib/locomotive/liquid/filters/text.rb +1 -1
  64. data/lib/locomotive/liquid/tags/nav.rb +7 -4
  65. data/public/images/admin/icons/actions.png +0 -0
  66. data/public/images/admin/menu/icons/assets.png +0 -0
  67. data/public/javascripts/admin/application.js +3 -0
  68. data/public/javascripts/admin/pages.js +1 -1
  69. data/public/javascripts/admin/plugins/shortcut.js +55 -0
  70. data/public/stylesheets/admin/application.css +1 -1
  71. data/public/stylesheets/admin/buttons.css +8 -13
  72. data/public/stylesheets/admin/formtastic_changes.css +1 -2
  73. data/public/stylesheets/admin/layout.css +24 -12
  74. data/public/stylesheets/admin/menu.css +3 -3
  75. data/spec/factories.rb +1 -1
  76. data/spec/lib/locomotive/liquid/tags/nav_spec.rb +11 -2
  77. data/spec/models/membership_spec.rb +5 -4
  78. data/spec/models/page_spec.rb +10 -8
  79. metadata +30 -6
  80. data/lib/generators/locomotive/assets/assets_generator.rb +0 -16
data/Gemfile CHANGED
@@ -23,6 +23,7 @@ gem 'actionmailer-with-request', :require => 'actionmailer_with_request'
23
23
  gem 'heroku'
24
24
  gem 'httparty', '0.6.0'
25
25
  gem 'RedCloth'
26
+ gem 'inherited_resources', '1.1.2'
26
27
 
27
28
  # Development environment
28
29
  group :development do
@@ -8,17 +8,11 @@ module Admin
8
8
  end
9
9
 
10
10
  def create
11
- @account = Account.new(params[:account])
12
-
13
- if @account.save
14
- current_site.memberships.create(:account => @account)
15
- flash_success!
16
- redirect_to edit_admin_current_site_url
17
- else
18
- flash_error!
19
- render :action => 'new'
20
- end
21
- end
11
+ @account = Account.create(params[:account])
12
+ current_site.memberships.create(:account => @account) if @account.errors.empty?
13
+
14
+ respond_with @account, :location => edit_admin_current_site_url
15
+ end
22
16
 
23
17
  end
24
18
  end
@@ -4,63 +4,22 @@ module Admin
4
4
  sections 'assets'
5
5
 
6
6
  before_filter :set_collections
7
-
7
+
8
8
  def index
9
- if not @collections.empty?
10
- redirect_to(edit_admin_asset_collection_url(@collections.first)) and return
9
+ if not @asset_collections.empty?
10
+ redirect_to(edit_admin_asset_collection_url(@asset_collections.first)) and return
11
11
  end
12
12
  end
13
13
 
14
14
  def show
15
- @collection = current_site.asset_collections.find(params[:id])
15
+ @asset_collection = current_site.asset_collections.find(params[:id])
16
16
  render :action => 'edit'
17
17
  end
18
-
19
- def new
20
- @collection = current_site.asset_collections.build
21
- end
22
-
23
- def edit
24
- @collection = current_site.asset_collections.find(params[:id])
25
- end
26
-
27
- def create
28
- @collection = current_site.asset_collections.build(params[:asset_collection])
29
-
30
- if @collection.save
31
- flash_success!
32
- redirect_to edit_admin_asset_collection_url(@collection)
33
- else
34
- flash_error!
35
- render :action => 'new'
36
- end
37
- end
38
-
39
- def update
40
- @collection = current_site.asset_collections.find(params[:id])
41
-
42
- if @collection.update_attributes(params[:asset_collection])
43
- flash_success!
44
- redirect_to edit_admin_asset_collection_url(@collection)
45
- else
46
- flash_error!
47
- render :action => 'edit'
48
- end
49
- end
50
-
51
- def destroy
52
- @collection = current_site.asset_collections.find(params[:id])
53
- @collection.destroy
54
-
55
- flash_success!
56
-
57
- redirect_to admin_asset_collections_url
58
- end
59
18
 
60
19
  protected
61
20
 
62
21
  def set_collections
63
- @collections = current_site.asset_collections.order_by([[:name, :asc]])
22
+ @asset_collections = current_site.asset_collections.order_by([[:name, :asc]])
64
23
  end
65
24
  end
66
25
  end
@@ -5,43 +5,25 @@ module Admin
5
5
 
6
6
  before_filter :set_collections_and_current_collection
7
7
 
8
- def new
9
- @asset = @collection.assets.build
10
- end
11
-
12
- def edit
13
- @asset = @collection.assets.find(params[:id])
14
- end
15
-
8
+ respond_to :json, :only => :update
9
+
16
10
  def create
17
- @asset = @collection.assets.build(params[:asset])
18
-
19
- if @asset.save
20
- flash_success!
21
- redirect_to edit_admin_asset_collection_url(@collection)
22
- else
23
- flash_error!
24
- render :action => 'new'
25
- end
11
+ create! { edit_admin_asset_collection_url(@asset_collection) }
26
12
  end
27
-
13
+
28
14
  def update
29
- @asset = @collection.assets.find(params[:id])
30
-
31
- if @asset.update_attributes(params[:asset])
32
- flash_success!
33
- redirect_to edit_admin_asset_collection_url(@collection)
34
- else
35
- flash_error!
36
- render :action => 'edit'
37
- end
15
+ update! { edit_admin_asset_collection_url(@asset_collection) }
38
16
  end
39
-
17
+
40
18
  protected
19
+
20
+ def begin_of_association_chain
21
+ @asset_collection
22
+ end
41
23
 
42
24
  def set_collections_and_current_collection
43
- @collections = current_site.asset_collections
44
- @collection = @collections.find(params[:collection_id])
25
+ @asset_collections = current_site.asset_collections
26
+ @asset_collection = @asset_collections.find(params[:collection_id])
45
27
  end
46
28
 
47
29
  end
@@ -1,8 +1,8 @@
1
1
  module Admin
2
- class BaseController < ::ApplicationController
3
-
2
+ class BaseController < InheritedResources::Base
3
+
4
4
  include Locomotive::Routing::SiteDispatcher
5
-
5
+
6
6
  layout 'admin/application'
7
7
 
8
8
  before_filter :authenticate_admin!
@@ -14,27 +14,23 @@ module Admin
14
14
  before_filter :set_locale
15
15
 
16
16
  helper_method :sections
17
-
17
+
18
18
  # https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
19
19
  Dir[File.dirname(__FILE__) + "/../../helpers/**/*_helper.rb"].each do |file|
20
20
  helper "admin/#{File.basename(file, '.rb').gsub(/_helper$/, '')}"
21
21
  end
22
+
23
+ self.responder = Locomotive::AdminResponder # custom responder
24
+
25
+ defaults :route_prefix => 'admin'
26
+
27
+ respond_to :html
22
28
 
23
29
  protected
24
-
25
- def flash_success!(options = {})
26
- msg = translate_flash_msg(:successful)
27
- (options.has_key?(:now) && options[:now] ? flash.now : flash)[:success] = msg
28
- end
29
-
30
- def flash_error!(options = { :now => true })
31
- msg = translate_flash_msg(:failed)
32
- (options.has_key?(:now) && options[:now] ? flash.now : flash)[:error] = msg
33
- end
34
-
35
- def translate_flash_msg(kind)
36
- t("#{kind.to_s}_#{action_name}", :scope => [:admin, controller_name.underscore.gsub('/', '.'), :messages])
37
- end
30
+
31
+ def begin_of_association_chain
32
+ current_site
33
+ end
38
34
 
39
35
  def self.sections(main, sub = nil)
40
36
  before_filter do |c|
@@ -55,6 +51,6 @@ module Admin
55
51
  def set_locale
56
52
  I18n.locale = current_admin.locale
57
53
  end
58
-
54
+
59
55
  end
60
56
  end
@@ -2,51 +2,6 @@ module Admin
2
2
  class ContentTypesController < BaseController
3
3
 
4
4
  sections 'contents'
5
-
6
- def new
7
- @content_type = current_site.content_types.build
8
- end
9
-
10
- def edit
11
- @content_type = current_site.content_types.find(params[:id])
12
- end
13
-
14
- def create
15
- @content_type = current_site.content_types.build(params[:content_type])
16
-
17
- if @content_type.save
18
- flash_success!
19
- redirect_to edit_admin_content_type_url(@content_type)
20
- else
21
- flash_error!
22
- render :action => 'new'
23
- end
24
- end
25
-
26
- def update
27
- @content_type = current_site.content_types.find(params[:id])
28
-
29
- if @content_type.update_attributes(params[:content_type])
30
- flash_success!
31
- redirect_to edit_admin_content_type_url(@content_type)
32
- else
33
- flash_error!
34
- render :action => "edit"
35
- end
36
- end
37
-
38
- def destroy
39
- @content_type = current_site.content_types.find(params[:id])
40
-
41
- begin
42
- @content_type.destroy
43
- flash_success!
44
- rescue Exception => e
45
- flash[:error] = e.to_s
46
- end
47
-
48
- redirect_to admin_pages_url
49
- end
50
-
5
+
51
6
  end
52
7
  end
@@ -3,70 +3,43 @@ module Admin
3
3
 
4
4
  sections 'contents'
5
5
 
6
- before_filter :set_content_type
6
+ before_filter :set_content_type
7
+
8
+ respond_to :json, :only => :update
7
9
 
8
10
  def index
9
11
  @contents = @content_type.list_or_group_contents
10
12
  end
11
13
 
12
- def new
13
- @content = @content_type.contents.build
14
- end
15
-
16
- def edit
17
- @content = @content_type.contents.find(params[:id])
18
- end
19
-
20
14
  def create
21
- @content = @content_type.contents.build(params[:content_instance])
22
-
23
- if @content.save
24
- flash_success!
25
- redirect_to edit_admin_content_url(@content_type.slug, @content)
26
- else
27
- flash_error!
28
- render :action => 'new'
15
+ create! do |success, failure|
16
+ success.html { redirect_to edit_admin_content_url(@content_type.slug, @content) }
29
17
  end
30
18
  end
31
-
32
- def update
33
- @content = @content_type.contents.find(params[:id])
34
19
 
35
- if @content.update_attributes(params[:content_instance])
36
- flash_success!
37
- redirect_to edit_admin_content_url(@content_type.slug, @content)
38
- else
39
- flash_error!
40
- render :action => "edit"
41
- end
20
+ def update
21
+ update! { edit_admin_content_url(@content_type.slug, @content) }
42
22
  end
43
23
 
44
24
  def sort
45
25
  @content_type.sort_contents!(params[:order])
46
26
 
47
- flash_success!
48
-
49
- redirect_to admin_contents_url(@content_type.slug)
27
+ respond_with(@content_type, :location => admin_contents_url(@content_type.slug))
50
28
  end
51
-
29
+
52
30
  def destroy
53
- @content = @content_type.contents.find(params[:id])
54
-
55
- begin
56
- @content.destroy
57
- flash_success!
58
- rescue Exception => e
59
- flash[:error] = e.to_s
60
- end
61
-
62
- redirect_to admin_contents_url(@content_type.slug)
31
+ destroy! { admin_contents_url(@content_type.slug) }
63
32
  end
64
33
 
65
34
  protected
66
35
 
67
36
  def set_content_type
68
- @content_type = current_site.content_types.where(:slug => params[:slug]).first
37
+ @content_type ||= current_site.content_types.where(:slug => params[:slug]).first
69
38
  end
39
+
40
+ def begin_of_association_chain
41
+ set_content_type
42
+ end
70
43
 
71
44
  end
72
45
  end
@@ -2,24 +2,23 @@ module Admin
2
2
  class CurrentSitesController < BaseController
3
3
 
4
4
  sections 'settings', 'site'
5
-
6
- def edit
7
- @site = current_site
8
- end
5
+
6
+ actions :edit, :update
7
+
8
+ respond_to :json, :only => :update
9
9
 
10
10
  def update
11
- @site = current_site
12
- if @site.update_attributes(params[:site])
13
- flash_success!
14
- redirect_to edit_admin_current_site_url(new_host_if_subdomain_changed)
15
- else
16
- flash_error!
17
- render :action => :edit
11
+ update! do |success, failure|
12
+ success.html { redirect_to edit_admin_current_site_url(new_host_if_subdomain_changed) }
18
13
  end
19
14
  end
20
15
 
21
16
  protected
22
17
 
18
+ def resource
19
+ @site = current_site
20
+ end
21
+
23
22
  def new_host_if_subdomain_changed
24
23
  if @site.domains.include?(request.host)
25
24
  {}
@@ -19,7 +19,7 @@ module Admin
19
19
  if @field.update_attributes(params[:custom_field])
20
20
  render :json => @field.attributes
21
21
  else
22
- render :json => { :error => translate_flash_msg(:successful) }
22
+ render :json => { :error => t('flash.admin.custom_fields.update.alert') }
23
23
  end
24
24
  end
25
25
 
@@ -3,55 +3,11 @@ module Admin
3
3
 
4
4
  sections 'settings'
5
5
 
6
+ respond_to :json, :only => :update
7
+
6
8
  def index
7
9
  @layouts = current_site.layouts.order_by([[:name, :asc]])
8
10
  end
9
-
10
- def new
11
- @layout = current_site.layouts.build
12
- end
13
-
14
- def edit
15
- @layout = current_site.layouts.find(params[:id])
16
- end
17
-
18
- def create
19
- @layout = current_site.layouts.build(params[:layout])
20
-
21
- if @layout.save
22
- flash_success!
23
- redirect_to edit_admin_layout_url(@layout)
24
- else
25
- logger.debug "===> #{@layout.errors.inspect}"
26
- flash_error!
27
- render :action => 'new'
28
- end
29
- end
30
-
31
- def update
32
- @layout = current_site.layouts.find(params[:id])
33
-
34
- if @layout.update_attributes(params[:layout])
35
- flash_success!
36
- redirect_to edit_admin_layout_url(@layout)
37
- else
38
- flash_error!
39
- render :action => "edit"
40
- end
41
- end
42
-
43
- def destroy
44
- @layout = current_site.layouts.find(params[:id])
45
-
46
- begin
47
- @layout.destroy
48
- flash_success!
49
- rescue Exception => e
50
- flash[:error] = e.to_s
51
- end
52
-
53
- redirect_to admin_layouts_url
54
- end
55
11
 
56
12
  end
57
13
  end