Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item8260: fix it so that links to topics that are not published don't…
… get rewritten. Also refactored generators into a subdirectory to make life a bit easier. git-svn-id: http://svn.foswiki.org/trunk/PublishPlugin@15234 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
CrawfordCurrie
authored and
CrawfordCurrie
committed
Jul 30, 2012
1 parent
9ae10a1
commit 35d1c46
Showing
12 changed files
with
243 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# | ||
# Copyright (C) 2005 Crawford Currie, http://c-dot.co.uk | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# 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 | ||
# | ||
# PDF writer module for PublishPlugin | ||
# | ||
|
||
package Foswiki::Plugins::PublishPlugin::BackEnd::flatpdf; | ||
|
||
use strict; | ||
use Foswiki::Plugins::PublishPlugin::BackEnd::flatfile; | ||
our @ISA = ('Foswiki::Plugins::PublishPlugin::BackEnd::flatfile'); | ||
|
||
use constant DESCRIPTION => | ||
'PDF file with all topics and attachments inside it. Topics will follow one another with no intervening page breaks.'; | ||
|
||
use File::Path; | ||
|
||
sub new { | ||
my $class = shift; | ||
my ($params) = @_; | ||
$params->{outfile} ||= "flatpdf"; | ||
my $this = $class->SUPER::new(@_); | ||
return $this; | ||
} | ||
|
||
sub param_schema { | ||
my $class = shift; | ||
return { | ||
outfile => { | ||
default => 'flatpdf', | ||
validator => | ||
\&Foswiki::Plugins::PublishPlugin::Publisher::validateFilename | ||
}, | ||
%{ $class->SUPER::param_schema() } | ||
}; | ||
} | ||
|
||
sub close { | ||
my $this = shift; | ||
my $dir = $this->{path}; | ||
eval { File::Path::mkpath($dir) }; | ||
die $@ if ($@); | ||
|
||
my @files = ("$dir$this->{params}->{outfile}/master.html"); | ||
|
||
my $cmd = $Foswiki::cfg{PublishPlugin}{PDFCmd}; | ||
die "{PublishPlugin}{PDFCmd} not defined" unless $cmd; | ||
|
||
my $landed = "$this->{params}->{outfile}.pdf"; | ||
my @extras = split( /\s+/, $this->{extras} || '' ); | ||
|
||
$ENV{HTMLDOC_DEBUG} = 1; # see man htmldoc - goes to apache err log | ||
$ENV{HTMLDOC_NOCGI} = 1; # see man htmldoc | ||
|
||
$this->{path} .= '/' unless $this->{path} =~ m#/$#; | ||
my ( $data, $exit ) = Foswiki::Sandbox::sysCommand( | ||
$Foswiki::sharedSandbox, | ||
$cmd, | ||
FILE => "$this->{path}$landed", | ||
FILES => \@files, | ||
EXTRAS => \@extras | ||
); | ||
|
||
# htmldoc failsa lot, so log rather than dying | ||
$this->{logger}->logError("htmldoc failed: $exit/$data/$@") if $exit; | ||
|
||
# Get rid of the temporaries | ||
unlink( @{ $this->{files} } ); | ||
|
||
return $landed; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.