Project

cmsable

0.0
No commit activity in last 3 years
No release in over 3 years
Lets users update the content on their pages directly on the page without the need of an admin system
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6

Runtime

~> 1.6
~> 4.0
~> 4.0
 Project Readme

Cmsable


Add inline editable content to pages.

Installation

Add to your Gemfile

gem 'cmsable'

Get Dependencies

bundle install

Add to your routes

  mount Cmsable::Engine => '/cmsable'

Install and run the migrations if you want to use the built in model

rake cmsable:install:migrations
rake db:migrate

Cmsable uses CanCan so make sure this is set up in your necessary controller(s) If your users aren't called users then you'll get something like:

undefined local variable or method `current_user' for ...

You need to define the current_ability, e.g.

def current_ability
  @current_ability ||= AccountAbility.new(current_account)
end

(From https://github.com/ryanb/cancan/wiki/changing-defaults)

Usage

To use the built in model

In your view files

<%= cms 'identifier' %>

Identifier can be any string or symbol, for example 'Homepage Intro' or :something

For plain text areas pass type: :plain as an option. This way you can put content in any tag you want without worrying about users messing up the markup.

<span><%= cms :identifier, type: :plain %></span>

The problem with the above is that in edit mode you'll end up with invalid HTML:

<span><div contenteditable>Content</div></span>

To avoid this you can override the tag used in edit mode:

<%= cms :identifier, type: :plain, tag: 'span' %>

Resulting in:

<span contenteditable>Content</span>

To use your own models

Add to your model:

cms :body => :column_to_use_for_content

Then in your views:

<%= cms @model_instance %>

TODO

  • Allow classes on custom tags
  • Fix highlight so empty areas are still visible
  • Add image mode
  • Add file mode
  • Add video mode (youtube/vimeo/etc)
  • Add support for langs/i18n
  • Handle saving errors
  • Decouple ckeditor
  • Support different editors
  • Remove CanCan dependancy
  • Setup config initializer for added customizability