Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
MIT-LICENSE | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
generators/ | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
rdoc/ | ||
| |
spec/ | ||
| |
tasks/ | ||
| |
uninstall.rb |
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 >= 2.1, do
./script/plugin install git@github.com:marcoow/content_repository.git
If you are on Rails < 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 Marco Otte-Witte (simplabs.com), released under the MIT license








