adding better initializer, cms root can be redirected to any path

Oleg committed Dec 06, 2010
commit 075c0305d92140f094b15edff0b77928e3c5338c
Showing 4 changed files with 35 additions and 8 deletions
config/initializers/comfortable_mexican_sofa.rb +24 -3
@@ @@ -1,9 +1,30 @@
- # Comfortable Mexican Sofa initializer. Change defaults to whatever you require
ComfortableMexicanSofa.configure do |config|
+ # Title of the admin area
config.cms_title = 'ComfortableMexicanSofa'
+
+ # Module responsible for authentication. You can replace it with your own.
+ # It simply needs to have #authenticate method. See http_auth.rb for reference.
config.authentication = 'ComfortableMexicanSofa::HttpAuth'
+
+ # Default url to access admin area is http://yourhost/cms-admin/
+ # You can change 'cms-admin' to 'admin', for example.
+ # config.admin_route_prefix = 'cms-admin'
+
+ # Path: /cms-admin redirects to /cms-admin/pages but you can change it
+ # to something else like:
+ # config.admin_route_redirect = '/cms-admin/pages'
+
+ # Location of YAML files that can be used to render pages instead of pulling
+ # data from the database. Not active if not specified.
+ # config.seed_data_path = File.expand_path('db/cms_seeds', Rails.root)
end
- # Credentials for HttpAuth
+ # Default credentials for ComfortableMexicanSofa::HttpAuth
ComfortableMexicanSofa::HttpAuth.username = 'username'
- ComfortableMexicanSofa::HttpAuth.password = 'password'
\ No newline at end of file
+ ComfortableMexicanSofa::HttpAuth.password = 'password'
+
+ # If you need to inject some html in cms admin views you can define what partial
+ # should be rendered into the following areas:
+ # ComfortableMexicanSofa::ViewHooks.add(:navigation, '/layouts/admin/navigation')
+ # ComfortableMexicanSofa::ViewHooks.add(:html_head, '/layouts/admin/html_head')
+ # ComfortableMexicanSofa::ViewHooks.add(:page_form, '/layouts/admin/page_form')
\ No newline at end of file
config/routes.rb +1 -1
@@ @@ -1,7 +1,7 @@
Rails.application.routes.draw do
namespace :cms_admin, :path => ComfortableMexicanSofa.config.admin_route_prefix, :except => :show do
- get '/' => redirect("/#{ComfortableMexicanSofa.config.admin_route_prefix}/pages")
+ get '/' => redirect(ComfortableMexicanSofa.config.admin_route_redirect)
resources :pages do
member do
match :form_blocks
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb +9 -4
@@ @@ -14,12 +14,17 @@ class ComfortableMexicanSofa::Configuration
# You can change 'cms-admin' to 'admin', for example.
attr_accessor :admin_route_prefix
+ # /cms-admin redirects to /cms-admin/pages but you can change it
+ # to something else
+ attr_accessor :admin_route_redirect
+
# Configuration defaults
def initialize
- @cms_title = 'ComfortableMexicanSofa'
- @authentication = 'ComfortableMexicanSofa::HttpAuth'
- @seed_data_path = nil
- @admin_route_prefix = 'cms-admin'
+ @cms_title = 'ComfortableMexicanSofa'
+ @authentication = 'ComfortableMexicanSofa::HttpAuth'
+ @seed_data_path = nil
+ @admin_route_prefix = 'cms-admin'
+ @admin_route_redirect = "/#{@admin_route_prefix}/pages"
end
end
\ No newline at end of file
test/unit/cms_configuration_test.rb +1 -0
@@ @@ -8,6 +8,7 @@ class CmsConfigurationTest < ActiveSupport::TestCase
assert_equal 'ComfortableMexicanSofa::HttpAuth', config.authentication
assert_equal nil, config.seed_data_path
assert_equal 'cms-admin', config.admin_route_prefix
+ assert_equal '/cms-admin/pages', config.admin_route_redirect
end
def test_initialization_overrides