Loading...
 

ConversionFromTWiki

Name

twiki2tiki.php - Migrate a TWiki web collection into TikiWiki.

Synopsis

twiki2tiki.php may be a helpful start for automating the process of converting your TWiki web into Tikiwiki pages. I wrote it to do the job on my particular installation (php-4.4.0 and MySql-3.23.59). Although I expect the code to be reasonably portable, I make no guarantees. Expect to get your hands dirty.

The program relies heavily on PHP MySQL functions and Perl-Compatible Regular Expression Functions. You'll need to have those extensions installed and be using a MySQL database then for this to work.

Features

The script is written so you should be able to run it as many times as you want and data that's already existing in the Tiki database will just get updated with your TWiki pages. This can be useful for debugging the conversion process since you don't need to empty your tiki_pages each time you want to run the program. Also, in theory, you can maintain an active TWiki installation and use this script to continuously update the Tikiwiki with it (although, any modifications you make in a Tikiwiki page will get blown away with the TWiki content each time you run the code).

Handled Conversion Rules:

  • Headings
  • Bullet Lists
  • Enumerated Lists
  • %HOMETOPIC% and %WEB% variable translation
  • Bold, Italic and Bold/Italic types
  • Preformatted text
  • Attached file syntax
  • Attached image syntax
  • Tables (though vertical span of cells is not possible)
  • External links
  • Wiki references


Nov. 6, 2005 v.0.2

  • Bulked up regex rules for improved matching
  • Added rules for <code>, <br> and TWiki specific weblinks
  • Handles file attachments. Gets mime class by including the tiki lib/mime/mimelib.php for the tiki_get_mime() function.
  • Toss out unused META tags


Nov. 16, 2005 v.0.3

  • Minor bug fixes including:
    • Properly locating files that are attached to the TWiki Web homepage for copying
    • Don't transform email addresses that contain the twiki_web name into wiki links
  • Added rule to force wikiwords followed by a colon with no whitespace into a wikilink
  • Add translation rule for TWiki Math Plugin formulae


Nov. 22, 2005 v.0.4

  • Convert <nop>WhateverWord into ))WhateverWord((
  • Toss out %BR% tags
  • Handle img src tags that don't have alt flag
  • Force wikilinks to ))BumpyWords(( followed by double underscore
  • Throw out %COMMENT% tags
  • Remap some icons into smileys
    • Check mark %Y% => arrow
    • New %N% => exclaim
    • Pencil %P% => question
    • Star %S% => idea
  • Eliminate ))BumpyWords(( in $filedesc since it causes problems in the img alt field
  • Tweaked ))BumpyWords(( match pattern from [A-Z][a-z]+[A-Z][a-z]+\w+? to [A-Z][a-z]+[A-Z]\w+?
  • Tweaked italic matching rule
  • Translate <a hrefs> (embedded div's will cause a problem)
  • Calculate md5 filename based on concatenation of pagename and filename. This way identical filenames on different pages don't conflict in file storage... and files will be appropriately updated when re-runing the script since the md5 hash is reproduced each time the script is run.
  • Translate Twiki color tags: %COLOR% to Tiki ~~#000000:text~~ syntax

Installation

MAKE A BACKUP OF YOUR DATABASE. I'm not kidding. I make backups when running this code on my own database... I doubt you should trust me any more then I trust myself. Also, backup your TWiki installation. The script only reads the files in there... but best be safe.

Unzip twiki2tiki.tgz into a directory you can point your browser to. I strongly suggest you secure this directory (eg. user authentication). It will soon contain a config file with your database password in clear text. (You could also dump the files in some private directory and parse it by php manually but the output won't be as pleasant).

Edit the twiki2tiki_cfg.php file. You'll basically need to change just about every line to properly configure the script for your system. The file comments will tell you what to do.

Point your browser to twiki2tiki.php. Perhaps it will work.

Known Bugs

  • I expect the regexp's aren't as robust as they could be in the conversion rules.
  • Tags that extend over more then one carriage return (ie multiple lines of bold, italic etc.) are not matched for translation
  • If you have more then one file of the same name on differing pages, the last one migrated will be the only file of that name. That is each file of the same name will replace any predecessor.

Todo

  • Come up with a srategy to handle %SEARCH directives
  • Handle migration of users?
  • Include a way to map TWiki wiki page names to different Tiki wiki page names?
  • Do something with the TOPICINFO metadata in the TWiki page.

Author

Art Davis

Files

See attached


Page last modified on Wednesday 23 November 2005 18:17:23 GMT-0000

Upcoming Events

No records to display

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.