This page was reorganized and split it into 3 parts:

The intent is to delete this page shortly after moin 1.7rc4 or moin 1.7.0 is released. -- RogerHaase 2008-06-21 02:06:20

Help On Moin Dump

Moin Dump is a utility to create static html dumps of MoinMoin wiki content. You can dump single pages or some pages matching a regular expression or the entire wiki. This is an HTML export feature.

You may find it useful to create a static dump for a software release, a high volume read-only copy for a busy organizational web site, a CD-ROM version to carry on trips when you do not have internet access, or use it to create a professional looking manual composed of selected wiki pages using a utility such as HTMLDOC.

Example

To execute Moin Dump, use the command line interface to execute the moin script utility. The backslash characters indicate line continuation in the example below. If your OS does not support command line continuation, key the entire command on a single line.

   python /pathToPython/site-packages/MoinMoin/script/moin.py \
                  --config-dir=/mywiki \
                  --wiki-url=www.myorg.org/mywiki/ \
                  export dump \
                  --page=WikiSandBox \
                  --target-dir=/home/myname/outputdir

The --config-dir parameter is required and must point to the directory containing your wikiconfig.py script.

The --wiki-url parameter is required and must point to the starting URL of your wiki.

The export dump parameters are required and indicate moin.py should execute the dump.py script in the export\ subdirectory.

The --page parameter is optional and will dump pages matching the pagename give (can be a regex to export multiple matching pages). If omitted, the contents of the entire wiki will be dumped, excluding the underlay pages.

The --target-dir specifies the output directory and is required.

Note the --page and --target-dir parameters must follow the export dump parameters.

Example with --page parameter using regular expression

This example exports all pages beginning with the paths:

Each of the above has several sub-pages, which are all exported, eg. Templates/Documentation/TemplateGuide/GenericTemplate

   python /pathToPython/site-packages/MoinMoin/script/moin.py \
                  --config-dir=/pathToPython/site-packages/wiki/config/ \
                  --wiki-url=http://www.myorg.org/mywiki/ \
                  export dump \
                  --page "Templates/Documentation/(CSSGuide|HtmlGuide|TemplateGuide).*" \
                  --target-dir=/home/myname/outputdir

Output

The output directory will be populated with HTML pages corresponding to each page in your wiki, or, some or a single page if you specified the --page option.

An index.html file will be created with the contents of your FrontPage or the single selected page. Subdirectories will be created and attachments that are images, icons, CSS, etc. will be copied. Inter-wiki page links will work as expected on the dumped pages.

Known limitations

Windows issues

Under Windows, a script called moin.bat gets installed under the Python installation directory to make invoking the moin utility script easier. It appears that the path where the dump script looks for the data dir is relative to the current dir, so to get the dump to work you need to cd to the wiki dir you are exporting. The example below will export the entire Wiki.The example below assumes the default install of MoinMoin 1.5.6.

cd C:\pathToPython\share\moin\mywiki
C:\pathToPython\Scripts\moin.bat --config-dir=C:\pathToPython\share\moin\mywiki --wiki-url=www.myorg.org/mywiki/ export dump --page=WikiSandBox --target-dir=C:\BackupPath\outputdir

---

Dump only data pages

In contrast to what is explained above the dump includes system pages and underlay pages (at least with moin-1.5.7). This can be fixed with the following patch:

--- C:\sources\moin-1.5.7\MoinMoin\script\export\dump.py.orig   Thu May 17 15:30:57 2007
+++ C:\sources\moin-1.5.7\MoinMoin\script\export\dump.py        Fri May 18 22:15:30 2007
@@ -122,10 +122,13 @@
                 pages = [page for page in pages if namematch.match(page)]
                 if not pages:
                     pages = [self.options.page]
             except:
                 pages = [self.options.page]
+        else:
+            #remove underlay and system pages from list, i.e. reduce to pure "data" pages
+            pages = [pagename for pagename in pages if Page.Page(request, pagename).isStandardPage() ]
 
         wikiutil.quoteWikinameURL = lambda pagename, qfn=wikiutil.quoteWikinameFS: (qfn(pagename) + HTML_SUFFIX)
 
         AttachFile.getAttachUrl = lambda pagename, filename, request, addts=0, escaped=0: (_attachment(request, pagename, filename, outputdir))

Note that edited underlay pages will be included. For example, if you edited RecentChanges on your wiki, it will be included in your the dump. This happens because underlay pages are protected, and copied into the standard page directory when edited. Thus edited RecentChanges page is considered a standard page.

If you want to exclude edited underlay pages, use this check:

+            # Remove underlay and system pages from list, i.e. reduce to pure "data" pages
+            # Including edited underlay pages
+            pages = [pagename for pagename in pages if not Page.Page(request, pagename).isUnderlayPage()]

However this will also exclude FrontPage, which is an underlay page, and used typically for your front page.

Use a custom template page

When generating sub-pages, moindump is still lacking. This is because the $(navibar)s parameter generates pages that are not generated if you use "--page" as argument. I didn't needed the navibar so I created a small patch where moindump will look in the current output dir for the file moindump.tpl. If the file exists it will load it and replace the page_template with the contents. It might not be the greatest solution, but due to the nature of moindump (being a plugin) it felt wrong to use a global option for only a plugin parameter.

--- C:/Python25/Lib/site-packages/MoinMoin/script/export/dump_org.py    Sat Jan 05 03:00:58 2008
+++ C:/Python25/Lib/site-packages/MoinMoin/script/export/dump.py        Mon Mar 17 20:56:11 2008
@@ -14,10 +14,11 @@
 from MoinMoin.action import AttachFile
 
 url_prefix_static = "."
 logo_html = '<img src="logo.png">'
 HTML_SUFFIX = ".html"
+MOINDUMP_FILE = "moindump.tpl"
 
 page_template = u'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
 <meta http-equiv="content-type" content="text/html; charset=%(charset)s">
@@ -205,12 +206,33 @@
                     import traceback
                     traceback.print_exc(None, errlog)
             finally:
                 timestamp = time.strftime("%Y-%m-%d %H:%M")
                 filepath = os.path.join(outputdir, file)
+
+                # To allow customization of the template, a check is done in the output
+                # directory for the name 'moindump.tpl' and if this exists it will be taken
+                # it is not really possible to pass it as argument because the parser 
+                # options are independent of the plugin architecture.
+                
+                pt = ''
+                tplfile = os.path.join(outputdir, MOINDUMP_FILE)
+                if os.path.exists(tplfile):
+                    f = None
+                    try:
+                        f = open(tplfile, 'rt')
+                        pt = f.read()
+                    except IOError:
+                        pass
+                    if f:
+                        f.close()
+                    
+                if not pt:
+                    pt = page_template
+                    
                 fileout = codecs.open(filepath, 'w', config.charset)
-                fileout.write(page_template % {
+                fileout.write(pt % {
                     'charset': config.charset,
                     'pagename': pagename,
                     'pagehtml': pagehtml,
                     'logo_html': logo_html,
                     'navibar_html': navibar_html,

Ideally, the template should be looked for in a seperate directory because the outputdir might not exist or is emptied on purpose. It would be great if there is more support for theming and a navigation bar where the user can specify which pages should be displayed in, except the standard (not always generated) pages. I will look into it further, but maybe this helps others too.

MoinMoin: MoinDump (last edited 2013-09-16 15:02:41 by 162-17-208-26-static)