MoinExportDumpEnhancements

This page is a work in progress. The goal is to collect problems, ideas, examples, and patches that will enhance the functionality of the MoinMoin Export Dump utility to make it into a superior Web Publication application.

A MoinMoin user should be able to dump the entire contents (or subpages) of their personal (or public) wiki to an output directory and upload the contents directly to the free web space provided by their ISP (or other) service. The result should be an attractive, error-free web site.

Known Problems

Use a custom template page

-- this was originally contributed by JorgenBodde on the MoinDump 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 separate 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.

Use a custom template file

The patch provides the ability to use a arbitrary template file. The code bases on the patch above. dump_templatefile.diff

Is there a known issue with this patch and 1.8? I always get:

  File "/usr/local/lib/python2.5/site-packages/MoinMoin/script/export/dump.py", line 224
    else:
    ^
IndentationError: unexpected indent

The patch is obviously invalid. Maybe you can get it working be indenting it correctly. Otherwise contact its author, please.

The patch was broken. It's repaired now and tested on MoinMoin 1.7.3 successfully. The old version is stored as dump_templatefile_broken.diff for reference pruposes only. -- CarstenGrohmann 2009-04-17 08:42:22


CategoryFeatureRequest

MoinMoin: FeatureRequests/MoinExportDump (last edited 2009-04-28 19:06:35 by ThomasWaldmann)