# Character Rails Admin Have you heard of [Django](https://www.djangoproject.com/), [Wordpress](https://wordpress.org/), [Active Admin](http://activeadmin.info/), [Locomotive](http://locomotivecms.com/)? Yeah?! — Those are all awesome... and **Character** is BETTER! ![Character Image](http://character.s3.amazonaws.com/character1.jpg) ## TODO * Enable published/unpublished option for new posts (now post is published after first save); * Fix paste code issue for redactor.js + chrome (this is pain in the ass); * Add smart toolbar buttons customization for redactor.js; * Add JS validation on form save; * Fix focus jump after image insert / link edit in redactor.js; * redactor.js source view is too big in height; * redactor.js source view removes new lines from code; * fix upload icon while uploading; * fix default styles for blog: links do break words; * SVG icons do not work for Firefox; * Add menu groups option to make one icon in menu for group of models (apps); * Add expand button to details header; * Reset validation after succesful form submission; * Cache list all list views in DOM and save scrolling state for them, rerender only details; * Fix fontawesome for firefox; ## Setup new [Rails 4.1](http://rubyonrails.org) project rails new ProjectName -T -O Add gems to the ```Gemfile```: # Mongoid ORM + Character gem 'carrierwave-mongoid', github: 'carrierwaveuploader/carrierwave-mongoid', require: 'carrierwave/mongoid' gem 'character' Run bundle and run generators: bundle ; rails g mongoid:config ; rails g character:bootstrap ## Routes After character generator finishes it's dirty business, in ```/config/routes.rb``` you see: mount_character_instance 'admin' This mounts character instance **admin** to ```/admin``` path and make character app accessible there. There are also two optional helpers ```mount_posts_at``` and ```mount_pages_at```, they mount default controllers to routes as well. Remove them if no need in **posts** or **pages** app. Instance name **admin** could be changed, and you can use something different. This option is here for the case when a few character instances are required. - mount_character_instance - mount_posts_at - mount_pages_at ## Running Automated Tests `$ bundle exec rake test` ## Modules - chr.genericModule() - chr.postsModule() - chr.pagesModule() - chr.settingsModule() - chr.settingsWebsite() - chr.settingsPostCategories() - chr.settingsAdmins() - chr.settingsRedirects() ## Forms To have custom form implementation for model, create ```form.html``` in ```/app/views/admin/model_names/``` — replace *model_names* with pluralized models name and if needed character instance name *admin* (default). ### Generic form template Generic form template looks like this: <%= simple_form_for @object, url: @form_action_url, method: :post do |f| %> <%= f.input :name %> <% end %> Checkout [Simple Form](https://github.com/plataformatec/simple_form) reference for all options (there are tons of them) which are available here. **No need to include SUBMIT button in form!** ### Hideable If you want to make model hideable include ```include Hideable``` in model and add hidden field to your form: <%= f.input :hidden, as: :hidden %> This will add an eye button trigger in the admin header, which allows to switch state for model. ### Inline forms Form inline elements could be added with this code (images example):