setting to disable sitemap
Oleg
committed Mar 24, 2012
commit 1e1fb12e22fc99778deb752aae3511e0ebd1b6ca
Showing 6
changed files with
37 additions
and 5 deletions
config/initializers/comfortable_mexican_sofa.rb
+10
-0
| @@ | @@ -26,6 +26,10 @@ ComfortableMexicanSofa.configure do |config| |
| # If you want to include the routes manually set this to false | |
| # config.use_default_routes = true | |
| + | # /sitemap.xml that is used by search engines for indexing. It's enabled by |
| + | # default, but you may turn it off. |
| + | # config.enable_sitemap = true |
| + | |
| # File uploads use Paperclip and can support filesystem or s3 uploads. Override | |
| # the upload method and appropriate settings based on Paperclip. For S3 see: | |
| # http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Storage/S3, and for | |
| @@ | @@ -87,6 +91,12 @@ ComfortableMexicanSofa.configure do |config| |
| # are accessible by default. Empty array will prevent rendering of all partials. | |
| # config.allowed_partials = nil | |
| + | # Site aliases, if you want to have aliases for your site. Good for harmonizing |
| + | # production env with dev/testing envs. |
| + | # e.g. config.site_aliases = {'host.com' => 'host.inv', 'host_a.com' => ['host.lvh.me', 'host.dev']} |
| + | # Default is nil (not used) |
| + | # config.hostname_aliases = nil |
| + | |
| end | |
| # Default credentials for ComfortableMexicanSofa::HttpAuth | |
config/routes.rb
+8
-4
| @@ | @@ -34,10 +34,14 @@ Rails.application.routes.draw do |
| scope :controller => :cms_content do | |
| get 'cms-css/:site_id/:identifier' => :render_css, :as => 'cms_css' | |
| get 'cms-js/:site_id/:identifier' => :render_js, :as => 'cms_js' | |
| - | get '(:cms_path)/sitemap' => :render_sitemap, |
| - | :as => 'cms_sitemap', |
| - | :constraints => {:format => /xml/}, |
| - | :format => :xml |
| + | |
| + | if ComfortableMexicanSofa.config.enable_sitemap |
| + | get '(:cms_path)/sitemap' => :render_sitemap, |
| + | :as => 'cms_sitemap', |
| + | :constraints => {:format => /xml/}, |
| + | :format => :xml |
| + | end |
| + | |
| get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)" | |
| end | |
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb
+5
-0
| @@ | @@ -23,6 +23,10 @@ class ComfortableMexicanSofa::Configuration |
| # If you want to include the routes manually set this to false | |
| attr_accessor :use_default_routes | |
| + | # /sitemap.xml that is used by search engines for indexing. It's enabled by |
| + | # default, but you may turn it off. |
| + | attr_accessor :enable_sitemap |
| + | |
| # Upload settings | |
| attr_accessor :upload_file_options | |
| @@ | @@ -80,6 +84,7 @@ class ComfortableMexicanSofa::Configuration |
| @admin_route_prefix = 'cms-admin' | |
| @admin_route_redirect = '' | |
| @use_default_routes = true | |
| + | @enable_sitemap = true |
| @upload_file_options = { :url => '/system/:class/:id/:attachment/:style/:filename' } | |
| @enable_fixtures = false | |
| @fixtures_path = File.expand_path('db/cms_fixtures', Rails.root) | |
test/integration/routing_extensions_test.rb
+12
-0
| @@ | @@ -46,4 +46,16 @@ class RoutingExtensionsTest < ActionDispatch::IntegrationTest |
| end | |
| end | |
| + | def test_get_sitemap |
| + | get '/sitemap', :format => 'xml' |
| + | assert_response :success |
| + | |
| + | ComfortableMexicanSofa.config.enable_sitemap = false |
| + | Rails.application.reload_routes! |
| + | |
| + | assert_exception_raised ActionController::RoutingError, 'Page Not Found' do |
| + | get '/sitemap', :format => 'xml' |
| + | end |
| + | end |
| + | |
| end | |
| \ No newline at end of file | |
test/test_helper.rb
+1
-0
| @@ | @@ -24,6 +24,7 @@ class ActiveSupport::TestCase |
| config.admin_route_prefix = 'cms-admin' | |
| config.admin_route_redirect = '' | |
| config.use_default_routes = true | |
| + | config.enable_sitemap = true |
| config.enable_fixtures = false | |
| config.fixtures_path = File.expand_path('db/cms_fixtures', Rails.root) | |
| config.revisions_limit = 25 | |
test/unit/configuration_test.rb
+1
-1
| @@ | @@ -11,8 +11,8 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal 'ComfortableMexicanSofa::DummyAuth', config.public_auth | |
| assert_equal 'cms-admin', config.admin_route_prefix | |
| assert_equal true, config.use_default_routes | |
| + | assert_equal true, config.enable_sitemap |
| assert_equal '', config.admin_route_redirect | |
| - | |
| assert_equal false, config.enable_fixtures | |
| assert_equal File.expand_path('db/cms_fixtures', Rails.root), config.fixtures_path | |
| assert_equal 25, config.revisions_limit | |