This repo is currently being used by the Charlotte Ruby Meetup group. This gem is not intended for production use at this time. It will be released to gemcutter after the group determines that it is stable.
boilerplate_engine
boilerplate_engine is used to kick-start your Rails 3 app views. It uses HTML5 Boilerplate assets and index page as a basis for the views. The goal of this project is to give you a good starting point and remove some of the mundane tasks involved in setting up a new Rails app.
Info for CLT Ruby
If you want to contribute to this project, then fork the repo on github and take a look at the source and see how you can improve or add more functionality. Take a look at https://github.com/paulirish/html5-boilerplate. The application layout file is based on this project. If you are not familiar with Rails 3 Engines, do some research on them as well.
All of the tests are in the "test_app" directory. Instead of using a dummy app, I found it easier to simply add a new blank rails app and bootstrap it with rspec and cucumber. The initial commit contains only cucumber tests (some of which need to be refactored).
This project also uses the Yettings gem, which gives you a YAML settings file that contains key/value pairs. These can be used as site-wide variables in the Engine and the containing Rails app. boilerplate_engine uses Yettings to allow the user to configure the Engine with things like Google Analytics API key, default title and meta description,etc..
Rails Generators are used to install the static assets, views, and delete index.html from the public directory. A controller, view and route are included in the engine for the index page. This maps to "home#index". The generator will create a view for the index page, so you can add your own code:
/app/views/home/index.html.erb
The generator also gives you a new view directory
/app/views/boilerplate/
This directory contains partials where you can insert extra javascript, css, meta tags, etc.. It also contains a partial named _layout.html.erb. This file contains the call to "yield". This partial is sandwiched between the opening "body" tag and the asynchronous javascript at the bottom of the layout. This is the appropriate file to code anything shared in your layout... like headers, nav bars, etc. All of the generator code is in:
/lib/generators/boilerplate_engine/install/install_generator.rb
The generator templates are in this directory
/lib/generators/boilerplate_engine/install/templates/
For more info about coding generators, see http://guides.rubyonrails.org/generators.html
Install
To install in your Rails 3 app, place this in your Gemfile and run "bundle install"
gem "boilerplate_engine", :git=>"[email protected]:charlotte-ruby/boilerplate_engine.git"
This will install the gem directly from github.
You can also install it using a local path, if you have cloned the repository locally:
gem "boilerplate_engine", :git=>"/path/to/boilerplate_engine"
Next, you need to run the generator to install views and assets into the parent Rails app:
rails g boilerplate_engine:install
Then you can configure the boilerplate by editing /config/yettings/boilerplate.yml. You will probably want to change the default title, meta description and author. You can also exclude things like jquery and analytics.
The final step is to add your code to the views in:
/app/views/boilerplate
This is where you want to add any extra javascript, css, or meta tags. You will also use _layout.html.erb for your template code like nav, headers, footers, etc..
You can override the default title and meta description for individual views with helpers:
<% head_title "Custom Title Here" %>
<% meta_description "Custom Meta Description" %>
Testing
If you clone the repository locally, you can fire off the tests by doing this:
cd /path/to/boilerplate_engine/test_app
bundle exec cucumber features/
TODO List
- Convert views from haml to erb. Not everyone uses haml, so this should not be the default.
- Create a flexible template system (and css) that allows you to easily skin your app.
- Better tests