Friday, August 14, 2009

Pimp My Instiki

Previous: Installing support for .NET development.

Instiki is a simple wiki that I use to keep track of useful information. I find it easier to find information if it's organized in a wiki than if it's scattered all over the filesystem.

To get Instiki, go to http://www.instiki.org and download it. There's no further installation to do, and no mandatory configuration before you can start using Instiki. Start an instance by navigating to the directory where you installed Instiki and running the instiki command.

Instiki is very simple and is Open Source. Users are encouraged to customize it. Some people use Instiki as the basis of public websites, and they do some pretty extensive customization. For my purposes, it's just a single-user wiki running on my laptop. To make it a little friendlier and better integrated with my desktop, I've made the following changes.

Start and stop scripts


As shipped, Instiki expects you to start it from a command line and stop it by typing ctrl+C. I set up a start script that starts Webrick in the background and saves the pid so that a kill command can be issued later.

Start script is ~/bin/wiki. It picks up the pid from stderr, where Instiki writes it, and creates the stop script on the fly in ~/bin/wiki_stop. The stop script does a kill -9, since Instiki appears to ignore SIGTERM.
#!/bin/bash
# Start the instiki wiki
cd ~/wiki/inst*
`./instiki 2> wiki_$` &
sleep 12
# Grab the pid and create a quick
# and dirty shutdown script.
echo `awk '/pid=/ {split($5,thepid,"="); print "kill -9 "
thepid[2]}' wiki_$` > ~/bin/wiki_stop
chmod +x ~/bin/wiki_stop
# This will start Firefox if necessary.
# Otherwise it will open in a new tab.
firefox http://localhost:2500/
I set up aliases for the scripts in ~/.bash_aliases.
alias wiki='~/bin/wiki'
alias wiki_stop='~/bin/wiki_stop'

Associated an icon with Instiki and created a desktop definition


AFAIK no one has yet created a logo or icon for Instiki. I found a nice one in a set called Influens by artist Matt U on Deviant Art, at http://mat-u.deviantart.com/art/influens-icons-62280875. It looks like this:


The icon is apopros of the way I use Instiki in that it depicts a folder of documents with sticky notes on them, suggesting an informal, working scratchpad area.

I copied it to ~/wiki/instiki.png and created an instiki.desktop file in /usr/share/applications with the following contents:
[Desktop Entry]
Encoding=UTF-8
Name=Instiki
Comment=Personal Wiki
Exec=wiki
Icon=/home/dave/wiki/instiki.png
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
Made the favicon for Instiki match the desktop icon by copying the .ico version of the file to ~/wiki/inst*/public/favicon.ico.

Reclaimed screen real estate when viewing a page


By default, Instiki displays wiki content in a narrow column centered on the page. To make this area wider I made the following change in ~/wiki/inst*/public/stylesheets/instiki.css. As shipped, the definition of #Content looks like this:
#Content {
border-top:none;
margin:auto;
padding:0.3em;
text-align:left;
width:100%;
max-width:55em;
}
I removed the max-width specification, resulting in this:

#Content {
border-top:none;
margin:auto;
padding:0.3em;
text-align:left;
width:100%;
}

Reclaimed screen real estate when editing a page


The edit and create views provide a small textarea for entering content. They also display a few examples of wiki markup in an area on the right-hand side of the frame. Since I'm using Instiki on my local machine only, I don't have to worry about accommodating different screen sizes or different markup languages. I'd rather have a large textarea that mostly fills the frame. I don't need the markup help to be visible all the time and I'm always using Textile, so I could free up some real estate by replacing the help area with a single link. Here are the portions of ~/wiki/inst*/app/views/wiki/edit.rhtml that were affected, as shipped:

<%-
@title = "Editing #{@page.name.escapeHTML}"
@content_width = 720
@hide_navigation = true
-%>

<div id="MarkupHelp">
<%= render(:file => "#{@web.markup}_help") %>
<%= render(:file => 'wiki_words_help') %>
</div>

<% form_tag({
:action => 'save',
:web => @web.address,
:id => @page.name },
{ 'id' => 'editForm',
'method' => 'post',
'onsubmit' => 'cleanAuthorName()',
'accept-charset' => 'utf-8' }) do %>
<div>
<textarea name="content" id="content" rows="24" cols="60">
<%= h(flash[:content] ||
((params['content'] && params['content'].is_utf8?) ?
params['content'] : @page.content).purify) %></textarea>
. . .
I removed the MarkupHelp div, added a link to Textile help to open in a new tab, and increased the size of the textarea, resulting in this:

<%-
@title = "Editing #{@page.name.escapeHTML}"
@content_width = 720
@hide_navigation = true
-%>
<% form_tag({
:action => 'save',
:web => @web.address,
:id => @page.name },
{ 'id' => 'editForm',
'method' => 'post',
'onsubmit' => 'cleanAuthorName()',
'accept-charset' => 'utf-8' }) do %>
<div>
<a href="http://hobix.com/textile/quick.html"
target="_blank">Textile Help</a><br />
<textarea name="content" id="content"
rows="30" cols="190"><%= h(flash[:content] ||
((params['content'] && params['content'].is_utf8?) ?
params['content'] : @page.content).purify) %></textarea>
. . .
I made the same changes in ~/wiki/inst*/app/views/wiki/new.rhtml.

Disabled spam filtering


Since this instance of Instiki resides locally and is not accessible on the network, I didn't need Instiki to protect me from my own innocent updates. I disabled spam filtering by deleting the file config/spam_patterns.txt.

One more thing...


I copied my personalized version of Instiki over from my MacBook Pro rather than installing Instiki fresh and repeating the modifications. Initially, Instiki would not start up. It displayed the catch-all "Do you smell smoke?" message and offered no clues on the console or log file.

A brief Internet search turned up a note on http://rubyforge.org/pipermail/instiki-users/2009-April.txt reporting that on Debian and its variants (including Ubuntu) some packages on which Instiki depends are not installed by default. I ran the following command, and the problem was fixed:
sudo apt-get install 
ruby1.8-dev swig libsqlite3-ruby1.8 flex bison


Next: Installing Git

No comments:

Post a Comment