Outside CMS

Build Status Gem Version Code Climate Test Coverage

Open source, easy to extend content management system for Rails

  • Easily extend your application with Pages, Post and Image Library
  • Built be easy to adapt, extend and customisable to suit any project
  • Supports Rails 4.1 to 5.0
  • Focus on building your unique application features
  • Define your own authorisation around the CMS
  • Designed to be easy to use for your end users
  • Uses the powerful Trix Editor

Outside CMS


Installation

Add Outside CMS to your gem file:

gem 'o_cms'

Install the migrations:

rake db:migrate

(Note: do not run rake o_cms:install:migrations. The Outside CMS's migrations live inside the gem and do not get copied into your application.)

Define a root for your application:

root to: "public#index"

Without this the primary navigation link 'Your Site' will error.

Authentication

Add Outside CMS to your routes.rb and define authorised users

No Authentication

In development you may want to use the CMS without defining any authentication.

# config/routes.rb
mount OCms::Engine => '/o_cms'

By default Outside CMS is configured to use Devise and includes the user email, with edit user and sign out link in the user navigation. If you are using the CMS without devise authentication override the /views/o_cms/partials/_user_navigation.html.erb partial devise specific links to prevent errors.

Devise

In a production application you'll likely want to protect access to the control panel.

To allow any authenticated User

# config/routes.rb
authenticate :user do
  mount OCms::Engine => '/o_cms'
end

Same as above but also ensures that User.has_role? :admin returns true

# config/routes.rb
authenticate :user, lambda { |user| user.has_role? :admin } do
  mount OCms::Engine => '/o_cms'
end

File Storage

Define where you would like your images to be stored by adding the below to you local initialiser e.g. o_cms_config.rb

By default images are stored in the file directory, to use fog you would add.

# initializers/o_cms_config.rb
OCms::Engine.config.file_storage = :fog

Customisation

You can customise the Primary and User navigation by creating these partials in your application.

  • /views/o_cms/partials/_primary_navigation.html.erb
  • /views/o_cms/partials/_user_navigation.html.erb

Image Sizes

If you would like to define a different selection of image sizes to the default, or change the resizing and size options add the below hash to your config file. You will have to include a Featured option for the Post and Page featured image to work.

# initializers/o_cms_config.rb
OCms::Engine.config.image_sizes = {
  thumb: { resize: "resize_to_fill", width: 50, height: 50 },
  medium: { resize: "resize_to_fit", width: 200, height: 200 },
  large: { resize: "resize_to_fit", width: 300, height: 300 },
  featured: { resize: "resize_to_fit", width: 400, height: 400 },
  special: { resize: "resize_to_fill", width: 600, height: 600 }
}

Guidelines

Each of the pages in the site has a guidelines section, describing to your user what is expected in each form field. You can easily override these guidelines, if you feel the language is tool simplistic or complicated for your users, or if you want to put something else in the sidebars.

  • /views/o_cms/pages/_guidelines.html.erb
  • /views/o_cms/images/_guidelines.html.erb
  • /views/o_cms/posts/_guidelines.html.erb
  • /views/o_cms/categories/_guidelines.html.erb

Controllers

  1. Create your controller
  2. Define the Outside CMS layout in the head of your controller layouts/o_cms/application
  3. Override the navigation to include a link to your new controller (explained in 'Navigation' above)
  4. Add controller specific Javascipt and CSS files to your assets directories, in folders following your CMS mount name defined in routes.rb.

E.g For a courses_controller.rb where your CMS uses the default mount name o_cms. Add your custom controller javascript & styles to assets/javascripts/o_cms/courses.js & assets/stylesheets/o_cms/courses.css.

Also supports the file extensions .coffee .erb .coffee.erb & .scss .erb .scss.erb.

Contributing

  1. Fork the project
  2. Make your changes, including tests that exercise the code
  3. Make a pull request

License

Outside CMS is released under the MIT License.

Author

Benjamin Ayres https://github.com/benjaminayres