Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

ExportHTML

Summary: Export PmWiki pages as "static" HTML pages
Version: 2007-01-12
Prerequisites: any
Status:
Maintainer: Pm

Questions answered by this recipe

  • Can I convert PmWiki pages into static HTML?
  • Can I export my site to a set of static HTML pages?

Description

PmWiki does not come with a built-in export to HTML feature, but other tools can be used to grab a "static" copy of PmWiki pages. Here's at least two options.

1. Export using Wget

Wget recursively from a start page

The following wget(1) command will grab all of the pages from a site, which are linked in some way from the starting page, fixing up links to be relative as needed.

    wget -r -k -np -p -l 0 http://example.org/wiki --html-extension

If running with $EnablePathInfo set, then it's possible to get just a single wikigroup using

    wget -r -k -np -p -l 0 http://example.org/wiki/SomeGroup --html-extension

Here's the meaning of the options to wget:

    -r    Recursive retrieval.  Wget will follow any links it finds in
          the document

    -k    Link adjustment.  After retrieving the pages, wget will convert
          all of the downloaded files to have relative links instead
          of absolute ones.

    -np   No parent.  Wget will restrict itself to the path
          given on the command line (in the above case, it would
          only download the pages of SomeGroup).

    -p    Prerequisites.  Wget will retrieve local copies of any .css
          files or gif images needed to display the static copy of the
          page locally.

    -l 0  Infinite follow.  Wget will follow all of the links it encounters
          (subject to the -np restriction above), so that it will completely
          spider the group.

    --html-extension    Adds the extension html to each file to allow for local viewing.
          Internet Explorer and Firefox on Windows is too stupid to not recognize
          html files by code only.

Since Wget doesn't respect the rel="nofollow" extension, it will follow also the action links. To avoid this:

  • Add $EnableRobotCloakActions = 1; to your config file and
  • add Wget to $RobotPattern or add '-u HTTrack' to the Wget command line to enable PmWiki recognizing Wget as robot.

Wget plus page list

If you want to include pages not reached by a path from the starting page, or you want finer control which pages to be downloaded, you can create a list of pages to be downloaded using a pagelist, e.g. (:pagelist group=*,-PmWiki,-Site*:).

To hide unwanted links, use (:noaction:) (:noleft:) (:noheader:) (:nofooter:).

Wget should be called with -l 1 so only the pages listed are downloaded.

Notes

If you want the retrieved pages to have .html extensions automatically added to them, see the HtmlUrls recipe.

How can I login using AuthUser and wget?

PmWiki doesn't use HTTP Basic authentication (i.e., wget --http-user and --http-passwd), but expects the data to be provided via POST requests. Try
--post-data=authid=USER&authpw=PASSWD

Comments

  • 18-Mar-2007 Olivier Bilodeau - I'm using CleanUrls (the ones that wraps around index.php) and this cookbook didn't work. After a little bit of research, I've found a workaround. You just need to create a local index.php directory where your pmwiki wraps around index.php. No more wget errors.
  • 26-Aug-2008 Timo van de Put - Instead of the HtmlUrls recipe I, used the --html-extension option of wget. This produces output with .html extensions that will load from a filesystem in a browser without webserver.

2. Integrated Export Tool

The following tool allows you to export your PmWiki into static HTML files and push them using FTP, SCP, or plain file copying.

For example exported website, see: http://www.physics.ox.ac.uk/users/santoso

Dependencies:

  • Windows (tested with WinXP) - should work in other OSs with minor tweak (see export.php)
  • wget.exe(approve links)
  • For SCP need pscp.exe (tested with 0.59.0.0)
  • For FTP need nftpput.exe(approve links) (tested with 3.2.0.11)

Installation:

  • Download and unzip pmwiki_export.zipΔ
  • Copy export.php in the same folder as pmwiki.php
  • Copy exportConfig.php in the pmwiki 'local' folder for security purpose
  • Download and copy the necessary binary files (see dependencies) to your webserver local drive
  • Tweak exportConfig.php to suit your need.

See Also

Contributors

User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date
* (-) Optional negative comment. Name, date

These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on November 22, 2009, at 08:36 PM