Skip to content

Commit 6d856d7

Browse files
CrawfordCurrieCrawfordCurrie
authored andcommitted
Item8168: fixed genopt (extras) parameter
git-svn-id: http://svn.foswiki.org/trunk/PublishPlugin@3991 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
1 parent e0fb0a8 commit 6d856d7

File tree

7 files changed

+93
-76
lines changed

7 files changed

+93
-76
lines changed

data/System/PublishPlugin.txt

Lines changed: 83 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ _Originally written for TWiki, previously known as !GenHTMLAddOn, !PublishAddOn,
1919
!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.
2020

2121
%TOC%
22-
22+
<script type="text/javascript">
23+
function showPublishOptions() {
24+
var select = document.getElementsByClassName('selectedFormat');
25+
var chosen = select[0].value + 'Options';
26+
var options = document.getElementsByClassName('publishOptionsSet');
27+
for (var i = 0; i < options.length; i++) {
28+
if (options[i].className.indexOf(chosen) >= 0)
29+
options[i].style.display = 'block';
30+
else
31+
options[i].style.display = 'none';
32+
}
33+
}
34+
</script>
2335
When you want to read a document stored in Foswiki, you have to have access to the web server that hosts that document. There are times when this may not be desirable, or even possible. For example:
2436
1 Foswiki is used to create documentation which has to be readable off-line
2537
1 Published versions of Foswiki pages must be read-only
@@ -59,18 +71,20 @@ vertical-align:top;
5971
border-bottom:1px solid #ddd;
6072
padding:.5em;
6173
}
74+
.headingBar { background-color:gold }
75+
.publishOptionsSet { padding: 0; margin: 0 }
6276
</style>
6377

