Skip to content

codeindulgence/cmsable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Rails plugin to allow in page editing of content

Resources

License

Stars

Watchers

Forks

Packages

No packages published