User:Austin J. Che/Extensions/dumpRewrite

From OpenWetWare
Revision as of 19:48, 12 April 2006 by Austin J. Che (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

dumpRewrite

This is a script like the other mediawiki maintenance scripts. It was written to allow the importing of another mediawiki into OpenWetWare. Although it has currently only been tested on one wiki, it should be general enough to extract any portion of one wiki, rewrite it using regular expression rules, and import those pages into another wiki. For example, it can be used to dump an entire wiki, prefix all page titles with Foo/Bar and also rewrite all links such that they point to the correct page name. The rewriting code currently relies on the subpage feature of MediaWiki to work correctly.

This is only a skeleton of what you have to do because if you want to use this, you have to really understand what you're doing anyway. Please contact me if you are interested in importing into OpenWetWare another wiki that you have file access to (you have to have shell access to the actual wiki files).

The steps to merge a source wiki (e.g. your wiki) into a destination wiki (e.g. OWW):

  1. Upgrade if necessary the source wiki to at least mediawiki 1.5 and preferably the same version as running on the destination wiki
  2. Images aren't currently handled too elegantly. I simply merge the images directory giving preference for existing images by running yes n | cp -r src-wiki/images/* dest-wiki/images
  3. After the above copy, the permissions should be set correctly to match those of other files so the web server can access them correctly
  4. Run php rebuildImages.php --missing in the maintainence directory of the destination wiki. This lets mediawiki know about the new images.
  5. In the source wiki, run php dumpRewrite.php dump.conf > file.xml to dump the source wiki using the rules in dump.conf. See the example file for the format of this file or read dumpRewrite.php
  6. In the destination wiki (don't do this in the source wiki), run php importDump < file.xml to import the source wiki

You should always test this process on a non-live wiki. I have not found an easy way to revert the import so test it on a copy of the wiki.

Bugs/Enhancements

  • The images could be handled better. There could be name conflicts leading to incorrect pictures showing. Rewriting image names isn't the easiest thing as their location would change.
  • Usernames are not mapped (User: pages can be mapped but that isn't equivalent to the mediawiki notion of a user).

Send bugs and comments to Austin Che. Other extensions including sources can be found at User:Austin J. Che/Extensions.