source: trunk/PublishPlugin/data/System/PublishPlugin.txt @ 1010

Revision 1010, 23.5 KB checked in by CrawfordCurrie, 4 years ago (diff)

Item8019: moving PublishContrib to a Plugin

Line 
1---+!! <nop>%TOPIC%
2*Generates a static view of a web, as HTML files on disc, or as a =PDF=, or as a =zip= or =tgz= archive file, or by uploading directly to an FTP server.*
3
4<!--
5
6   PLEASE DO NOT EDIT THIS TOPIC
7
8   It is automatically generated from the subversion repository, and any changes
9   you make will simply be overwritten the next time a release is generated.
10
11   Instead, you could check your fix in, raise a bug in the Bugs web, or mail thge author.
12
13   * Set SHORTDESCRIPTION = Generate static output (HTML, PDF) for a web and optionally upload (FTP) the output to a publishing site.
14-->
15
16_Previously known as !GenHTMLAddOn, and then !PublishAddOn, and the !PublishContrib, this is the *original* publishing extension for TWiki, and now for Foswiki_.
17
18<img src="%ATTACHURLPATH%/publish.gif" style="float:right" />
19!PublishPlugin provides support for the generation of stand-alone HTML from a web. It will generate fully rendered versions of a set of Foswiki pages together with any attached files.
20
21%TOC%
22
23When Foswiki 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:
24        1 Foswiki is used to create documentation which has to be bundled into a product release
25        1 Published versions of Foswiki pages must be read-only
26        1 The Foswiki server is inaccessible to the audience (e.g. on the other side of a corporate firewall)
27       
28
29---++ Features
30        * All standard Foswiki macros are interpreted
31        * Plugins are called
32        * Unresolved links to non-existent topics are silently ignored
33        * Topic links internal to the Foswiki are translated to relative links
34        * Powerful support for choosing what content gets published
35        * Any links to the 'pub' areas of topics in the web are automatically resolved and the referenced files copied
36        * Any links to images outside the Foswiki are resolved, and the image is stored in the output (requires LWP)
37        * Output in HTML or PDF. HTML can be compressed in different archive formats.
38        * Full support for hierarchical webs
39        * Multiple instances (e.g. dev, test, prod) can be specified
40        * Special output format specific templates (such as viewpdf) can be used
41        * Able to publish HTML and referenced files directly to a remote server via ftp
42    * Complete history of what was published, and when!
43
44---++ Usage
45---+++ Publish Form
46The easiest way to publish a web is from this topic, by filling in the following form.
47
48The output is generated in a directory designated during installation. The progress messages printed during documentation generation tell you exactly where the output is. Admins can use the %<nop>PUBLISHERS_CONTROL_CENTRE% macro to manage your published output.
49
50Publishing is a controlled process; before you can publish, you have to have VIEW access to the topics you want to publish, and CHANGE access to the publishing history topic.
51
52You can also create a [[#PublishTopic][permanent topic in a web]] to help with the publishing process.
53
54<style type="text/css" media="all">
55.twikiPageForm table th,
56.twikiPageForm table td {
57vertical-align:top;
58border-bottom:1px solid #ddd;
59padding:.5em;
60}
61</style>
62
63<div class="twikiPageForm">
64<form method="POST" name="publish" action="%SCRIPTURL{publish}%/%URLPARAM{"web" default=""}%">
65<table class="twikiTable" cellpadding="0" cellspacing="0">
66<tr>
67  <th colspan="3" style="background-color:gold">Choose what to publish</th>
68</tr>
69<tr>
70  <td> Web to publish </td>
71  <td>
72   <select name="web" class="twikiSelect">%WEBLIST{"<option $marker value='$name'>$name</option>" selection="%URLPARAM{"web" default="%WEB%"}%"}%</select>
73  </td>
74  <td>
75   =web=
76  </td>
77</tr>
78<tr>
79  <td>
80    Comma-separated list of [[#WildcardPattern][wildcard patterns]] that match
81    the names of topics to *include*.
82  </td>
83  <td>
84    <input type="text" name="inclusions" class="twikiInputField" value="%URLPARAM{"inclusions" default="*"}%" size="50"/><br />Use * for all topics.
85  </td>
86  <td>
87   =inclusions=
88  </td>
89</tr>
90<tr>
91  <td>
92    Comma-separated list of [[#WildcardPattern][wildcard patterns]] that match
93    the names of topics to *exclude*.
94  </td>
95  <td>
96    <input type="text" name="exclusions" class="twikiInputField" value="%URLPARAM{"exclusions" default=""}%" size="50"/><br />Leave blank to include all topics.
97  </td>
98  <td>
99   =exclusions=
100  </td>
101</tr>
102<tr>
103  <td>
104    Name of a topic that contains a table, each row of which maps a topic names to the version of that topic to publish.
105  </td>
106  <td>
107    <input type="text" name="versions" class="twikiInputField" value="%URLPARAM{"versions" default=""}%" size="50"/><br />Leave blank to publish the most recent version of each topic. The table can be generated by a %SEARCH or other macro. For example: =| Web.<nop>TopicName | 1.33 |=. If a topic does not appear in the table, the most recent version will be published.
108  </td>
109  <td>
110   =versions=
111  </td>
112</tr>
113<tr>
114  <td>
115    A [[#RegularExpression][regular expression]] that will cause a topic to be
116    *excluded* if the RE matches the topic content.
117  </td>
118  <td>
119    <input type="text" name="filter" class="twikiInputField" value="%URLPARAM{"filter" default=""}%" size="50" /><br />Leave blank to include all topics.
120  </td>
121  <td>
122   =filter=
123  </td>
124</tr>
125<tr>
126  <td>
127    Comma-separated list of Plugins to enable during publish.
128  </td>
129  <td>
130    <input type="text" name="enableplugins" class="twikiInputField" value="%URLPARAM{"enableplugins" default=""}%" size="50"/><br /> Leave blank to enable all plugins. You are recommended to disable any plugins that generate buttons in the output.<br />
131    The currently enabled plugins are: %ACTIVATEDPLUGINS%
132  </td>
133  <td>
134   =enableplugins=
135  </td>
136</tr>
137<tr>
138  <th colspan="3" style="background-color:gold">Output options</th>
139</tr>
140<tr>
141  <td>Select skin for published HTML</td>
142  <td>
143    <input type="text" name="skin" class="twikiInputField" size="20" value="basic_publish" /><br />
144    The skin provides the template for how topics are published. See [[%SYSTEMWEB.Skins][Skins]] for more informations on skins.<br />
145    You are recommended to pick =basic_publish=, or =plain=, or a =print= skin.
146    Your installation may also offer a special =export= or =publish= skin.<br />%I% The =view= [[SkinTemplates][template]] is used to generate published pages, so =view.%URLPARAM{"skin" default="basic_publish"}%.tmpl= is the template that will be used to generate the output. You can preview any topic in this skin simply by appending =?skin=%URLPARAM{"skin" default="basic_publish"}%= to the end of the view URL. Note that the standard =VIEW_TEMPLATE= template override still works when publishing.
147
148  </td>
149  <td>
150   =skin=
151  </td>
152</tr>
153<tr>
154  <td>Output format</td>
155  <td>
156   <select name="format" class="twikiSelect" onchange="toggle('ftp','ftpoptions')">
157    <option value="">file</option>
158    <option value="zip">zip</option>
159    <option value="tgz">tgz</option>
160    <option value="pdf">pdf</option>
161    <option value="ftp">ftp</option>
162   </select><br />
163    The output will be generated on the server, in the directory pointed to
164    by the ={PublishPlugin}{Dir}= configuration setting. You can manage the
165    contents of this directory from the browser using the %>nop>PUBLISHERS_CONTROL_CENTRE% macro.<br />
166    *X* The rendered data can get pretty big, and the process itself puts
167   a heavy load on the server, especially when using compression on large webs.
168  </td>
169  <td>
170   =format=
171  </td>
172</tr>
173<tr>
174  <td>Publishing history topic</td>
175  <td>
176    <input type="text" name="history" class="twikiInputField" size="50" value="PublishPluginHistory" /><br />
177    This is where the history of your publishing is stored. Each time you publish, this topic is re-written with the log of the publishing process. You have to have "change" access to this topic. You can specify a topic in another web using the standard Web.Topic syntax.
178  </td>
179  <td>
180   =history=
181  </td>
182</tr>
183<tr>
184  <th colspan="3" style="background-color:gold">Web options</th>
185</tr>
186<tr>
187 <td style="background-color:gold"> Web options are only relevant for web output formats (<tt>file</tt> and <tt>ftp</tt>)
188 The web formats generate a sitemap.xml, and can also generate
189 default.htm, index.html and google site verification files.
190 </td>
191 <td colspan=2>
192  <table class="twikiTable" width="100%">
193   <tr>
194    <td>
195     Google file
196    </td>
197    <td>
198     <input type="text" size="40" name="googlefile" value="" /><br />
199     generates the =HTML verification file= needed to verify your site claim.
200     see <a href="http://www.google.com/webmasters/sitemaps/">Google webmaster tools</a>
201    </td>
202    <td>
203     =googlefile=
204    </td>
205   </tr>
206   <tr>
207    <td>
208     Default topic:
209    </td>
210    <td>
211     <input type="text" size="40" name="defaultpage" value="WebHome" /><br />
212     Name of topic to used to generate default.htm, index.html
213    </td>
214    <td>
215     =defaultpage=
216    </td>
217   </tr>
218   <tr>
219    <td>
220     Relative URL used in sitemap
221    </td>
222    <td>
223     <input type="text" size="40" name="relativeurl" value="/" /><br />
224     the base URL that your published Foswiki topics will reside at (if you are publishing to the root of your site, =/= is correct)
225     see <a href="http://www.google.com/webmasters/sitemaps/">Google webmaster tools</a>
226    </td>
227    <td>
228     =relativeurl=
229    </td>
230   </tr>
231   </table>
232  </td>
233</tr>
234<tr>
235  <th colspan="3" style="background-color:gold">FTP options</th>
236</tr>
237<tr>
238 <td style="background-color:gold"> FTP options are only relevant if Output format is =ftp=
239
240The FTP output generator was written by Foswiki:Main.SvenDowideit.
241</td>
242 <td colspan=2>
243  <table class="twikiTable">
244   <tr>
245    <td>
246     Destination FTP server
247    </td>
248    <td>
249     <input type="text" size="40" name="destinationftpserver" value="" /><br />
250     Set to blank to proof the output prior to uploading to your site.
251
252    </td>
253    <td>
254     =destinationftpserver=
255    </td>
256   </tr>
257   <tr>
258    <td>
259     Path to upload to on server
260    </td>
261    <td>
262     <input type="text" size="40" name="destinationftppath" value="" />
263    </td>
264    <td>
265     =destinationftppath=
266    </td>
267   </tr>
268   <tr>
269    <td>
270     FTP username
271    </td>
272    <td>
273     <input type="text" size="40" name="destinationftpusername" value="" />
274    </td>
275    <td>
276     =destinationftpusername=
277    </td>
278   </tr>
279   <tr>
280    <td>
281     FTP Password
282    </td>
283    <td>
284     <input type="password" size="40" name="destinationftppassword" value="" />
285    </td>
286    <td>
287     =destinationftppassword=
288    </td>
289   </tr>
290   <tr>
291     <td valign="top">Fast publish</td>
292     <td> <input type="checkbox" name="fastupload" value="1" /> <br />
293     Speed up the ftp publishing by only uploading modified files. This will
294     store a (tiny) checksum (.md5) file on the server alongside each uploaded
295     file which will be used to optimise future uploads. Recommended.
296     </td>
297     <td>
298      =fastupload=
299     </td>
300    </tr>   
301  </table>
302 </td>
303</tr>
304<tr>
305  <th colspan="3" style="background-color:gold">Other output generator options</th>
306</tr>
307<tr>
308  <td>Some output generators support extra options (e.g. for =pdf=, you can add =htmldoc= command-line parameters here, such as =--linkstyle underline=)</td>
309  <td>
310   <textarea rows="5" cols="80"  class="twikiInputField">%URLPARAM{"genopt" default=""}%</textarea>
311  </td>
312  <td>
313   =genopt=
314  </td>
315</td>
316</tr>
317<tr>
318<td colspan="3" class="twikiLast">
319<input type="submit" class="twikiSubmit" value="Publish" />
320</td>
321</tr>
322</table>
323</form>
324</div>
325#WildcardPattern
326---+++ Wildcard Patterns
327Wildcard patterns are well known to people who are used to command lines on computers, but may be unfamiliar to the Windows generation. A wildcard is a special string that you can put into a filename so that it matches a whole range of files:
328| *String* | *What  it does* | *Example* | *What the example matches* |
329| * | Matches any string, including an empty string. | =*Cheese*= | Every topic with "Cheese" somewhere in the name (but _not_ "cheese") |
330| ? | Matches any single character. | Example1? | Example10 and Example 1X but _not_ example1 |
331| [...] | Matches any one of the enclosed characters.  A pair of characters separated by a hyphen denotes a range  expression; any  character that sorts between those two characters, inclusive, using the current locale's collating sequence and character set, is matched.  If the first character following the [ is a ^ then any character not enclosed is matched. A - may be matched by including it as the first or  last  character  in  the set.  A ] may be matched by including it as the first character in the set.<br /> Within  [  and ], character classes can be specified using the syntax [:class:], where class is one of the following classes defined in the POSIX.2 standard: =alnum=, =alpha=, =ascii=, =blank=, =cntrl=, =digit=, =graph=, =lower=, =print=, =punct=, =space=, =upper=, =word=, =xdigit=. A character class matches any character belonging to that class.  The =word= character class matches letters, digits, and the character _. | B[aeiou]g | Bag, Bog, Big, Beg, Bug |
332
333#RegularExpression
334---+++ Regular Expressions
335A perl regular expression. You can use a simple string here, which will be matched exactly, or you can read up on perl regular expressions on the web.
336
337#PublishTopic
338---+++ Using a Publish Topic (configtopic)
339You can create a publish topic in a web that contains all the details needed to publish that web. This is just a topic with a series of standard preference settings (which correspond to the form parameters) in it. You can use the PublishWeb topic in this web as a template for your own topics.
340
341Alternatively you can just take a copy of the form in this topic, paste it into your own topic, and change the defaults.
342
343To use a publish topic, you must pass the =configtopic= parameter to the =publish= script set to the name of the topic to use to control publishing. You can specify a topic in another web using the standard Web.Topic syntax.
344
345---+++ Publishing from the command line
346Just =cd= to the =bin= directory, and
347=perl -T rest topic=PublishPlugin/publish=. Parameters are passed as name=value pairs, for example:
348<verbatim>
349perl -T rest topic=PublishPlugin/publish web=Book exclusions='Web*' format=file
350perl -T rest topic=PublishPlugin/publish web=Book inclusions=WebBook format=pdf genopt='--book --duplex --toclevels=5'
351</verbatim>
352The available parameter names are shown in the example above, in the 'Name' column.
353
354---+++ Controlling which parts of a topic get published
355You can control what gets published from a topic using =%<nop>STARTPUBLISH%= and =%<nop>STOPPUBLISH%= control tags:
356   * If =%<nop>STARTPUBLISH%= is the first control tag seen in the file, everything before it will be ignored.
357   * Everything between =%<nop>STOPPUBLISH%= and the next =%<nop>STARTPUBLISH%= (or the end of the topic) will be ignored.
358   * =%<nop>STARTPUBLISH%= and =%<nop>STOPPUBLISH%= will be visible in the viewed topic, so you can easily see what will be published from the topic.
359Note: the old &lt;nopublish> tag is deprecated and should be replaced in topics
360
361Another good trick is to set up a special "publishing" web. Create topics in the web that %INCLUDE the topics from *other* webs that you want to publish. You can use [[%SYSTEMWEB%.VarSTARTSECTION][STARTSECTION]] and [[%SYSTEMWEB%.VarENDSECTION][ENDSECTION]] to highlight what you want published. This way the "publishing" web gives you a view of exactly what will be in the published output, without the need for special publishing tags.
362
363---++ Publishing History
364Every time a web is published, then the results of that publishing step are stored in a topic in the web. By default this topic is called =PublishPluginHistory=, but you can choose another name (see the form, above). In order to publish a web, you have to be able to write to this topic. If you need to add access controls to the topic, then make sure you do that right at the beginning of the topic, or in the hidden preferences.
365
366The history topics contains a list of all the parameters used, and the versions of the topics that were published, so it is very useful for tracking exactly what you publish. it is written every time you run =publish=.
367
368---++ Installation Instructions
369---+++ Dependencies
370
371Note: If you want to generate PDF files, you will need an installation of =htmldoc=. This program is available from http://www.easysw.com/htmldoc/ for free, but you are *strongly* recommended to buy the commercial version. Your support for open-source projects helps make open-source software possible.
372
373%$INSTALL_INSTRUCTIONS%
374
375Run =configure= and complete the installation in the *PublishPlugin* section. If you can't do this for some reason, these are the settings required in !LocalSite.cfg:
376| =$Foswiki::cfg{PublishPlugin}{Dir}= | File path to the directory where published files will be generated. you will normally want this to be visible via a URL, so the Foswiki pub directory is a good choice. |
377| =$Foswiki::cfg{PublishPlugin}{URL}= | URL path of the directory you defined above. |
378| =$Foswiki::cfg{PublishPlugin}{PDFCmd}= | Template command-line for the PDF generator program - for example, =htmldoc --webpage --links --linkstyle plain --outfile %FILE|F% %EXTRAS|U% %FILES|F%'= |
379
380---++++ =PDF= output
381   1 install htmldoc from http://www.easysw.com/htmldoc/
382
383Note that =htmldoc= can also be used to generate !PostScript by using the =-t= option in the =Other output generator options= above. See the =htmldoc= man pages for details.
384
385---++++ =.tgz= (tar) output
386   1 Install Archive::Tar and everything it depends on
387
388---++++ =.zip= output
389   1 Install Archive::Zip and everything it depends on
390
391---++ Info
392This add-on started as the TWiki:Extensions/GenHTMLAddon, written by Foswiki:Main/CrawfordCurrie at Motorola. It was then partially rewritten by TWiki:Main/EricScouten, and then fixed and enhanced by Foswiki:Main/CrawfordCurrie (http://c-dot.co.uk). It has been further extended by Foswiki:Main/SvenDowideit and Foswiki:Main/MartinCleaver, and most recently refactored for Foswiki by Foswiki:Main/CrawfordCurrie
393
394|  Authors: | Foswiki:Main/CrawfordCurrie, TWiki:Main/EricScouten, Foswiki:Main.SvenDowideit, Foswiki:Main.MartinCleaver|
395|  Dependencies: | %$DEPENDENCIES% |
396|  Version: | %$VERSION% |
397|  Change History: | |
398|  27 Nov 2008 | Foswikibug:8019: refactoreed as a plugin and tested in Foswiki |
399|  27 Oct 2008 | TWikibug:Item5385: Fixed doc for configtopic TWikibug:Item5388: $WEB and $TOPIC were not correct in %IF statements TWikibug:Item5390: remove comments from .css before processing for included resoures TWikibug:Item5706: Improved FTP upload process for incrementally maintained webs TWikibug:Item6029: expand config topic on load to support use of searches TWikibug:Item6030: respect VIEW_TEMPLATE in published topics TWikibug:Item6092: expand common tags in configtopic TWikibug:Item6094: move sitemap options into base file generator TWikibug:Item6110: rename settings in config topic to avoid clashes with other plugins |
400|  11 Dec 2007 | TWikibug:Item5099 fixed |
401|  10 Nov 2007 | Tested on 4.2.0. TWikibug:Item4624:, TWikibug:Item4625: TWikibug:Item4830: fixed. TWikibug:Item4825: added a basic skin to avoid the confusion caused by =text= skin. TWikibug:Item4951: added interface to allow management of output files |
402|  13222 | fixed ftp publish, added doco, and added enabled plugin selection funcitonality |
403|  13064 | TWikibug:Item3722 worked around core attaching URL params to internal URLs |
404|  12961 | TWikibug:Item3671 cannot publish without write access to history topic, so \
405  security now checked early. TWikibug:Item3619 Cleaned up error handling from \
406  writers. TWikibug:Item3675 added history topic to record changeset. Plus major \
407  refactoring of main class to get rid of some of the cruft that had built \
408  up from many authors. Item2726: uses getExternalResource now, so should \
409  obey proxy settings (untested) |
410|  12824 | Added support for new internal api - no user changes |
411|  12708 | Added UI for FTP. Added .spec file. Fixed TWikibug:Item3515 and TWikibug:Item2725 |
412|  12028 | Michael Daum - create a new TWiki object for every topic, don't reuse the current one (TWikibug:Item3139) |
413|  10412 | Correction to the correction for anchors. |
414|  10345 | Correction to support anchors in URLs properly |
415|  10242 | Martin Cleaver - changes to allow generation of viewprint and viewxxx when specified by TEMPLATE; multiple INSTANCE (dev/test/prod); (TWikibug:Item2269) |
416|  10063 | Bugfix TWikibug:Item2216 |
417|  10006 | Crawford Currie - fixed problem where it was failing to remove &lt;base> tags completely (TWikibug:Item2200) |
418|  9986 | Crawford Currie - added doc on usage from command line, corrected sense of topicsearch filter (TWikibug:Item2120, TWikibug:Item2121), renamed parameters (old ones are still valid), corrected handling of empty web refs (TWikibug:Item2128), deprecated nopublish html-style tag in favour of !PublishWebPlugin-compatible style (though with richer semantics) (TWikibug:Item2196) |
419|  9823 | Crawford Currie - added support for hierarchical webs, and inclusion of external images. |
420|  9773 | Crawford Currie - added tgz and pdf support |
421|  9725 | Michael Daum - fixed rewriting urls; \
422                 fixed nested resources issue; \
423                 creating a new prefs object for each topic |
424|  9713 | Corrected form action so it uses up the right web preferences |
425|  9695 | Michael Daum - recursively archive resources imported by css files;\
426      fixed several html errors in the !PublishPlugin and !PublishWeb topics;\
427      removed hardcoded reference to print.pattern |
428|  8959 | TWiki-4 version. Also supports publishing to a file area, making TWiki easier to use as a CMS (see also Foswiki:Extensions/PublishWebPlugin, which does almost the same thing :-( ) |
429|  6276 | TWikibug:Item196 - bugfix for HTTP_HOST, as described in the Dev topic for the contrib |
430|  5566 | Changed interface to support wildcards, and lightened the plugin by replacing a lot of files with simpler ways of doing things. |
431|  5499 | Added Compress::Zlib dependency, as requested by Brad Taylor |
432|  27 Apr 2005 | 1.301 Crawford Currie - fixed minor issues highlighted by Bruce Dillahunty and Scott Claridge |
433|  11 Apr 2005 | 1.3 Crawford Currie - reworked the interface and code to work better |
434|  13 October 2004 | 1.200 Crawford Currie - Cairo compatible |
435|  7 Jan 2003 | 1.1 Initial version |
436|  Home: | http://foswiki.org/Extensions/%TOPIC% |
437|  Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev |
438|  Appraisal: | http://foswiki.org/Extensions/%TOPIC%Appraisal |
439
440__Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences, [[%SYSTEMWEB%.Plugins][Plugins]]
441
442---+++ Copyright
443This code is a development of the Architectures and System Platforms group of Motorola Inc. and is protected by the following copyrights:
444        * Copyright &copy; 2001 Motorola. All Rights Reserved.
445        * Copyright &copy; 2002-2003, Eric Scouten.
446        * Copyright &copy; 2004-2006 Crawford Currie http://c-dot.co.uk
447        * Copyright &copy; 2006 Martin Cleaver http://www.cleaver.org
448
449The 2005 functionality improvements were sponsored by [[http://www.windriver.com][Wind River Systems]]
450
451The =pdf= and =tgz= output formats were made possible by [[http://www.sabiolabs.com][ =Sabio Labs= ]]
452
453---+++ License
454As required for the publication of all extensions to TWiki, the software is published under the terms of the GNU General Public License.
455
456This program is distributed in the hope that it will be useful,
457but WITHOUT ANY WARRANTY; without even the implied warranty of
458MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
459GNU General Public License for more details, published at
460http://www.gnu.org/copyleft/gpl.html
461
462%META:FILEATTACHMENT{name="publish.gif" attr="h" comment="Logo"}%
463%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%
Note: See TracBrowser for help on using the repository browser.