Permalink
Browse files

Merge branch 'master' of github.com:thoughtbot/flutie

  • Loading branch information...
2 parents d8b0f98 + fc9fc01 commit 67761cd4ef96ee86376802a9b2b072ac3e3924ec Chad Pytel committed Oct 1, 2011
View
@@ -4,4 +4,6 @@ pkg/
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/
-.sass-cache/*
+.sass-cache/*
+gemfiles/*.lock
+*.gem
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- flutie (1.3.1)
+ flutie (1.3.3)
GEM
remote: http://rubygems.org/
View
@@ -74,6 +74,44 @@ Plugin authors can also add to the styleguide by ensuring that their view path i
<a href="#next">Next</a>
</div>
+Helpers
+-------
+
+Flutie provides several helper methods for layouts as well.
+
+The `page_title` method can be used like:
+
+ <title><%= page_title %></title>
+
+By default, it will produce results like:
+
+ <title>Appname : page title</title>
+
+* "App name" comes from the module name of the rails application created by your app, i.e. `Appname::Application` will produce "Appname"
+* "page" comes from trying `content_for(:page_title)` and assumes you are setting :page_title on your pages.
+* The separator defaults to " : "
+
+These can be overridden by passing an options hash including `:app_name`, `:page_title_symbol` and `:separator` hash keys, ie:
+
+ content_for(:site_page_title, 'My title of my page')
+ page_title(:app_name => 'My app name', :page_title_symbol => :site_page_title, :separator => " | ")
+ => "My app name | My title of my page"
+
+The `body_class` method can be used like:
+
+ <body class="<%= body_class %>">
+
+This will produce a string including the controller name and controller-action name. For example, The WidgetsController#show action would produce:
+
+ <body class="widgets widgets-show">
+
+Anything which has been added via `content_for(:extra_body_classes)` will be added to the end, for example:
+
+ content_for(:extra_body_classes, 'special-page')
+ <body class="<%= body_class %>">
+ <body class="widgets widgets-show special-page">
+
+
Suggestions, Bugs, Refactoring?
-------------------------------
@@ -1,6 +1,13 @@
module BodyClassHelper
- def body_class
+ def body_class(options = {})
+ extra_body_classes_symbol = options[:extra_body_classes_symbol] || :extra_body_classes
qualified_controller_name = controller.controller_path.gsub('/','-')
- "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
+ basic_body_class = "#{qualified_controller_name} #{qualified_controller_name}-#{controller.action_name}"
+
+ if content_for?(extra_body_classes_symbol)
+ [basic_body_class, content_for(extra_body_classes_symbol)].join(' ')
+ else
+ basic_body_class
+ end
end
end
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'flutie'
- s.version = '1.3.2'
- s.date = %q{2011-09-16}
+ s.version = '1.3.3'
+ s.date = %q{2011-10-01}
s.email = 'support@thoughtbot.com'
s.homepage = 'http://github.com/thoughtbot/flutie'
s.summary = 'Flutie adds default stylesheets to web apps'
@@ -1,128 +0,0 @@
-PATH
- remote: /Users/mjankowski/Development/opensource/flutie
- specs:
- flutie (1.3.1)
-
-GEM
- remote: http://rubygems.org/
- specs:
- abstract (1.0.0)
- actionmailer (3.0.10)
- actionpack (= 3.0.10)
- mail (~> 2.2.19)
- actionpack (3.0.10)
- activemodel (= 3.0.10)
- activesupport (= 3.0.10)
- builder (~> 2.1.2)
- erubis (~> 2.6.6)
- i18n (~> 0.5.0)
- rack (~> 1.2.1)
- rack-mount (~> 0.6.14)
- rack-test (~> 0.5.7)
- tzinfo (~> 0.3.23)
- activemodel (3.0.10)
- activesupport (= 3.0.10)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.10)
- activemodel (= 3.0.10)
- activesupport (= 3.0.10)
- arel (~> 2.0.10)
- tzinfo (~> 0.3.23)
- activeresource (3.0.10)
- activemodel (= 3.0.10)
- activesupport (= 3.0.10)
- activesupport (3.0.10)
- appraisal (0.3.8)
- bundler
- rake
- arel (2.0.10)
- builder (2.1.2)
- capybara (1.1.1)
- mime-types (>= 1.16)
- nokogiri (>= 1.3.3)
- rack (>= 1.0.0)
- rack-test (>= 0.5.4)
- selenium-webdriver (~> 2.0)
- xpath (~> 0.1.4)
- childprocess (0.2.2)
- ffi (~> 1.0.6)
- diff-lcs (1.1.3)
- erubis (2.6.6)
- abstract (>= 1.0.0)
- ffi (1.0.9)
- i18n (0.5.0)
- json_pure (1.5.4)
- spruz (~> 0.2.8)
- mail (2.2.19)
- activesupport (>= 2.3.6)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.16)
- mocha (0.9.12)
- nokogiri (1.5.0)
- polyglot (0.3.2)
- rack (1.2.3)
- rack-mount (0.6.14)
- rack (>= 1.0.0)
- rack-test (0.5.7)
- rack (>= 1.0)
- rails (3.0.10)
- actionmailer (= 3.0.10)
- actionpack (= 3.0.10)
- activerecord (= 3.0.10)
- activeresource (= 3.0.10)
- activesupport (= 3.0.10)
- bundler (~> 1.0)
- railties (= 3.0.10)
- railties (3.0.10)
- actionpack (= 3.0.10)
- activesupport (= 3.0.10)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.4)
- rake (0.9.2)
- rdoc (3.9.4)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
- rspec-rails (2.6.1)
- actionpack (~> 3.0)
- activesupport (~> 3.0)
- railties (~> 3.0)
- rspec (~> 2.6.0)
- rubyzip (0.9.4)
- sass (3.1.7)
- selenium-webdriver (2.5.0)
- childprocess (>= 0.2.1)
- ffi (>= 1.0.7)
- json_pure
- rubyzip
- spruz (0.2.13)
- sqlite3 (1.3.4)
- thor (0.14.6)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.29)
- xpath (0.1.4)
- nokogiri (~> 1.3)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- appraisal
- capybara (>= 0.4.0)
- flutie!
- mocha
- rails (= 3.0.10)
- rspec-rails
- sass
- sqlite3
@@ -1,141 +0,0 @@
-PATH
- remote: /Users/mjankowski/Development/opensource/flutie
- specs:
- flutie (1.3.1)
-
-GEM
- remote: http://rubygems.org/
- specs:
- actionmailer (3.1.0)
- actionpack (= 3.1.0)
- mail (~> 2.3.0)
- actionpack (3.1.0)
- activemodel (= 3.1.0)
- activesupport (= 3.1.0)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- i18n (~> 0.6)
- rack (~> 1.3.2)
- rack-cache (~> 1.0.3)
- rack-mount (~> 0.8.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.0.0)
- activemodel (3.1.0)
- activesupport (= 3.1.0)
- bcrypt-ruby (~> 3.0.0)
- builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.0)
- activemodel (= 3.1.0)
- activesupport (= 3.1.0)
- arel (~> 2.2.1)
- tzinfo (~> 0.3.29)
- activeresource (3.1.0)
- activemodel (= 3.1.0)
- activesupport (= 3.1.0)
- activesupport (3.1.0)
- multi_json (~> 1.0)
- appraisal (0.3.8)
- bundler
- rake
- arel (2.2.1)
- bcrypt-ruby (3.0.0)
- builder (3.0.0)
- capybara (1.1.1)
- mime-types (>= 1.16)
- nokogiri (>= 1.3.3)
- rack (>= 1.0.0)
- rack-test (>= 0.5.4)
- selenium-webdriver (~> 2.0)
- xpath (~> 0.1.4)
- childprocess (0.2.2)
- ffi (~> 1.0.6)
- diff-lcs (1.1.3)
- erubis (2.7.0)
- ffi (1.0.9)
- hike (1.2.1)
- i18n (0.6.0)
- json_pure (1.5.4)
- spruz (~> 0.2.8)
- mail (2.3.0)
- i18n (>= 0.4.0)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- mime-types (1.16)
- mocha (0.9.12)
- multi_json (1.0.3)
- nokogiri (1.5.0)
- polyglot (0.3.2)
- rack (1.3.2)
- rack-cache (1.0.3)
- rack (>= 0.4)
- rack-mount (0.8.3)
- rack (>= 1.0.0)
- rack-ssl (1.3.2)
- rack
- rack-test (0.6.1)
- rack (>= 1.0)
- rails (3.1.0)
- actionmailer (= 3.1.0)
- actionpack (= 3.1.0)
- activerecord (= 3.1.0)
- activeresource (= 3.1.0)
- activesupport (= 3.1.0)
- bundler (~> 1.0)
- railties (= 3.1.0)
- railties (3.1.0)
- actionpack (= 3.1.0)
- activesupport (= 3.1.0)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (~> 0.14.6)
- rake (0.9.2)
- rdoc (3.9.4)
- rspec (2.6.0)
- rspec-core (~> 2.6.0)
- rspec-expectations (~> 2.6.0)
- rspec-mocks (~> 2.6.0)
- rspec-core (2.6.4)
- rspec-expectations (2.6.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.6.0)
- rspec-rails (2.6.1)
- actionpack (~> 3.0)
- activesupport (~> 3.0)
- railties (~> 3.0)
- rspec (~> 2.6.0)
- rubyzip (0.9.4)
- sass (3.1.7)
- selenium-webdriver (2.5.0)
- childprocess (>= 0.2.1)
- ffi (>= 1.0.7)
- json_pure
- rubyzip
- sprockets (2.0.0)
- hike (~> 1.2)
- rack (~> 1.0)
- tilt (!= 1.3.0, ~> 1.1)
- spruz (0.2.13)
- sqlite3 (1.3.4)
- thor (0.14.6)
- tilt (1.3.3)
- treetop (1.4.10)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.29)
- xpath (0.1.4)
- nokogiri (~> 1.3)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- appraisal
- capybara (>= 0.4.0)
- flutie!
- mocha
- rails (= 3.1.0)
- rspec-rails
- sass
- sqlite3
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe BodyClassHelper do
+describe BodyClassHelper, 'without any extra body classes' do
describe "body_class with a normal controller" do
before do
controller = mock
@@ -24,3 +24,16 @@
end
end
end
+
+describe BodyClassHelper, 'with extra body classes' do
+ before do
+ controller = mock
+ controller.stubs(:controller_path).returns('widgets')
+ controller.stubs(:action_name).returns('show')
+ helper.stubs(:controller).returns controller
+ helper.content_for(:extra_body_classes, 'extra_class')
+ end
+ it "adds extra body classes to the controller classes" do
+ helper.body_class.should == 'widgets widgets-show extra_class'
+ end
+end

0 comments on commit 67761cd

Please sign in to comment.