github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

marcoow / content_repository

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 5
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A simple content repository plugin for Ruby on Rails — Read more

  cancel

http://simplabs.com/#projects

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

updated copyright notice 
marcoow (author)
Sat Jan 23 07:07:31 -0800 2010
commit  43a807f6598ac284f6a9bc8931ffb82fec2ff2ea
tree    3e533b6d54da73442088e9bd641dcda4ec7f8654
parent  4741040f4b07d12f61177b8223b031a72855cc16
content_repository /
name age
history
message
file .gitignore Loading commit data...
file MIT-LICENSE
file README.rdoc
file Rakefile
directory generators/
file init.rb
file install.rb
directory lib/
directory rdoc/
directory spec/
directory tasks/
file uninstall.rb
README.rdoc

ContentRepository

ContentRepository is a simple content repository plugin for Ruby on Rails. Its main are of application might be blogs or other content-centric aplications.

The basic structure is the content tree, that is built of instances Simplabs::ContentRepository::Content, e.g.:

  + parent_content
  |
  +--- child_content1
  |
  +--+ child_content2
     |
     +-- sub_child_content

Every Simplabs::ContentRepository::Content has an arbitrary number of sections, that hold the actual content of the instance, e.g.:

  + content
  |
  +--- header_section
  |
  +--- body_section
  |
  +--- footer_section

Additionally to the content tree and the sections, instances of Simplabs::ContentRepository::Content might be associated to containers (Simplabs::ContentRepository::Container). Containers are not structured in trees, but discrete buckets that group certain content or parts of the content tree, e.g.:

  + parent_content
  |
  +--- child_content1       => container1
  |
  +--+ child_content2
     |
     +-- sub_child_content  => container2

To add some semantic tagging options, there are also tags that can be associated to instances of Simplabs::ContentRepository::Content.

Simplabs::ContentRepository::Content has the following properties

  • name: internal name, will be used as title by default
  • title: if name and title differ
  • slug: used to access the content, generated auomatically from the name, can be overridden
  • parent: the parent content
  • container: the associated container
  • timestamps

Simplabs::ContentRepository::Container has the following properties

  • name: internal name, nothing else is needed for containers
  • timestamps

Simplabs::ContentRepository::Section has the following properties

  • name: internal name
  • body: holds the actual content of the section, e.g. body text of a blog post
  • content: the content the section is associated with
  • timestamps

The content class Simplabs::ContentRepository::Content also adds a finder method find_by_slug that allows finding of content by its path in the content tree, e.g.

  Simplabs::ContentRepository::Content.find_by_path(['parent_content', 'child_content2', 'sub_child_content'])

would return the child leaf in the above content tree.

Custom Content Types

The default content model can of course be subclassed to implement custom content types. For example, if you want to create a structure that has categories and articles where articles are the categories’ children

  + category 1
  |
  +--- article 1
  |
  +--- article 2
  |
  + category 2
  |
  +--- article 3

you just add models for article and category. The only thing you have to do in addition to that is tell ContentRepository that the parent of an article is not of type Content anymore but of type Category and that the children of a category are of type Article:

  class Category < Simplabs::ContentRepository::Content

    has_children :articles

  end

  class Article < Simplabs::ContentRepository::Content

    has_parent :category

  end

Both has_parent and has_children take a class as second argument if it cannot be inferred from the association name.

Installation

Installation requires 2 simple steps:

get the plugin

From your RAILS_ROOT in Rails &gt;= 2.1, do

  ./script/plugin install git@github.com:marcoow/content_repository.git

If you are on Rails &lt; 2.1, do this from your RAILS_ROOT

  git clone git@github.com:marcoow/content_repository.git vendor/plugins/content_repository

generate migration

  ./script/generate content_repository_migration add_content_repository_tables

migrate

  rake db:migrate

TODOs/ future plans

At the moment there are neither TODOs nor future plans. If you want ot suggest any, do so at github.com/marcoow/content_repository/issues.

Author

Copyright © 2008-2010 Marco Otte-Witte (simplabs.com), released under the MIT license

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server