Moving off MediaWiki to a static site

Moving off MediaWiki to a static site


  • Ease of use - edit text straight on the desktop with a desktop app, all text is up to date and available
  • Simplicity - no need to remember, keep logins and anti-spam plugins, sql configs and mediawiki internals
  • Security - Reduce attack vector, no more php, mysql or mediawiki plugins

How it works

  1. Store files locally in the zim wiki format as a part of the documents notebook
  2. Have the text files version controlled with github. This way a web server and any number of remote systems can have a recent copy
  3. Have the web server notice change in the github repository and recreate the site, emailing the summary to me

GitHub can be used for editing the files directly on the web.

How to migrate

Here are the steps needed to migrate. This took a bit longer than I expected, with quite a bit of coding to beat various tools into shape.

Convert MediaWiki to Zim wiki

  1. Extended pandoc to write in ZimWiki. I built a native haskell module, thinking that the zimwiki syntax is close to DokuWiki that I might reuse the DokuWiki export code, where in reality it should have been done in a Lua external script. Haskell has a steep learning curve.
  2. Export media wiki into an xml file by using the Special:Export page
  3. Run the wiki extractor script, that I modified to extract individual files, WikiExtractor to individual
  4. Run the extended pandoc to convert extracted mediawiki files into zimwiki format
  5. Run a post-processing for fixing converted files that pandoc is not suited to do (changing links from categories to tags for example)

Create the static site locally

  1. Grab a Mediawiki html code and convert it to a zim template so that the static site looks like mediawiki.
  2. Run zim export your text into html. I had to extend/fix zim because it had issues with exporting (index/source code)
  3. Write a bash script to do the export for all the files

Move to the server

  1. Push the source zim text files into a github repository
  2. Install zim on the server and make sure it can do the export without the gui component. I had to extend zim and the sourceviewer plugin so they can operate without the gui.
  3. Install a github webhook PHP on the web server and configure it. I modified one to look for the shared secret instead of relying on the source IPs. Configure the webhook on Github
  4. Create a script, triggered by the webhook PHP to pull the github repo, regenerate the site and email the results

Attachments: 182b
diagram.png 33.8kb