Admin Theme
Admin theme is a fork of Web App Theme generator. See demo.
It aims the same goal as a main branch: to generate admin panels quickly.
Changes from main branch:
- Rails 3.1+ compatibility
- Asset pipeline integration
- Auto generation of resources
- Improved I18n support
- Only default theme included
- Kaminari for pagination (optional)
- Erb and slim template engines support
Installation
Add to your Gemfile:
gem 'admin-theme'
If you want to paginate records in admin panel also add:
gem 'kaminari'
gem 'kaminari-admin-theme'
Run bundle install
Usage
- First time you need to setup admin-theme:
rails generate admin_theme:setup
This will generate some assets, controllers, views for admin panel and prepare routes:
create app/views/layouts/admin.html.erb
create app/views/admin/shared/_sidebar.html.erb
create app/views/admin/dashboard/show.html.erb
create app/controllers/admin/base_controller.rb
create app/controllers/admin/dashboard_controller.rb
insert config/routes.rb
create app/assets/stylesheets/admin.css
create app/assets/javascripts/admin.js
You can pass app_name
option to specify the application name:
rails generate admin_theme:setup --app_name="Custom name"
After you will be able to access admin panel at localhost:3000/admin
.
- Move application stylesheets to
another_dir
and change application.css
to not load admin-theme stylesheets:
--*= require_tree .
++*= require_tree ./another_dir
- You can now use admin-theme resource generator to generate necessary resources in admin panel:
rails generate admin_theme:resource posts
If you want to enable pagination:
rails generate admin_theme:resource posts --pagination
You can pass engine
option to specify the template engine (slim
or erb
, the default is erb
):
rails generate admin_theme:setup --engine=slim
If you want to generate resource with different name just specify the model name in the second parameter:
rails generate admin_theme:resource items post
i18n
See config/locales
for available translations.
You can add one by yourself in config/locales
:
time:
formats:
admin-theme: "%d %b %Y [%H:%M]"
admin-theme:
save: Save
cancel: Cancel
list: List
edit: Edit
new: New
show: Show
delete: Delete
confirm: Are you sure?
created_at: Created at
updated_at: Updated at
all: All
or: or
Credits