Was this page helpful?

Importing a TWiki into MindTouch

    Prerequisites

    A working Mindtouch (tested with 8.08.1a and 9.02.2)

    A TWiki

    Perl 5.8 (This script was run via a Linux vm, but may work under Active Perl or Strawberry Perl).

    Background

    We have several TWiki instances in our organisation, each administered by a different person, with no access for users to the filesystem. This script simply 'scrapes' the web output of the TWiki and inserts the page into a Mindtouch instance. It is possible to import all versions of a page, but I find that very few people even know that revisions are kept; much less that they ever view them or revert. The script has commented out code (for you to play with) that does the revisions. I have used it once, but don't really know why.

    Script

    Put the following files in the same directory on a machine that has Perl available. If you execute

    perl -c upload_TWiki.pl

    it should tell you if you have all of the modules that you need:

    use Carp;
    use DateTime;
    use LWP;
    use HTTP::Cookies;
    use HTTP::Request::Common qw{GET POST};
    use URI::Escape;
    use MIME::Types qw{b_suffix};
    use Data::Dumper;

    Dream.pm

    This is the Perl module that does all the work. You should not need to look in here.

    upload_TWiki.pl

    This is basically the configuration file that calls the main run method. Hopefully it is self explanatory.

    Use

     

    Create an import user (local) on your Mindtouch. Give them Admin access. Contributor should work, but I like overkill.

    Fill in all of the parameters for hte $deki object. Again, these should be fairly obvious.

    The script imports ONE Twiki web at a time.

    TWiki stuff

    Page Naming

    The TWiki uses flat files. Most people prefix each page-file with a group or collection name, such as MyGroupName. This gives a set of pages:

    MyGroupNamePeople MyGroupNameAddresses MyGroupNameToDo

    This script promotes MyGroupName to a page on its own, with all the other pages below it, with MyGroupName stripped off. The child pages are not further split. You will have to do this by hand (but it wouldn't be hard to script if you wanted). You will end up with lots of pages to move if your TWiki is big.

    Attachments

    Images and other files are (mostly) scraped and added to the correct mindtouch pages. They are also (mostly) correctly linked to, and inserted into pages where required. I have had one file upload fail because TWiki output > rather than > ; I'm not so bothered that I can't import one missing file by hand. Similarly, one .txt file failed to link properly, even though it uploaded fine.

    Users

    We are moving to LDAP user management. Local TWiki users are therefore no longer needed...

    Bugs and missing features

    Well, this was not test-driven development. It worked for me. The only problem I get is on 8.08 being unable to delete the imported tree in one hit. The workaround is re-naming the top level imported page and then deleting that and its children.

    If your TWiki is password protected you'll have to add an AuthBasic parameter to the user agent to get the pages. If anyone locally wants me to import a protected site, I'll add the feature and post the new code here.

    Remember that it's unsupported code, and I am unlikely to want to do more work on it as it's reached end-of-life for me!

    Was this page helpful?
    Tag page

    Files 2

    FileVersionSizeModified 
    Viewing 3 of 3 comments: view all
    awesome! Thank you so much Tim!

    Using the deki vm I needed to install a couple of perl modules (apt-get install libdatetime-perl libmime-type-perl) before perl -c would stop complaining. edited 22:38, 16 Oct 2009
    Posted 11:58, 3 Sep 2009
    Hello, this is really cool, but I have a different setup in my Twiki installation and I'm wondering if you can give me some guidance on how to proceed.
    Basically, we created sub-webs like the following:
    Company/
    Operations
    Development
    Management
    Processes
    CustomerService
    (Company being the main web, and all the following being sub-webs)
    I've tried a number of ways editing upload_Twiki.pl to suit the existing configuration, but always get "Topic " doesn't exist yet..." (note that the topic is a lonely double-qoute...).

    Any help is greatly appreciated.

    Adam D edited 11:12, 20 Nov 2009
    Posted 11:11, 20 Nov 2009
    Hi,

    I've tried this script on both debian sarge and vista using active perl, and I get the same error every time:

    twiki-move:~# perl -w upload_TWiki.pl
    Use of uninitialized value in hash element at Dream.pm line 95.
    Use of uninitialized value in hash element at Dream.pm line 96.
    Use of uninitialized value in hash element at Dream.pm line 96.
    Use of uninitialized value in hash element at Dream.pm line 98.
    Use of uninitialized value in hash element at Dream.pm line 98.
    Use of uninitialized value in hash element at Dream.pm line 98.
    Can't use an undefined value as an ARRAY reference at Dream.pm line 98.
    (in cleanup) Can't access `DESTROY' field in class Dream at upload_TWiki.pl line 0
    Posted 18:39, 1 Dec 2009
    Viewing 3 of 3 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by