6478
<div class="foswikiPageForm">
6579
<form method="POST" name="publish" action="%SCRIPTURL{rest}%/PublishPlugin/publish">
6680
<table class="foswikiTable" cellpadding="0" cellspacing="0">
6781
<tr>
68-
<th colspan="3" style="background-color:gold">Choose what to publish</th>
82+
<th colspan="3" class="headingBar">Choose what to publish</th>
6983
</tr>
7084
<tr>
71-
<td> Web to publish </td>
85+
<td width="200px"> Web to publish </td>
7286
<td>
73-
<select name="web" class="foswikiSelect">%WEBLIST{"<option $marker value='$name'>$name</option>" selection="%URLPARAM{"web" default="%WEB%"}%"}%</select>
87+
<select name="web" class="foswikiSelect">%WEBLIST{"<option $marker value='$name'>$name</option>" selection="%URLPARAM{"web" default="%WEB%" encode="entity"}%"}%</select>
7488
</td>
7589
<td>
7690
=web=
@@ -82,7 +96,7 @@ padding:.5em;
8296
the names of topics to *include*.
8397
</td>
8498
<td>
85-
<input type="text" name="inclusions" class="foswikiInputField" value="%URLPARAM{"inclusions" default="*"}%" size="50"/><br />Use * for all topics.
99+
<input type="text" name="inclusions" class="foswikiInputField" value="%URLPARAM{"inclusions" default="*" encode="entity"}%" size="50"/><br />Use * for all topics.
86100
</td>
87101
<td>
88102
=inclusions=
@@ -94,7 +108,7 @@ padding:.5em;
94108
the names of topics to *exclude*.
95109
</td>
96110
<td>
97-
<input type="text" name="exclusions" class="foswikiInputField" value="%URLPARAM{"exclusions" default=""}%" size="50"/><br />Leave blank to include all topics.
111+
<input type="text" name="exclusions" class="foswikiInputField" value="%URLPARAM{"exclusions" default="" encode="entity"}%" size="50"/><br />Leave blank to include all topics.
98112
</td>
99113
<td>
100114
=exclusions=
@@ -105,7 +119,7 @@ padding:.5em;
105119
Name of a topic that contains a table, each row of which maps a topic names to the version of that topic to publish.
106120
</td>
107121
<td>
108-
<input type="text" name="versions" class="foswikiInputField" 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.
122+
<input type="text" name="versions" class="foswikiInputField" value="%URLPARAM{"versions" default="" encode="entity"}%" 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.
109123
</td>
110124
<td>
111125
=versions=
@@ -117,7 +131,7 @@ padding:.5em;
117131
*excluded* if the RE matches the topic content.
118132
</td>
119133
<td>
120-
<input type="text" name="filter" class="foswikiInputField" value="%URLPARAM{"filter" default=""}%" size="50" /><br />Leave blank to include all topics.
134+
<input type="text" name="filter" class="foswikiInputField" value="%URLPARAM{"filter" default="" encode="entity"}%" size="50" /><br />Leave blank to include all topics.
121135
</td>
122136
<td>
123137
=filter=
@@ -128,15 +142,15 @@ padding:.5em;
128142
Comma-separated list of Plugins to enable during publish.
129143
</td>
130144
<td>
131-
<input type="text" name="enableplugins" class="foswikiInputField" 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 />
145+
<input type="text" name="enableplugins" class="foswikiInputField" value="%URLPARAM{"enableplugins" default="" encode="entity"}%" size="50"/><br /> Leave blank to enable all plugins. You are recommended to disable any plugins that generate buttons in the output.<br />
132146
The currently enabled plugins are: %ACTIVATEDPLUGINS%
133147
</td>
134148
<td>
135149
=enableplugins=
136150
</td>
137151
</tr>
138152
<tr>
139-
<th colspan="3" style="background-color:gold">Output options</th>
153+
<th colspan="3" class="headingBar">Output options</th>
140154
</tr>
141155
<tr>
142156
<td>Select skin for published HTML</td>
@@ -145,7 +159,6 @@ padding:.5em;
145159
The skin provides the template for how topics are published. See [[%SYSTEMWEB%.Skins][Skins]] for more informations on skins.<br />
146160
You are recommended to pick =basic_publish=, or =plain=, or a =print= skin.
147161
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.
148-
149162
</td>
150163
<td>
151164
=skin=
@@ -154,17 +167,19 @@ padding:.5em;
154167
<tr>
155168
<td>Output format</td>
156169
<td>
157-
<select name="format" class="foswikiSelect" onchange="toggle('ftp','ftpoptions')">
170+
<select name="format" class="foswikiSelect selectedFormat" onchange="showPublishOptions()">
158171
<option selected="selected">file</option>
159172
<option>zip</option>
160173
<option>tgz</option>
161174
<option>pdf</option>
162175
<option>ftp</option>
163176
</select><br />
164-
The output will be generated on the server, in the directory pointed to
165-
by the ={PublishPlugin}{Dir}= configuration setting. You can manage the
166-
contents of this directory from the browser using the %<nop>PUBLISHERS_CONTROL_CENTRE% macro (See PublishPluginControlCentre).<br />
167-
*X* The rendered data can get pretty big, and the process itself puts
177+
The output will be generated on the server, in the directory pointed to
178+
by the ={PublishPlugin}{Dir}= configuration setting. Administrators can
179+
manage the contents of this directory from the browser using the
180+
%<nop>PUBLISHERS_CONTROL_CENTRE% macro
181+
(See PublishPluginControlCentre).<br />
182+
%X% The rendered data can get pretty big, and the process itself puts
168183
a heavy load on the server, especially when using compression on large webs.
169184
</td>
170185
<td>
@@ -182,16 +197,17 @@ padding:.5em;
182197
</td>
183198
</tr>
184199
<tr>
185-
<th colspan="3" style="background-color:gold">Web options</th>
186-
</tr>
187-
<tr>
188-
<td style="background-color:gold"> Web options are only relevant for web output formats (<tt>file</tt> and <tt>ftp</tt>)
189-
The web formats generate a sitemap.xml, and can also generate
190-
default.htm, index.html and google site verification files.
191-
</td>
192-
<td colspan=2>
193-
<table class="foswikiTable" width="100%">
200+
<td colspan="3" style="padding:0">
201+
<table class="publishOptionsSet fileOptions ftpOptions foswikiTable" width="100%">
202+
<tr>
203+
<th colspan="4" class="headingBar">Web options</th>
204+
</tr>
194205
<tr>
206+
<td width="200px" rowspan="4"> Web options are only relevant for
207+
web output formats (<tt>file</tt> and <tt>ftp</tt>)
208+
The web formats generate a sitemap.xml, and can also generate
209+
default.htm, index.html and google site verification files.
210+
</td>
195211
<td>
196212
Google file
197213
</td>
@@ -222,7 +238,9 @@ padding:.5em;
222238
</td>
223239
<td>
224240
<input type="text" size="40" name="relativedir" value="/" /><br />
225-
Path of a directory relative to ={PublishPlugin}{Dir}= where you want the output generated. '/' means generate the output directly in ={PublishPlugin}{Dir}=.
241+
Path of a directory relative to ={PublishPlugin}{Dir}= where you want
242+
the output generated. '/' means generate the output directly in
243+
={PublishPlugin}{Dir}=.
226244
</td>
227245
<td>
228246
=relativedir=
@@ -234,34 +252,32 @@ padding:.5em;
234252
</td>
235253
<td>
236254
<input type="text" size="40" name="relativeurl" value="/" /><br />
237-
the base URL that your published Foswiki topics will reside at (if you are publishing to the root of your site, =/= is correct)
238-
see <a href="http://www.google.com/webmasters/sitemaps/">Google webmaster tools</a>
255+
the base URL that your published Foswiki topics will reside at (if you
256+
are publishing to the root of your site, =/= is correct)
257+
see <a href="http://www.google.com/webmasters/sitemaps/">Google
258+
webmaster tools</a>
239259
</td>
240260
<td>
241261
=relativeurl=
242262
</td>
243263
</tr>
244-
</table>
245-
</td>
246-
</tr>
247-
<tr>
248-
<th colspan="3" style="background-color:gold">FTP options</th>
249-
</tr>
250-
<tr>
251-
<td style="background-color:gold"> FTP options are only relevant if Output format is =ftp=
252-
253-
The FTP output generator was written by Foswiki:Main.SvenDowideit.
254-
</td>
255-
<td colspan=2>
256-
<table class="foswikiTable">
264+
</table>
265+
<table class="publishOptionsSet ftpOptions foswikiTable" style="display:none" width="100%">
257266
<tr>
267+
<th colspan="4" class="headingBar">FTP options</th>
268+
</tr>
269+
<tr>
270+
<td width="200px" rowspan="5">
271+
FTP options are only relevant if Output format is =ftp=
272+
<p />
273+
The FTP output generator was written by Foswiki:Main.SvenDowideit.
274+
</td>
258275
<td>
259276
Destination FTP server
260277
</td>
261278
<td>
262279
<input type="text" size="40" name="destinationftpserver" value="" /><br />
263280
Set to blank to proof the output prior to uploading to your site.
264-
265281
</td>
266282
<td>
267283
=destinationftpserver=
@@ -301,36 +317,41 @@ The FTP output generator was written by Foswiki:Main.SvenDowideit.
301317
</td>
302318
</tr>
303319
<tr>
304-
<td valign="top">Fast publish</td>
305-
<td> <input type="checkbox" name="fastupload" checked="checked" /> <br />
306-
Speed up the ftp publishing by only uploading modified files. This will
307-
store a (tiny) checksum (.md5) file on the server alongside each uploaded
308-
file which will be used to optimise future uploads. Recommended.
309-
</td>
310-
<td>
311-
=fastupload=
312-
</td>
313-
</tr>
320+
<td valign="top">Fast publish</td>
321+
<td> <input type="checkbox" name="fastupload" checked="checked" /> <br />
322+
Speed up the ftp publishing by only uploading modified files. This will
323+
store a (tiny) checksum (.md5) file on the server alongside each uploaded
324+
file which will be used to optimise future uploads. Recommended.
325+
</td>
326+
<td>
327+
=fastupload=
328+
</td>
329+
</tr>
314330
</table>
315331
</td>
316332
</tr>
317333
<tr>
318-
<th colspan="3" style="background-color:gold">Other output generator options</th>
334+
<th colspan="3" class="headingBar">
335+
Other output generator options
336+
</th>
319337
</tr>
320338
<tr>
321-
<td>Some output generators support extra options (e.g. for =pdf=, you can add =htmldoc= command-line parameters here, such as =--linkstyle underline=)</td>
322339
<td>
323-
<textarea rows="5" cols="80" class="foswikiInputField">%URLPARAM{"genopt" default=""}%</textarea>
340+
Some output generators support extra options (e.g. for =pdf=, you
341+
can add =htmldoc= command-line parameters here, such as
342+
=--linkstyle underline=)
324343
</td>
325344
<td>
326-
=genopt=
345+
<textarea name="extras" rows="5" cols="80" class="foswikiInputField">%URLPARAM{"extras" default="" encode="entity"}%</textarea>
346+
</td>
347+
<td>
348+
=extras=
327349
</td>
328-
</td>
329350
</tr>
330351
<tr>
331-
<td colspan="3" class="foswikiLast">
332-
<input type="submit" class="foswikiSubmit" value="Publish" />
333-
</td>
352+
<td colspan="3" class="foswikiLast">
353+
<input type="submit" class="foswikiSubmit" value="Publish" />
354+
</td>
334355
</tr>
335356
</table>
336357
</form>
@@ -360,7 +381,7 @@ Just =cd= to the =bin= directory, and
360381
=perl -T rest /PublishPlugin/publish=. Parameters are passed as name=value pairs, for example:
361382
<verbatim>
362383
perl -T rest /PublishPlugin/publish web=Book exclusions='Web*' format=file
363-
perl -T rest /PublishPlugin/publish web=Book inclusions=WebBook format=pdf genopt='--book --duplex --toclevels=5'
384+
perl -T rest /PublishPlugin/publish web=Book inclusions=WebBook format=pdf extras='--book --duplex --toclevels=5'
364385
</verbatim>
365386
The available parameter names are shown in the publish form above, in the last column.
366387

