0.0
No commit activity in last 3 years
No release in over 3 years
Rails Engine for simple content management. See readme on github for details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Contentment¶ ↑

Contentment is a extremely basic Content Management System for Ruby On Rails. ¶ ↑

How often do your clients want to manage / edit some piddly little portion of the site you’re building for them? Every time? Yeah me too. If what you need is a way for your clients to manage the FAQ or Testimonials, contentment is for you. It’s simple to use and will save you time.

The primary advantage it offers over a roll-your-own CMS is consistency.

Use Contentment whenever you need a basic CMS and you can stop re-inventing the wheel and start pumping code.

Get Contentment¶ ↑

Add it to your gemfile gem ‘contentment’ and run bundle install

Use Contentment¶ ↑

rails generate contentment rails g contentment_views rake db:migrate This will create the Content model and a migration to add the contents table to your database, if it doesn’t already exist. It will also create contents_controller.rb for you with all the CRUD already done, and create the views to manage your Content.

Fire up the server and you’re ready to go.

Details¶ ↑

:title and :body are pretty self explanatory, perfect for question and answer, or header and paragraph.

:tipe is not type to get around rails polymorphic associations, and exists to help you keep track of what Content goes on what pages. Add your own values to the @tipes array

  @tipes = [
	# "Billboard",
	# "What You Learn",
	# "Tips",
	# "Questions Copy",
	# "FAQ",
	# "Examples",
	# "Testimonial",
	# "Navigation",
	]

and you’ll get things like Content.for_faq or Content.for_navigation. Be careful about changing tipes after you’ve been up and running for a while or you might orphan Content.

:dom_id is rarely used, but sometimes you need to manipulate Content on the page with JavaScript and this is there for that.

:position will help you control the order of things in lists.

:visible will help you hide things without deleting them.

:link will allow you to have your navigation editable by your client. Put what you want to show up in the title, and where you want to go in the link field and I’m sure you can fill in the rest.

Live Preview of Content on Edit¶ ↑

If you’re using jQuery

Slap this in your application.js to get live preview of the title attribute of content

$(document).ready(function(){$('.edit_content').keyup(function(){$('.content_preview_title').html($('#content_title').val());});})

I’m using TinyMCE Hammer to get TinyMCE in my projects, and if you install it too you can have live preview of the body of your content pretty easily. (I’m working on getting TinyMCE included in this gem) TinyMCE is nice because your clients probably want the ability to add line breaks and other styling without having to learn HTML. So. Install the TinyMCE Hammer plugin github.com/trevorrowe/tinymce_hammer or tinymcehammer.lanalot.com/ , I don’t know which is canonical. Then add <%= yield :scripts %> to the <head> section of whatever layout (probably application.html.erb) is rendered around the contents/edit.html.erb file. Donezo. You should now see the changes made to the title and body of your content on the edit view live and in real time in the preview area. Clients love that.

That’s It!¶ ↑

If it did anything else it wouldn’t be simple anymore.

Questions, Thoughts, Comments to larrick@gmail.com

Thanks¶ ↑

A thousand thanks to @modestrubyist from www.themodestrubyist.com/ , without whose tutorials on the subject of Rails 3 Engines I would be nowhere.

Also thanks to the thoughtbot team and the clearance gem, which I looked at to learn more. github.com/thoughtbot/clearance

And also finally thanks to github.com/elricstorm/baby_dove which I used as a template for this whole engine.

Read More about engines - edgeapi.rubyonrails.org/classes/Rails/Engine.html

TODO¶ ↑

* Get TinyMCE Integrated so there’s no external dependancies. * Get an example app using contentment up somewhere to show it off.