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.
- Host: GitHub
- URL: https://github.com/bagilevi/relaxedwiki
- Owner: bagilevi
- License: mit
- Created: 2009-11-17T15:26:12.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2009-12-01T16:54:40.000Z (over 15 years ago)
- Last Synced: 2025-01-13T04:41:48.130Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 82 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: MIT-LICENSE
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 :preparationacts_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.
endYou 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
endCopyright (c) 2009 Levente Bagi, released under the MIT license