An open API service indexing awesome lists of open source software.

https://github.com/bagilevi/relaxedwiki

Rails plugin adding wiki functionality to a RelaxDB model.
https://github.com/bagilevi/relaxedwiki

Last synced: 3 months ago
JSON representation

Rails plugin adding wiki functionality to a RelaxDB model.

Awesome Lists containing this project

README

        

RelaxedWiki
===========

RelaxedWiki is a Rails plugin, that can add wiki functionality to any model that
extends RelaxDB::Document.

It can be used in 2 ways:
* make your documents editable via a normal form and via the markup
* make your documents simply editable via the markup (this way you don't need a controller)

!!! UNDER DEVELOPMENT !!!

Requirements
============

* rails 2.3.4
* relaxdb plugin (my fork here: http://github.com/bagilevi/relaxdb)
* wikitext ruby extension
* haml (for the generated views)
* jQuery (but you can replace the jQuery code easily)

Example
=======

In environment.rb make sure that relaxdb comes before relaxedwiki in the plugin
list:

config.plugins = [ :relaxdb, :relaxedwiki, :all ]

Generating controller and views:

ruby script/generate relaxedwiki

Add these to the routes.rb file:

map.connect ':class/:slug', :controller => "Wiki", :action => "show"
# TODO: new+create
map.connect ':class/:slug/edit', :controller => "Wiki", :action => "edit"
map.connect ':class/:slug/update', :controller => "Wiki", :action => "update"
map.connect ':class/:slug/changelog', :controller => "Wiki", :action => "changelog"
map.connect ':class/:slug/versions/:time', :controller => "Wiki", :action => "version"

Adding wiki functionality to your model:

class Recipe < RelaxDB::Document

property :title
property :ingredients # array
property :preparation

acts_as_relaxedwiki_document

# Optional. This is run before save if the user edited via the form.
def generate_wiki_content
self.wiki_content = "#{self.title}\n\n#{self.ingredients.join("\n")}\n\n#{preparation}"
end

# Optional. This is run before save if the user edited the markup.
def parse_wiki_content
self.title = "parsed title from wiki_content"
self.ingredients = ["parsed ingredient 1 from wiki_content", "..."]
self.preparateion = "parsed preparation from wiki_content"
end

# IMPORTANT! your model has to have a 'slug' property for the routing to work.
end

You don't even need a controller, Wiki_Controller handles it all if the routing is configured.

If you use your own controller, wrap your normal fields this way:

wiki_hybrid_form(@recipe) do
# ... your normal form fields
end

Copyright (c) 2009 Levente Bagi, released under the MIT license