Drupal Wiki

Using Drupal as a Wiki

I decided to move my presonal site over to Drupal. The old site was partly manually created HTML and partly PMWiki. I liked PMWiki because it was fairly simple and worked well. One of the add-ons I used was syntax highlighting for code that I post. Having looked around at a few CMS's I decided Drupal was probably a good fit for my requirements, well coded, well supported and with more modules that I could shake a stick at.

So how to do a wiki with syntax highlighting in Drupal?

Well the up-shot of this long post is that I ended up creating my own filter module to wrap PMWiki. See Wiki Module for Drupal

But before I came to writing my own module it took me quite a while of trying things out to get there. Personally I am not too bothereed about revison history, diffs, etc. since the wiki is just something I use to put content up quickly from any location, rather than it being a multi-contributor type wiki. In the end I had to install the following Drupal Modules:




Wikitools gives some wiki like behaviour and freelinking allows for camel case links and page creating pagesif a link does not exist. Both of these were easy to install and configure: unpack in the modules directory of your drupal installation, just grant permissions to use them in Administer - Site Building - Modules, and they are there.

Syntaxhighlighter was also reasonably easy to set up (I have no real reason for choosing this over GeShi but the old PMWiki syntax highlighter was client side and I was happy with it). Down load the module and then down load the Syntax Highlighter Javascript library separately. Put the Javascript library in sites/all/libraries (it can go in a sub directory of this). Again you need to grant permissions to use the module and then go to Administer - Site Configuration - SyntaxHighlighter and turn on the languages you want.

Now for wiki formatting ... Naively I had thought that Wikitools would do this, but it doesn't. There seem to be two options for wiki formating, flexifilter and pearwiki_filter. Initially I tried flexifilter becuase it has more recent releases than pearwiki filter. But flexifilter just does not work, even after a lot of fiddling around, applying pathces, etc. So I went to pearwiki.

I found the pearwiki_filter documentation pretty scant, it turns out that you need to download the module and again separately download both the Text_Wiki and the appropriate Wiki Format - e.g. Text_Wiki_Mediawiki. Then you have to get these in the correct directories, and I found a restart of Apache was needed just to everything refreshed (although there may be a simpler way of doing this).

So pearwiki_filter is installed, but how to configure/administer it? I could not find the config settings. After an hour or so of searching I figured out that you do this from Site Configuration - Input Formats - {Configure an input format} - select PearWiki and save and then click the |Configure| tab for that format. This gets you all the config for that input format, including Pear Wiki. I created an input format called Wiki to include all these modules, turned on the book modules and create my wiki pages as book pages. After rearranging the input format so that PEAR Wiki Filter came before SyntaxHighlighter, everything was ok except for one problem. PEAR Wiki Filter was putting <P> and <BR> tags in the code. I tries using <PRE> tags instead of {syntaxhighlighter brush: java} around the code, but that didn't work. In the end I used a regex (regular expression) to cause PEAR Wiki Filter to ignore {syntaxhighlighter brush: java}. The regular expression needs to do multi line matches so ends up looking like this:


Having got all this working the formatting options of Pear Wiki were pretty limited and moving my original pages across was not going to be trivial. So faced with a lot of editing, or some coding, I went with the coding and wrote PMWiki filter module. See Wiki Module for Drupal