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).
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.
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;
This is the Perl module that does all the work. You should not need to look in here.
This is basically the configuration file that calls the main run method. Hopefully it is self explanatory.
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.
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.
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.
We are moving to LDAP user management. Local TWiki users are therefore no longer needed...
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!
| File | Version | Size | Modified | |
|---|---|---|---|---|
| ||||
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by
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
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
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