= ManageableContent http://travis-ci.org/fabiokr/manageable_content.png Manageable Content is a Rails 3.1 Engine that provides a simple framework for content management. It works by providing a Page instance for each of your configured controllers, so that each controller can have it's own contents that will be available to the views. You can also have shared contents. == Contributing This engine is a work in progress and open for contributions! Please don't forget to add tests if you plan on contributing. == Installation This gem is compatible with Rails 3.1. To install it, add the following to your Gemfile: gem 'manageable_content' After that, run the 'bundle' command to install the gem. The next step is to import the engine migrations to your application. Just run this: bundle exec rake manageable_content_engine:install:migrations Then migrate your database with the usual command: bundle exec rake db:migrate The last step is to include the Dsl in where you want to make the ManageableContent engine available. For example, you might want to add the following code to your ApplicationController: include ManageableContent::Controllers::Dsl == Getting Started ManageableContent supports two types of contents: a controller content, and a layout content. A controller content is a content that each controller will have by its own. For example, you might want to have a 'body' content, in which each controller will have a different value for it. A layout content is a content that will be shared between controllers. For example, you might want to have a 'footer' content that will be shared accross all of your controllers. === Controller contents Supposing that you have a controller named ContactController and you want it to have its own 'body' content. You will need to add this to the controller code: manageable_content_for :body After that, run the following rake task: bundle exec rake manageable_content:generate This rake task will check your controllers configurations and will generate the corresponding pages for each controller with their contents. This should be run everytime a new controller or page content is added. This rake task just calls the ManageableContent::Manager.generate! method. You might want to add some kind of hook so that when you deploy your application the generator will run. You might also want to have an administration interface to edit you pages contents. Currently, this engine does not provide that, but you can check an admin example here: https://github.com/fabiokr/manageable_content_example_app/ Now, to use this in your views, you have to use the manageable_content_for helper: manageable_content_for :body This will print the content 'body' for the current controller, if it exists. This will print the content with html_safe. If you need a content that all your controllers will have (for example, a 'title' content), you can add the configuration to your parent controller and all controllers that inherit from it will also have that content. For example, you could add this to your ApplicationController: manageable_content_for :title === Layout contents Supposing that your application will have a 'footer' content that should be the same in all of your controllers, you would add this to your ApplicationController: manageable_layout_content_for :footer In the views, to print it you need to use the manageable_layout_content_for helper: manageable_layout_content_for :footer ==== Different layouts In the previous example, the 'footer' content is available under the 'application' page. By default, manageable_layout_content_for uses the current controller default layout, which in the ApplicationController case is 'application'. If you need to add a content to a different layout, you could use this: manageable_layout_content_for :footer, :layout => 'my_custom_layout' === I18n If you need different contents for multiple locales, you can generate multiple pages for each available locale. You just need to set the available locales for ManageableContent, and then when you run the generator task it will generate contents for all available locales. To do that, just add an initializer with this content: ManageableContent::Engine.config.locales = [:en, :pt] In your views, the helper calls will remain the same. The helpers use I18n.locale to get the current locale and than will use the content available for that locale. === Specs To run the specs, first you need to setup the dummy application database and clone it for the test environment: rake app:db:schema:load rake app:db:test:clone Now you can run the specs with this: rake spec == Contributors https://github.com/fabiokr/manageable_content/contributors == Maintainers * Fabio Kreusch (https://github.com/fabiokr) == License MIT License. Copyright 2011 Fabio Kreusch http://www.kreusch.com.br