Socket
Book a DemoInstallSign in
Socket

contentable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentable

0.3.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

h1. Contentable

Contentable is a gem for easing the integration of chunks of dynamic content. For situations in which content which needs to be inserted here in there in some web application, but which should be updatable on the fly, you could go with a content management system, but if you also need other models and the rest of the power of rails, that isn't the best solution. This gem addresses this issue by allowing you to create content_items which house content (using textile) and give you easy display (etc) access to this content, either as full page content or as a simple block of content to be embedded within some other dynamic page.

h2. How to use

The basics of use of this gem are as follows.

First, include the gem in your Gemfile

Next scaffold out a content_item model with fields @name:string title:string description:string text:text@. Alternatively (preferably really) there is a migration helper which goes along the lines of @create_content_items@ that does this for you; just include that method call within @def self.up@.

Put the line @acts_as_contentable@ in your @ContentItem@ model

Use @display_content(content_item)@ in your views (or @display_textile(some_textile_text)@)

Include @Contentable::Controller@ in your @ContentItemController@ to gain access to the @find_content_item@ controller method which first looks to see if @params[:id]@ is defined and then looks to see if @params[name]@ is defined. The the first isn't but the latter is, the action will grab the content item based on the name passed through. Now you can set up routes that easily take advantage of this so that your content item @name@ attributes can behave like parts of a path.

You can also call @ContentItem#safe_find_by_name(name)@ directly (the method able is just a wrapper of this). If that name queried for is not found, the method returns a (either new or old, depending on whether the situation has ever happened before) content item named @content_missing@. This content item will be given a @missing@ attribute (in local memory, not in db) which stores the name of the missing content item. This name can then be used for easier creation of content that should exist but does not yet.

h2. TODO

  • Make it so that the class you include contentable in can be named whatever your want (BIG ONE)
  • Make helpers for using javascript to automatically render the textile as you type it.
  • Put in validations on @name@ of content items so that they can always be used as paths?
  • Create validations/protections on changing the content_item @name@
  • Create generators for view code, (migrations, etc?)
  • ContentItem manager (a sort of default content item index which allows an admin to manage content items)
  • Support other markup languages
  • Integrate the textile helper
  • Routing helpers

h2. Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add specs for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

h2. Copyright

Copyright (c) 2010 metasoarous (Christopher Small). See LICENSE for details.

FAQs

Package last updated on 20 Jan 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.