Friday, December 16, 2005

A Simple and Effective Wiki in Ruby

I was looking for a simple but effective wiki to run on Mac OS X for my home network. After a bit of looking, I found SOKS. It was trivial to set up and use.

SOKS is written in Ruby and released under an Open Source license.

To install SOKS, one simply grab it via gems, the ruby package manager, run the setup script and start using it:


$ sudo gem install Soks
$ /usr/local/lib/ruby/gems/1.8/gems/Soks-1.0.3/bin/soks-create-wiki.rb


The soks-create-wiki.rb script will ask you where you want to install the wiki itself. Anywhere will do. The directory you use will be referred to as '...' for the rest of this post.

Use a Web browser to go to http://localhost:8000, which shows you instructions for use and customization. At a minimum, you will want to modify the stylesheet located at .../attachment/stylesheet.css (since the default reds are ugly) and .../attachment/logo.jpg (the site logo). To name the wiki and expose it via a public URL, you will need to modify a couple of lines at the top of .../start.rb, but this is well documented.

I only had one problem with the setup: Some (not all) of the URLs in the sidebar continued to point to localhost, even after I changed the system base URL to a proper machine name. The solution was to edit the sidebar to remove just one of the links and then again to put it back in. Whatever cache was stale happily updated.

Mac OS X uses launchd to launch applications on boot and when directed by the launchctl command line utility. To get the wiki launching automatically, I created a file called /System/Library/LaunchDaemons/soks.plist with the following content:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>soks</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ruby</string>
<string>/Users/dwood/Documents/soks-wiki/start.rb</string>
</array>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>


Once that file is in place, the wiki may be started:


$ sudo launchctl load /System/Library/LaunchDaemons/soks.plist
$ sudo launchctl start soks


I used the Mac's Network System Preferences to open port 8000 in the firewall so other machines on my network could access the service.

NB: Unfortunately, I wouldn't use SOKS on a public machine yet. Ruby 1.8.3 seems to have a broken YAML which prohibits SOKS from running and Ruby 1.8.2 (which I'm using) has a known security flaw. I'm sure the Ruby guys will square that away shortly.

Bernadette and I are using SOKS to work collaboratively on a new book. More details on that coming shortly.

No comments:

Post a Comment