# Weeler [![Gem Version](https://badge.fury.io/rb/weeler.png)](http://badge.fury.io/rb/weeler) [![Build Status](https://travis-ci.org/weby-lv/weeler.png?branch=master)](https://travis-ci.org/weby-lv/weeler) [![Coverage Status](https://coveralls.io/repos/weby-lv/weeler/badge.png)](https://coveralls.io/r/weby-lv/weeler) [![Code Climate](https://codeclimate.com/github/weby-lv/weeler.png)](https://codeclimate.com/github/weby-lv/weeler) CMS for weby.lv projects. ## Installation Add this line to your application's Gemfile: gem 'weeler' And then execute: $ bundle Or install it yourself as: $ gem install weeler ## Setup Run weeler generator: $ rails g weeler:install It will generate: * weeler.rb setting file in config/initializers folder; * migrations for translation, settings and object seos; * application_controller.rb in weeler controller scope. It is the parent controller of all weeler controllers; * assets in lib/assets for modify, append new javascript or style for weeler backend. And then migrate database: $ rake db:migrate ## Usage ### Adding controllers and views Create controllers and views in app/controller/weeler and app/view/weeler and then add routes in mount_weeler_at block in config/routes.rb file. There is no limitation or DCL for that. Also you need to extend at least Weeler::BaseController if you expect that weeler work as expected. ### Menu If you want your controller work under menu section, you should extend one of: * Weeler::AdministrationController - for administration section; * Weeler::ContentController - for content section; Then you should append config.content_menu_items or config.administration_menu_items array with hash that contains: name for submenu name and weeler_path as string for relative weeler path. E.g.: config.content_menu_items = [ {name: "Posts", weeler_path: "posts"}, {name: "Post comments", weeler_path: "comments"} ] ### acts_as_restful Weeler action controller method. It creates all restful actions for action controller. Create a controller for your model (e.g. Post) what you want to administrate in weeler. Add method acts_as_restful Post and permit params for your resource - option permit_params. Also you can paginate - add option paginate e.g. class Weeler::PostController < Weeler::ContentController acts_as_restful Post, permit_params: [:title, :body], paginate: 50 end It will handle :index, :new, :edit, :update, :destroy, :order, :activation and :remove_image actions For permiting custom by role or permiting all params (permit!), you must add block permit_params: -> (params) { params.require(:post).permit! } You should implement form file with your own active record attributes. To do that, create _form.html.haml in views/weeler/_YOUR_RESOURCE_/_form.html.haml where _YOUR_RESOURCE_ is name of your resource. Also you can override all standart restful action view and implement, if you need, _filter.html.haml ### View partials for restful controllers: Weeler have default views for index, new, edit actions. You should override _form.html.haml partial. ### View helper image_upload_field : Weeler action view helper method. It creates file upload field with info and preview for image. e.g. <%= f.image_upload_field :image, size_info: "270x294" %> It creates:
Size should be 270x294
Name
If you use another image handler than Paperclip, you can also pass image_url_method for image preview. Also with remove_image action in controller and route for that, it removes only image from object. ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request