TWiki home TWiki > TWiki > PublishAddOn ( vs. r1.1) TWiki webs:
Main | TWiki | Plugins | Sandbox | Patterns
TWiki . { Home | Welcome | Register | Changes | Topics | Index | Search | Go }
 <<O>>  Difference Topic PublishAddOn (r1.1 - 08 Jan 2003 - EricScouten?)
Added:
>
>

%META:TOPICINFO{author="EricScouten" date="1042004160" format="1.0" version="1.1"}%

PublishAddOn

History

This Addon started as the TWiki:Plugins/GenHTMLAddon, submitted by TWiki:Main/MartinRaabe at Motorola. This version is a major rewrite from TWiki:Main/EricScouten.

Usage

When TWiki generates a view, it does so dynamically i.e. there's a CGI script that runs, processes some files, and generates HTML that is displayed by the browser. There are circumstances in which this may not be desirable or even possible. For example:

  1. TWiki is used to create documentation which has to be bundled into a product release,
  2. Published versions of TWiki pages must be read-only,
  3. The TWiki server is inaccessible to the audience (e.g. on the other side of a corporate firewall).

PublishAddon? provides support for the generation of stand-alone HTML from a TWiki web. It will generate a directory containing rendered versions of a set of TWiki pages together with any attached files.

WARNING This addon generates HTML output in the 'pub' directories of your twiki installation. For a large web, this can amount to a considerable amount of data!

Features

Tags

  • All standard TWiki tags are interpreted, including Plugins
  • UnresolvedLinks? to non-existant topics are silently ignored
  • Topic links internal to the web are translated to relative links
  • External links (outside this web) are left untouched
  • Any links to the 'pub' areas of topics in the web are automatically resolved and the referenced files copied into the 'images' subdirectory.

  • A specific section of a template or page may be omitted from the rendered HTML by wrapping it in <nopublish> ... </nopublish>. (Hint: Wrap the "control panel" of a template -- the portion that provides edit/attach/etc. in <nopublish>.)

Using the Addon

To generate HTML for a web, view any topic in the web. Edit the URL of the topic and change 'view' to 'publish'. (Hint: Create a WebPublish topic in your web that does this for you.) For example, if you are viewing the WebHome? topic, the URL will be something like

http://node.company.com/twiki/bin/view/Main/WebHome
Modify this URL to read instead
http://node.company.com/twiki/bin/publish/Main/WebHome
(Your TWiki administrator may have already set up a shortcut in the view template; see your local site information for details) Then hit return to invoke the script.

The first thing you see is a web form that allows you to control the HTML generation for the web. From this form you can change the web to generate documentation for, and list perl regular expressions to match topics that you wish to include (default: all) or exclude from generation. When you have set these parameters appropriately, hit the "Publish" button. Note: You can bypass this screen by adding the option goAhead=yes in the query string.

The HTML is generated in a designated directory for the web; the progress messages printed during documentation generation indicate where the generated HTML has been written.

Specialised templates

Unlike the TWiki:Plugins/GenHTMLAddOn, this addon renders using existing skins. It will, by default, use the skin specified in WebPreferences for the published web. This can be overriden by adding the option skin={skin name} in the query string (same as the view script).

Known problems

  • Doesn't handle revision info tags in templates
  • Plugin tags that create complex HTML (sug as TWikiDraw? DRAWING tags) are not handled correctly.
  • Links to excluded topics get generated as links

Addon Installation Instructions

  • Download the ZIP file from the Plugin web (see below). Contents:
    File: Description:
    bin/publish New command
    data/TWiki/PublishAddOn.txt Addon topic
    templates/oopspublished.tmpl Message displayed on successful publishing
    templates/oopspublisherr.tmpl Message displayed when publish fails
    templates/publish.tmpl Confirmation screen before publishing

  • Unzip PublishAddOn.zip in your twiki installation directory.
  • Add the following line to the "TWiki Addons" section of TextFormattingRules:
    • PublishAddOn?: Generate static HTML for a TWiki Web

  • Make the following additions to TWiki.cfg (I put them after $dataDir, line 70 in the 01 Dec 2001 distribution):

# Root directory for static-published HTML [scouten 12/08/02]
$publishDir       = "/home/httpd/path/to/published/files/";
# Root URL for static-published HTML (should point to $publishDir) [scouten 12/08/02]
$publishUrlPath     = "/url/path/to/published/files/";

  • Make the following changes to TWiki.pm:
    • under "use vars qw" (line 47 in 01 Dec 2001 distribution): add $publishDir $publishUrlPath
    • add the following subroutines anywhere in the file (I put them after sub getPubUrlPath, at line 496 in the 01 Dec 2001 distribution):

# =========================
sub getPublishDir
{
    return $publishDir;
}

# =========================
sub getPublishUrlPath
{
    return $publishUrlPath;
}

Addon info

One Line Description: Generate static HTML for a TWiki Web
Addon Author: EricScouten?
Addon Version: 1.1
Change History: 7 Jan 2003: Initial version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.0
Addon Home: http://TWiki.org/cgi-bin/view/Plugins/PublishAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/PublishAddOnDev

Related Topics: TWikiPreferences, TWikiPlugins

Copyright

This code is a development of the Architectures and System Platforms group of Motorola Inc. and is protected by the following copyrights:
  • Copyright (C) 2001 Motorola. All Rights Reserved.

Further modifications were made by Eric Scouten and are copyright (C) 2002-2003, Eric Scouten.

License

As required for the publication of all extensions to TWiki, the software is published under the terms of the GNU General Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, published at http://www.gnu.org/copyleft/gpl.html

See also

Further discussions are to be found at: PublishPluginDev?

Topic PublishAddOn . { View | Diffs | r1.1 | More }
Revision -
Revision r1.1 - 08 Jan 2003 - 05:36 GMT - EricScouten?
Copyright © 2003 by the contributing authors. All material on this collaboration tool is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback