# Application template recipe for the rails_apps_composer. Check for a newer version here: # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/boilerplate.rb if config['boilerplate'] if recipes.include? 'rails 3.1' after_bundler do say_wizard "Boilerplate recipe running 'after bundler'" # Download HTML5 Boilerplate JavaScripts get "https://raw.github.com/paulirish/html5-boilerplate/master/js/libs/modernizr-2.0.min.js", "app/assets/javascripts/modernizr.js" get "https://raw.github.com/paulirish/html5-boilerplate/master/js/libs/respond.min.js", "app/assets/javascripts/respond.js" get "https://raw.github.com/paulirish/html5-boilerplate/master/js/plugins.js", "app/assets/javascripts/plugins.js" # Download HTML5 Boilerplate Stylesheet get "https://raw.github.com/paulirish/html5-boilerplate/master/css/style.css", "app/assets/stylesheets/boilerplate.scss" # Download HTML5 Boilerplate Site Root Assets get "https://raw.github.com/paulirish/html5-boilerplate/master/apple-touch-icon-114x114-precomposed.png", "app/assets/images/apple-touch-icon-114x114-precomposed.png" get "https://raw.github.com/paulirish/html5-boilerplate/master/apple-touch-icon-57x57-precomposed.png", "app/assets/images/apple-touch-icon-57x57-precomposed.png" get "https://raw.github.com/paulirish/html5-boilerplate/master/apple-touch-icon-72x72-precomposed.png", "app/assets/images/apple-touch-icon-72x72-precomposed.png" get "https://raw.github.com/paulirish/html5-boilerplate/master/apple-touch-icon-precomposed.png", "app/assets/images/apple-touch-icon-precomposed.png" get "https://raw.github.com/paulirish/html5-boilerplate/master/apple-touch-icon.png", "app/assets/images/apple-touch-icon.png" get "https://raw.github.com/paulirish/html5-boilerplate/master/crossdomain.xml", "public/crossdomain.xml" get "https://raw.github.com/paulirish/html5-boilerplate/master/humans.txt", "public/humans.txt" # Set up the default application layout if recipes.include? 'haml' # Haml version of default application layout # create some Haml helpers inject_into_class 'app/helpers/application_helper.rb', ApplicationHelper do <<-RUBY # Create a named haml tag to wrap IE conditional around a block # http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither def ie_tag(name=:body, attrs={}, &block) attrs.symbolize_keys! haml_concat("".html_safe) haml_concat("".html_safe) haml_concat("".html_safe) haml_concat("".html_safe) haml_tag name, attrs do haml_concat("".html_safe) block.call end end def ie_html(attrs={}, &block) ie_tag(:html, attrs, &block) end def ie_body(attrs={}, &block) ie_tag(:body, attrs, &block) end private def add_class(name, attrs) classes = attrs[:class] || '' classes.strip! classes = ' ' + classes if !classes.blank? classes = name + classes attrs.merge(:class => classes) end RUBY end remove_file 'app/views/layouts/application.html.erb' remove_file 'app/views/layouts/application.html.haml' # There is Haml code in this script. Changing the indentation is perilous between HAMLs. create_file 'app/views/layouts/application.html.haml' do <<-HAML - ie_html :lang => 'en', :class => 'no-js' do %head %title #{app_name} = stylesheet_link_tag :application = javascript_include_tag :application = csrf_meta_tags %body #container %header - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String) #main{:role => "main"} = yield %footer HAML end else # ERB version of default application layout remove_file 'app/views/layouts/application.html.erb' remove_file 'app/views/layouts/application.html.haml' create_file 'app/views/layouts/application.html.erb' do <<-ERB