Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
Setup gemcutter as gem source:
sudo gem install gemcutter gem tumble
And install irwi gem (recommended):
sudo gem install irwi
And add to your environment.rb:
config.gem "irwi", :source => "http://gemcutter.org"
Or in your application directory call:
script/plugin install git://github.com/alno/irwi
In your application directory call:
script/generate irwi_wiki
It will generate:
-
WikiPageController to serve wiki pages
-
WikiPage model to represent page
-
Migration to prepare database
Also it will add to your routes.rb
something like:
map.wiki_root '/wiki'
You can link pages by using
- [Some page title]
-
construction in text. If linked page exists, when it will be replaced with link to this page, in other case it will be replaced with link to new page with such path/title.
You may create your own templates for controller actions (
show
,edit
andhistory
), in other case default built-in templates will be used.Following helpers are defined by default and you may replace them with you own:
-
wiki_user
- Renders user name or link by given user object. By default renders <Unknown> fornil
and “User#{user.id}” for others.
Configuration options are acessed via
Irwi.config
object. Currently supported options:-
user_class_name
- Name of user model class. By default - ‘User’ -
formatter
- Formatter instance, which process wiki content before output. It should have methodformat
, which gets a string and returns it formatted. By default instance ofIrwi::Formatters::RedCloth
is used (requires RedCloth gem). Other built-in formatter isIrwi::Formatters::BlueCloth
(requires BlueCloth gem). Option accepts formatter instance, not class, so correct usage is:Irwi.config.formatter = Irwi::Formatters::BlueCloth.new
-
comparator
- Comparator instance, which builds and renders a set of changes between to texts. By default instance ofIrwi::Comparators::DiffLcs
is used (requires diff-lcs gem).
If you want (and it’s good idea) to specify which users can see or edit certain pages you should simply override following methods in your controller:
-
show_allowed?
- should returntrue
when it’s allowed for current user to see current page (@page). -
history_allowed?
- should returntrue
when it’s allowed for user to see history of current page (@page) and compare it’s versions. -
edit_allowed?
- should returntrue
when it’s allowed for current user to modify current page (@page).
Irwi allows easy attachment integration in your wiki. There area several simple steps to add attachments to wiki pages:
-
Call
irwi_wiki_attachments
generator. It will create WikiPageAttachment class. -
Include
config.gem "paperclip"
in yourenvironment.rb
or, if you prefer another library modify generated code for it. -
Append to initializer (or create a new one) something like
Irwi.config.page_attachment_class_name = 'WikiPageAttachment'
. -
Run
rake db:migrate
and start using attachments in your wiki!
If you have Rails prior to 2.3 when you should also call:
script/generate irwi_wiki_views
To generate default wiki views.
If you get some weird errors like
missing interpolation argument in "%{count} %B %Y, %H:%M"
Please check your Rails and I18n versions, because of incompatibility issue between Rails prior to 2.3.6 and I18n 0.4.x (github.com/svenfuchs/i18n/issues/issue/20). If it’s your case, consider upgrade of Rails or downgrade of I18n. Big thanks to Tomasz Stachewicz for information ;)
-
Alexey Noskov (github.com/alno)
-
Ravi Bhim (github.com/ravibhim)
-
Pavel Valodzka (github.com/valodzka)
-
Xavier Defrang (github.com/xavier)
Feel free to add yourself when you add new features.
Copyright © 2009 Alexey Noskov, released under the MIT license
-