/contrib/famzah

Enthusiasm never stops

Migrate your TWiki to Google Sites (using Google Sites API and Perl)

9 Comments

If you want to transfer your existing TWiki webs to Google Sites, you can do it automatically with the power of the Google Sites API and Perl.

You can download the Perl script, which I used to export my TWiki webs and then import them in Google Sites, at the following page: http://www.famzah.net/download/google-api/twiki2googlesites.pl

Note that this is in no way a complete migration solution. You can use it as a demonstration/base on how to interact with the following Google API features using Perl:

Now you know that you can use Perl to interact with Google APIs. Go build your own scripts!

Update: Google released Python command line tools for the Google Data APIs (GoogleCL). They seem promising and very easy to use for simple automation tasks.

P.S. If you’re limited on time and your TWiki is relatively small on pages count, you’ve got a pretty good chance of migrating it manually with copy/paste, than writing your own migration scripts. Believe me. 🙂

Author: Ivan Zahariev

An experienced Linux & IT enthusiast, Engineer by heart, Systems architect & developer.

9 thoughts on “Migrate your TWiki to Google Sites (using Google Sites API and Perl)

  1. that is very cool!

    Someone might be interested at some stage to package this code up into PublishPlugin – for http://foswiki.org of course 🙂

    And so in the interests of those that come after, is there any chance that you would add an explicit license for this code (GPL?).

    Cheers and Beers
    Sven

    • Sure, I’ve added a GPL license. The weakest point of the script is the render_wiki_to_html() function. If someone implements it right, I could be of help with the other stuff like communicating with the Google API.

  2. I realize this is an amateur doubt but no one seems to be able to help, so here goes:
    I would like to know if the “wiki-data” has to be within my system or whether a remote TWiki would also suffice. I’ve got the code to run and linked it to my Google Site but nothing happens. Any pointers would be highly appreciated

    • You either have to run the script from the server hosting your TWiki site, or copy all TWiki files in the folder pointed by $wikidata. This folder contains all your TWiki webs and pages in the following format:
      $wikidata/$web/$page.txt

      Furthermore, you need to edit the variable @webs_to_import accordingly. If Google Sites don’t accept some of your web names (I forgot what the policy is), you may need to edit camelcase2dashes() too.

      As a start, first uncomment the two create_page() examples in main(), which will create two sample pages in your Google Sites. The “print Dumper(get_created_pages())” statement will try to read those pages back using the Google API. Once you are sure that the script is interacting properly with the Google Sites API, continue debugging what’s happening locally when analyzing your existing TWiki file structure.

      • Thank you. However, on a slightly different note, I’ve managed to get the html code of the twiki using perl. Would it be possible for me to directly add that page into my Google Sites (via the HTML box)? Or would some modification of the create_Page() allow me to do that?

      • I’m not an expert on Google Sites, but this seems doable, yes. You can copy/paste the HTML source directly. The Perl script does pretty much the same.

  3. I wish to take a bunch of TWikis and be able to place them under a page titled “TWikis” in my Google Site and not actually migrate the entire TWiki. Will a modification of your code allow me to do that?

Leave a Reply to Ivan Zahariev Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s