Converting LiquidWiki to 5.0 (and maybe fixing a few gotchas)... (Part 1)

Background: LiquidWiki was a great attempt at getting wiki functionality into Drupal. Unfortunately, even in its native 4.7, users had problems installing it. I'm going to walk through the development process of converting LiquidWiki to 5.0. I hope this well help other developers (or even end users) in their quest for Drupal glory.

Our primary objective in this overhaul is to get Liquid working with 5.0, but we also want to make sure that we're using all of the nifty new features that help end users.

First, let's get LiquidWiki 4.7.x-1.x-dev from drupal.org (available here: liquidwiki)

The unpacked directory will look something like this:
...po (directory)
...README.txt
...mw_sanitizer.inc
...mw_parser.inc
...liquid_wikipage.module
...liquid_filters.module
...liquid.mysql
...liquid.module
...LICENSE.TXt

There are several important files missing for an ideal 5.0 module. Let's go ahead and create them before we worry about code.

The first file is a .info file. A recent introduction to Drupal 5.0, this file describes the module being added, specifically puts it into a package, and allows for dependencies (other modules required for this module to work properly).

A good .info file would have the following code:

liquid.info

name = LiquidWiki Project
description = Allows for the creation of wiki within Drupal

version = "HEAD"
project = "liquid"

Now, the name is the Long Title of the module being installed. The description is the text you will see on the modules page on the administration section. I have set the version to HEAD to reflect that these code changes aren't committed. The project identifier is liquid (when in doubt, go with the name of the folder of the project you are working in).

The next missing file (even in 4.7 *gasp) was the install file. This file sets up the database and does any work that needs to be done to make the module will work. Let's create a nice simple one that'll get liquidwiki up and running, and revisit it later to add more advanced features (like uninstall).

liquid.install

<?php

//@TODO: Postgres support

function liquid_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query('

CREATE TABLE {wiki_name}(
wid varchar( 128 ) NOT NULL ,
nid int( 10 ) unsigned NOT NULL ,
PRIMARY KEY ( wid ) ,
UNIQUE KEY nid( nid )
);');

db_query('CREATE TABLE {wiki_moveref}(
src varchar( 128 ) NOT NULL ,
dest varchar( 128 ) NOT NULL ,
PRIMARY KEY ( src )
);');
break;
}
}

...and that's all she wrote for new files to be added. Check out the second part of the series to see what code changes need to be made, and the third for improvements (fixing gotchas and applying patches).

Trackback URL for this post:

http://www.vancouvertechguy.com/trackback/18