App Themer
App Themer is a rails generator inspired by web-app-theme that allows you to quickly generate a complete admin template for your rails app.
Features
- HTML5 - based on html5-boilerplate
- Tested in IE6
Installation
You can use app-themer with Rails 3. Specify the app-themer gem in your Gemfile, only for :development and :test
group :development, :test do
gem 'app-themer'
end
Usage
Layout Generator
Used without parameters, app_themer generates the layout file application.html.erb using the default theme.
rails g app_themer:layout
You can specify the layout file name in the first parameter:
rails g app_themer:layout admin # this will generate a layout called `admin.html.erb`
If you want to use another theme, instead of the default, you can use the --theme option:
rails g app_themer:layout admin --theme="a-theme" # there currently is only 1 theme
You can specify the template engine with --engine=name option, where name can be erb (default) or haml:
rails g app_themer:layout --engine=haml # you must specify haml in your Gemfile
If you want to generate the stylesheets of a specific theme without changing the previously generated layout you can pass the --no-layout option:
rails g app_themer:layout --theme=a-theme --no-layout
You can specify the text used in the header with the --app-name option:
rails g app_themer:layout --app-name="My New Application"
If you need a layout for login and signup pages, you can use the --type option with sign as value. Ìf not specified, the default value is admin
rails g app_themer:layout login --layout-type=login
View Generator
Start creating your controllers manually or with a scaffold, and then use the view generator to overwrite the previously generated views.
If you have a controller named like the plural of the used model you can specify just the first parameter:
rails g app_themer:view posts # you have a model named Post and a controller named PostsController
rails g app_themer:view admin/gallery_pictures # you have a model named GalleryPicture and a controller named Admin::GalleryPicturesController
Use the --layout option specifying the previously generated layout to add a link to the controller you are working on:
rails g app_themer:view posts --layout=admin # you will see the `Posts` link in the navigation
If the controller has a name different to the model used, specify the controller path in the first parameter and the model name in the second one:
rails g app_themer:view items post
rails g app_themer:view admin/items post
If you use will_paginate for pagination use the --with_will_paginate:
rails g app_themer:view items post --will-paginate
You can specify the template engine with --engine=name option, where name can be erb (default) or haml:
rails g app_themer:view posts --engine=haml
If you have something like map.resource :dashboard in your routes.rb file, you can use the --type=text to generate a view with just text:
rails g app_themer:view dashboards --view-type=text
If you want to show form error messages inside the generated forms, use the following code inside your environment.rb
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag =~ /<label/
%|<div class="fieldWithErrors">#{html_tag} <span class="error">#{[instance.].join(', ')}</span></div>|.html_safe
else
html_tag
end
end
Contributing
- Fork this repository.
- Duplicate the 'themes/default' folder and rename it.
- Modify the style.css file adding your favorite colors.
- Add a link to your theme in the 'Switch Theme' block inside the index.html file.
- Send a pull request.
Links
- Repository: [email protected]:PoeticSystems/app-themer.git
- Issues: http://github.com/PoeticSystems/app-themer/issues
- Gem: https://rubygems.org/gems/app-themer
Author
Matthew Hager - Poetic Systems
Credits
- Based on web-app-theme by Andrea Franz - http://gravityblast.com
- Icons: FAMFAMFAM Silk icons http://www.famfamfam.com/lab/icons/silk/
- Buttons: Particletree - Rediscovering the Button Element http://particletree.com/features/rediscovering-the-button-element/