Staticman
Staticman build static pages, e.g. errors, about, contact, and it's very easy, fast, programable. Rending with proxy inherited rails controller.
Installation
Add this line to your application's Gemfile:
gem 'staticman'
And then execute:
$ bundle
Or install it yourself as:
$ gem install staticman
Setup
Create staticman.rb as config in config directory.
$ rails g staticman:config
Next, setting config with staticman.rb.
Staticman.configure do |config|
config.static_pages = [
{ file: 'statics/about', layout: 'application' },
{ file: 'statics/404', layout: 'application' }
]
# config.static_dir = 'public'
config.host = 'staticman.github.com'
# config.controller_context_class = nil
endThe following is config parameters means.
-
static_pages- rendering pages, default is[]. -
static_dir- output directory for html, default ispublic. -
host- resolve domain, default isexample.com. -
controller_context_class- using controller as proxy, default isApplicationController.
Usage
So easy how to use, you only execute two commands of build and destroy.
First, add static pages in directory specified.
you can write static pages the same as other views, include helper_method, *_helper.
$ vim app/view/statics/about.html.erb[haml, etc...]
Create static pages.
$ rake staticman:build
And delete.
$ rake staticman:destroy
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Copyright
Copyright (c) 2012 terut. See MIT LICENSE for details.