Skip to content

MoinMoin To Git Wiki Conversion Tools

The tools are a set of command line tools under the name moin2gitwiki.

moin2gitwiki

MoinMoin To Git Wiki Tools Command Line Utility

Converts a MoinMoin wiki into a git repository populated with Markdown formatted pages, set up for use on a git based wiki such as the built in wiki for gitea, github or gitlab

This parses the users and the revision structure from the MoinMoin data filesystem. However converting the wiki markup was found to be best done by converting the output HTML using pandoc.

The utility requires git and pandoc commands to be available in the path.

Environment Variables

The common options can also be set by use of environment variables:

  • --debug - MOIN2GIT_DEBUG - Output debugging logging

  • --verbose - MOIN2GIT_VERBOSE - Output verbose logging

  • --syslog - MOIN2GIT_SYSLOG - Send logging to syslog

  • --moin-data - MOIN2GIT_DATA - Data directory for moin

  • --user-map - MOIN2GIT_USERS - User map for moin - see the save-users command for info

  • cache-directory - MOIN2GIT_CACHE - Directory for moin component fetches. This defaults to _cache in the current directory.

Help

Running the moin2gitwiki command on its own will show some help information.

Usage:

moin2gitwiki [OPTIONS] COMMAND [ARGS]...

Options:

  --debug / --no-debug
  --verbose / --no-verbose
  --syslog / --no-syslog
  --moin-data DIRECTORY
  --user-map FILE
  --proxy TEXT
  --version                 Show the version and exit.

check

A minimal check to see if we run in this environment

Usage:

moin2gitwiki check [OPTIONS]

fast-export

Git fast-export all the revisions in the wiki into markdown git wiki form

Named for the git fast-export command, although it actually builds a new git repository and then translates each revision at a time into a command stream for git-fast-import on that new repository. After all pages and revisions have been processed the new git wiki repo instance is garbage collected (to compress all the revisions into a more compact set of git packs) and finally checked out.

Page names are slightly modified - the "(2f)" seen in wiki file names (which is normally displayed as a / character) are changed to underscores. Internal links are remapped - however if a link goes within the wiki namespace to something that was not found in the wiki (this may include attachments which are not currently bought across), then the link is deleted (although the link text is left).

Although the filesystem data is read to derive the revision and history information, the actual page transformation is done by retrieving the page html from its webserver, cutting the content div out of that html, doing a few simplifications and translations (specifcially images corresponding to emojis are converted to emoji forms). This HTML is then pass through pandoc to get a markdown (specifically github flavoured markdown).

Usage:

moin2gitwiki fast-export [OPTIONS] DESTINATION

Options:

  --cache-directory TEXT
  --url-prefix, --prefix TEXT
  --home-page / --no-home-page

save-users

Write the user map out to a file

This writes all the users found in the wiki out to a JSON file. This can then be modified, if required, and used as the input to the --user-map option - typically this would be to fix any email address or name issues.

These user entries are used to set the author of git commits within the output repository.

The file format is an JSON file consisting of an array of user records, which each look like:-

{
    "email": "user@example.com",
    "moin_id": "1358271613.26.36417",
    "moin_name": "SomeUser"
},

Usage:

moin2gitwiki save-users [OPTIONS] FILENAME

translate-page

Fetch a single page revision and translate to Markdown

The first argument is a page name, the second an integer revision.

The translation process is as described for the fast-export command.

Usage:

moin2gitwiki translate-page [OPTIONS] PAGE VERSION

Options:

  --cache-directory TEXT
  --url-prefix, --prefix TEXT