more wip. routes are changing. ugh
Oleg
committed Jun 13, 2011
commit 863834daf4e752384f71f531e7c9e120e4c99a54
Showing 9
changed files with
27 additions
and 54 deletions
app/controllers/cms_admin/base_controller.rb
+3
-16
| @@ | @@ -14,23 +14,10 @@ class CmsAdmin::BaseController < ApplicationController |
| protected | |
| def load_admin_cms_site | |
| - | hostname = request.host.downcase |
| - | @cms_site = Cms::Site.find_by_hostname!(hostname) |
| - | |
| + | @cms_site = Cms::Site.find(params[:site_id]) |
| rescue ActiveRecord::RecordNotFound | |
| - | unless ComfortableMexicanSofa.config.enable_multiple_sites |
| - | if Cms::Site.count == 0 |
| - | @cms_site = Cms::Site.create!(:label => 'Default Site', :hostname => hostname) |
| - | else |
| - | @cms_site = Cms::Site.first |
| - | @cms_site.update_attribute(:hostname, hostname) |
| - | end |
| - | end |
| - | |
| - | unless @cms_site |
| - | flash[:error] = 'No Site defined for this hostname. Create it now.' |
| - | return redirect_to(cms_admin_sites_path) |
| - | end |
| + | flash[:error] = 'Site not found' |
| + | return redirect_to(cms_admin_sites_path) |
| end | |
| def load_fixtures | |
app/controllers/cms_content_controller.rb
+1
-5
| @@ | @@ -27,11 +27,7 @@ class CmsContentController < ApplicationController |
| protected | |
| def load_cms_site | |
| - | @cms_site = if ComfortableMexicanSofa.config.enable_multiple_sites |
| - | Cms::Site.find_by_hostname(request.host.downcase) |
| - | else |
| - | Cms::Site.first |
| - | end |
| + | Cms::Site.find_by_hostname(request.host.downcase) |
| render :text => 'Site Not Found', :status => 404 if !@cms_site | |
| end | |
app/views/layouts/cms_admin/_left.html.erb
+1
-3
| @@ | @@ -1,7 +1,5 @@ |
| <ul class='nav'> | |
| - | <% if ComfortableMexicanSofa.config.enable_multiple_sites %> |
| - | <li><%= active_link_to 'Sites', cms_admin_sites_path %></li> |
| - | <% end %> |
| + | <li><%= active_link_to 'Sites', cms_admin_sites_path %></li> |
| <li><%= active_link_to 'Layouts', cms_admin_layouts_path %></li> | |
| <li><%= active_link_to 'Pages', cms_admin_pages_path %></li> | |
| <li><%= active_link_to 'Snippets', cms_admin_snippets_path %></li> | |
config/initializers/comfortable_mexican_sofa.rb
+0
-4
| @@ | @@ -14,10 +14,6 @@ ComfortableMexicanSofa.configure do |config| |
| # Path: /cms-admin redirects to /cms-admin/pages but you can change it | |
| # config.admin_route_redirect = 'pages' | |
| - | # If you enable this setting you'll be able to serve completely different set |
| - | # of sites with their own layouts and pages. |
| - | config.enable_multiple_sites = true |
| - | |
| # By default you cannot have irb code inside your layouts/pages/snippets. | |
| # Generally this is to prevent putting something like this: | |
| # <% User.delete_all %> but if you really want to allow it... | |
config/routes.rb
+21
-20
| @@ | @@ -4,28 +4,29 @@ Rails.application.routes.draw do |
| get '/' => redirect( | |
| "/#{ComfortableMexicanSofa.config.admin_route_prefix}/#{ComfortableMexicanSofa.config.admin_route_redirect}" | |
| ) | |
| - | resources :pages do |
| - | member do |
| - | match :form_blocks |
| - | match :toggle_branch |
| + | resources :sites do |
| + | resources :pages do |
| + | member do |
| + | match :form_blocks |
| + | match :toggle_branch |
| + | end |
| + | collection do |
| + | match :reorder |
| + | end |
| + | resources :revisions, :only => [:index, :show, :revert] do |
| + | put :revert, :on => :member |
| + | end |
| end | |
| - | collection do |
| - | match :reorder |
| + | resources :uploads, :only => [:create, :destroy] |
| + | resources :layouts do |
| + | resources :revisions, :only => [:index, :show, :revert] do |
| + | put :revert, :on => :member |
| + | end |
| end | |
| - | resources :revisions, :only => [:index, :show, :revert] do |
| - | put :revert, :on => :member |
| - | end |
| - | end |
| - | resources :sites |
| - | resources :uploads, :only => [:create, :destroy] |
| - | resources :layouts do |
| - | resources :revisions, :only => [:index, :show, :revert] do |
| - | put :revert, :on => :member |
| - | end |
| - | end |
| - | resources :snippets do |
| - | resources :revisions, :only => [:index, :show, :revert] do |
| - | put :revert, :on => :member |
| + | resources :snippets do |
| + | resources :revisions, :only => [:index, :show, :revert] do |
| + | put :revert, :on => :member |
| + | end |
| end | |
| end | |
| end unless ComfortableMexicanSofa.config.admin_route_prefix.blank? | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+0
-3
| @@ | @@ -14,9 +14,6 @@ class ComfortableMexicanSofa::Configuration |
| # to something else | |
| attr_accessor :admin_route_redirect | |
| - | # Are you running multiple sites from single install? Default assumption is 'No' |
| - | attr_accessor :enable_multiple_sites |
| - | |
| # Not allowing irb code to be run inside page content. False by default. | |
| attr_accessor :allow_irb | |
test/functional/cms_admin/pages_controller_test.rb
+1
-1
| @@ | @@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| class CmsAdmin::PagesControllerTest < ActionController::TestCase | |
| def test_get_index | |
| - | get :index |
| + | get :index, :site_id => cms_sites(:default) |
| assert_response :success | |
| assert assigns(:cms_pages) | |
| assert_template :index | |
test/test_helper.rb
+0
-1
| @@ | @@ -18,7 +18,6 @@ class ActiveSupport::TestCase |
| config.authentication = 'ComfortableMexicanSofa::HttpAuth' | |
| config.admin_route_prefix = 'cms-admin' | |
| config.admin_route_redirect = 'pages' | |
| - | config.enable_multiple_sites = false |
| config.allow_irb = false | |
| config.enable_caching = true | |
| config.enable_fixtures = false | |
test/unit/configuration_test.rb
+0
-1
| @@ | @@ -8,7 +8,6 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal 'ComfortableMexicanSofa::HttpAuth', config.authentication | |
| assert_equal 'cms-admin', config.admin_route_prefix | |
| assert_equal 'pages', config.admin_route_redirect | |
| - | assert_equal false, config.enable_multiple_sites |
| assert_equal false, config.allow_irb | |
| assert_equal true, config.enable_caching | |
| assert_equal false, config.enable_fixtures | |