adding a setting to control cching mechanism

Oleg committed Feb 23, 2011
commit 182411ded2ae64bf9c4ae24def8f184a7371cbfb
Showing 7 changed files with 25 additions and 4 deletions
README.md +10 -1
@@ @@ -160,7 +160,16 @@ There's a rake task that makes moving seeds into database (and vice-versa) easy:
# from database to seeds
rake comfortable_mexican_sofa:export:all FROM=your-site.com TO=your-site.local SEED_PATH=/path/to/seeds
- ---
+ Active Components
+ -----------------
+ Comfortable Mexican Sofa utilizes the following:
+
+ * **[https://github.com/rails/rails](https://github.com/rails/rails)** - Ruby on Rails 3.*, of course
+ * **[https://github.com/thoughtbot/paperclip](https://github.com/thoughtbot/paperclip)** - Paperclip to handle file uploads
+ * **[https://github.com/theworkinggroup/active_link_to](https://github.com/theworkinggroup/active_link_to)** - Easy method to handle logic behind 'active' links
+
+ * * *
+
![Looks pretty comfortable to me. No idea what makes it Mexican.](https://github.com/twg/comfortable-mexican-sofa/raw/master/doc/sofa.png)
ComfortableMexicanSofa is released under the [MIT license](https://github.com/twg/comfortable-mexican-sofa/raw/master/LICENSE)
app/controllers/cms_content_controller.rb +1 -1
@@ @@ -4,7 +4,7 @@ class CmsContentController < ApplicationController
before_filter :load_cms_page, :only => :render_html
before_filter :load_cms_layout, :only => [:render_css, :render_js]
- caches_page :render_css, :render_js
+ caches_page :render_css, :render_js, :if => ComfortableMexicanSofa.config.enable_caching
def render_html(status = 200)
layout = @cms_page.cms_layout.app_layout.blank?? false : @cms_page.cms_layout.app_layout
app/views/layouts/cms_admin.html.erb +2 -2
@@ @@ -4,8 +4,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title><%= ComfortableMexicanSofa.config.cms_title %></title>
<%= csrf_meta_tag %>
- <%= stylesheet_link_tag :cms, :cache => '_cms' %>
- <%= javascript_include_tag :cms %>
+ <%= stylesheet_link_tag :cms, :cache => ('_cms' if ComfortableMexicanSofa.config.enable_caching) %>
+ <%= javascript_include_tag :cms, :cache => ('_cms' if ComfortableMexicanSofa.config.enable_caching) %>
<%= yield :head %>
<%= cms_hook :html_head %>
</head>
config/initializers/comfortable_mexican_sofa.rb +6 -0
@@ @@ -26,6 +26,12 @@ ComfortableMexicanSofa.configure do |config|
# Generally this is to prevent putting something like this:
# <% User.delete_all %> but if you really want to allow it...
# config.disable_irb = true
+
+ # Asset caching for CSS and JS for admin layout. This setting also controls
+ # page caching for CMS Layout CSS and Javascript. Enabled by default. When deploying
+ # to an environment with read-only filesystem (like Heroku) turn this setting off.
+ # config.enable_caching = true
+
end
# Default credentials for ComfortableMexicanSofa::HttpAuth
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb +4 -0
@@ @@ -24,6 +24,9 @@ class ComfortableMexicanSofa::Configuration
# Not allowing irb code to be run inside page content. True by default.
attr_accessor :disable_irb
+ # Caching for css/js. For admin layout and ones for cms content. Enabled by default.
+ attr_accessor :enable_caching
+
# Configuration defaults
def initialize
@cms_title = 'ComfortableMexicanSofa MicroCMS'
@@ @@ -33,6 +36,7 @@ class ComfortableMexicanSofa::Configuration
@admin_route_redirect = "/#{@admin_route_prefix}/pages"
@auto_manage_sites = true
@disable_irb = true
+ @enable_caching = true
end
end
\ No newline at end of file
test/test_helper.rb +1 -0
@@ @@ -21,6 +21,7 @@ class ActiveSupport::TestCase
config.admin_route_redirect = "/cms-admin/pages"
config.auto_manage_sites = true
config.disable_irb = true
+ config.enable_caching = true
end
ComfortableMexicanSofa::HttpAuth.username = 'username'
ComfortableMexicanSofa::HttpAuth.password = 'password'
test/unit/cms_configuration_test.rb +1 -0
@@ @@ -10,6 +10,7 @@ class CmsConfigurationTest < ActiveSupport::TestCase
assert_equal 'cms-admin', config.admin_route_prefix
assert_equal '/cms-admin/pages', config.admin_route_redirect
assert_equal true, config.disable_irb
+ assert_equal true, config.enable_caching
end
def test_initialization_overrides