@@ -406,6 +427,7 @@ This add-on started life as the !GenHTMLAddon, written by Foswiki:Main/CrawfordC
406427
| License: | GPL |
407428
| Version: | %$VERSION% |
408429
| Change History: | |
430+
| 30 May 2009 | Foswikitask:Item8168: fixed genopt (extras) |
409431
| 22 May 2009 | Foswikitask:Item8165: fixed missing BASEWEB and other internal preferences. This was resulting in the wrong web being used for some operations |
410432
| 16 May 2009 | Foswikitask:Item1626: fixed META{"formfield" Foswikitask:Item8150: (Marc Schaefer) fix for -skin parameter Foswikitask:Item1557: doc fix Foswikitask:Item1585: allow history topic in different web Foswikitask:Item871: add missing newline at start of topic text. Foswikitask:Item1449: topic publisher was not popping the context correctly Foswikitask:Item1632: improve backporting support |
411433
| 18 Mar 2009 | Foswikitask:Item804: automatically create publish dir Foswikitask:Item8078: support publishing to a subdir of the publish dir, under url param control |

lib/Foswiki/Plugins/PublishPlugin/BackEnd.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ Construct a new back end.
3838
=cut
3939

4040
sub new {
41-
my ( $class, $path, $web, $genopt, $logger, $query ) = @_;
41+
my ( $class, $path, $web, $extras, $logger, $query ) = @_;
4242
$path .= '/' unless $path =~ m#/$#;
4343
my $this = bless( {
4444
path => $path,
4545
web => $web,
46-
genopt => $genopt,
46+
extras => $extras,
4747
logger => $logger,
4848
query => $query,
4949
}, $class );

lib/Foswiki/Plugins/PublishPlugin/Publisher.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ sub _handleURL {
908908
my $host = $2;
909909
my $port = $3 || 80;
910910
my $path = $4;
911-
die $src unless $host;
912911
# Early getUrl didn't support protocol
913912
if ($Foswiki::Plugins::SESSION->{net}->can('_getURLUsingLWP')) {
914913
$data =

lib/Foswiki/Plugins/PublishPlugin/file.pm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ sub new {
2929
my $this = $class->SUPER::new(@_);
3030

3131
foreach my $param qw(defaultpage googlefile relativeurl) {
32-
my $p = $this->{query}->param($param);
33-
die "'$param' query parameter missing" unless defined $p;
32+
my $p = $this->{query}->param($param) || '';
3433
$p =~ /^(.*)$/;
3534
$this->{$param} = $1;
3635
}
@@ -125,9 +124,6 @@ HERE
125124
my $topicTemplatePre = "<url>\n<loc>";
126125
my $topicTemplatePost = "</loc>\n</url>";
127126

128-
die "relativeurl param not defined"
129-
unless ( defined( $this->{relativeurl} ) );
130-
131127
my $urls = join(
132128
"\n",
133129
map {

lib/Foswiki/Plugins/PublishPlugin/ftp.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use File::Temp qw(:seekable);
3232
use File::Spec;
3333

3434
sub new {
35-
my ( $class, $path, $web, $genopt, $logger, $query ) = @_;
36-
my $this = $class->SUPER::new( $path, $web, $genopt, $logger, $query );
35+
my ( $class, $path, $web, $extras, $logger, $query ) = @_;
36+
my $this = $class->SUPER::new( $path, $web, $extras, $logger, $query );
3737

3838
foreach my $param qw(destinationftpserver
3939
destinationftppath destinationftpusername

lib/Foswiki/Plugins/PublishPlugin/pdf.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ our @ISA = ( 'Foswiki::Plugins::PublishPlugin::file' );
2424
use File::Path;
2525

2626
sub new {
27-
my ( $class, $path, $web, $genopt, $logger, $query ) = @_;
27+
my ( $class, $path, $web, $extras, $logger, $query ) = @_;
2828
my $t = Foswiki::Time::formatTime(time, '$year$mo$day$hours$minutes$seconds', 'gmtime');
29-
return $class->SUPER::new( $path, "${web}_$t", $genopt, $logger, $query );
29+
return $class->SUPER::new( $path, "${web}_$t", $extras, $logger, $query );
3030
}
3131

3232
sub close {
@@ -45,7 +45,7 @@ sub close {
4545
die "{PublishPlugin}{PDFCmd} not defined" unless $cmd;
4646

4747
my $landed = "$this->{web}.pdf";
48-
my @extras = split( /\s+/, $this->{genopt} || '' );
48+
my @extras = split( /\s+/, $this->{extras} || '' );
4949

5050
$ENV{HTMLDOC_DEBUG} = 1; # see man htmldoc - goes to apache err log
5151
$ENV{HTMLDOC_NOCGI} = 1; # see man htmldoc

lib/Foswiki/Plugins/PublishPlugin/pdffiles.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ my $debug = 1;
2727
Foswiki::Plugins::PublishPlugin::PDFWriter);
2828

2929
sub new {
30-
my ( $class, $path, $web, $genopt ) = @_;
30+
my ( $class, $path, $web, $extras ) = @_;
3131
my $this = bless( $class->SUPER::new( $path, "${web}_$$" ), $class );
32-
$this->{genopt} = $genopt;
32+
$this->{extras} = $extras;
3333
return $this;
3434
}
3535

0 commit comments

Comments
 (0)