Thoughts on Systems

Emil Sit

Jan 2, 2006 - 2 minute read - Hacking dokuwiki moinmoin wiki

Migrating from MoinMoin to DokuWiki

On our webserver, we run a wiki for tracking various administrative bits. Today, we migrated it from MoinMoin 1.3 to DokuWiki. This was not entirely trivial but at the same time not that difficult. The following method doesn’t preserve history, users or attachments, but seems to basically work. The handling of categories could probably use a little work though.

  1. First, find the latest revision of the files and move them to the right place. In sh, this is expressed roughly as:

    cd $MOINWIKI/main/data/pages
    for i in *; do
        r=$(ls -tr $i/revisions 2>/dev/null | tail -1);
        if [ "$r" ]; then
            cp $i/revisions/$r $DOKUWIKI/data/pages/$i.txt;
  2. Next, you’ll need to handle any categories manually and move them into subdirectories for namespaces. This could probably be automated by splitting based on the (2f)s in the filenames.

  3. Since DokuWiki prefers lowercase filenames, go ahead and lowercase all the filenames, e.g.:

    rename '$_ = lc($_)' *.txt

    using this handy perl script. You can repeat this for each namespace/category.

  4. Hack the markup. Create the following script:

    #!/usr/bin/perl -ni.bak
    BEGIN { $readblank = 0; }
    $readblank = 1 if /^$/;
    # Fix line-endings for Unix
    # Ignore all pragmas
    next if !$readblank and /^#/;
    # Fix different a href linking styles
    # Fix lists that aren't indented enough
    s/^ \*/  \*/;
    # Fix ordered lists
    # Fix code blocks
    # Fix monospace/code text
    # Fix headers
    s/^= (.*) =$/====== $1 ======/g;
    s/^== (.*) ==$/===== $1 =====/g;
    s/^=== (.*) ===$/==== $1 ====/g;

    and run it on each file (find . -name "*.txt" | xargs -n 1 perl

  5. Make sure your local.php sets $conf['camelcase'] = 1.

  6. You’ll need to move your attachments from the various attachments subdirectories and move them into DokuWiki’s media subdirectory and fix up the links.

That’s it!