Moved most site-specific configuration into config.pm.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 6 Aug 2005 23:20:28 +0000 (23:20 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 6 Aug 2005 23:20:28 +0000 (23:20 +0000)
config.pm [new file with mode: 0644]
createpdf.pl

diff --git a/config.pm b/config.pm
new file mode 100644 (file)
index 0000000..68030ea
--- /dev/null
+++ b/config.pm
@@ -0,0 +1,13 @@
+package pdfweb::config;
+
+# The home directory of the user going to be running the CGI scripts.
+# (Required if OOo is to find its configuration files etc.)
+our $homedir = "/home/cassarossa/itk/sesse/sesse-pdf/";
+
+# Display of a running X server (OOo needs one to work -- Xvfb will do nicely).
+our $xserver = ":25";
+
+# Directory for PDF output.
+our $outputdir = "/home/cassarossa/itk/sesse/public_html/pdf/output";
+
+1;
index bd39e9c..86187fb 100755 (executable)
@@ -22,8 +22,9 @@ use CGI;
 use POSIX;
 use strict;
 use File::Temp;
+require './config.pm';
 
-$ENV{"HOME"} = "/home/cassarossa/itk/sesse/sesse-pdf/";
+$ENV{"HOME"} = $pdfweb::config::homedir;
 
 my $cgi = CGI->new;
 my $filename = $cgi->param('input');
@@ -103,7 +104,7 @@ if ($filename =~ /(.*)\.(?:e?ps|pdf)$/i) {
        close DOC;
 
        # Create PostScript from OOo :-)
-       system("/usr/lib/openoffice/program/soffice -display :25 -headless -pt pdf /home/cassarossa/itk/sesse/public_html/pdf/output/$pdf_filename.$ext");
+       system("/usr/lib/openoffice/program/soffice -display $pdfweb::config::xserver -headless -pt pdf $pdfweb::config::outputdir/$pdf_filename.$ext");
 
        system("gs $pdfopts -dCompatbilityLevel=1.4 -dNOPAUSE -dPATCH -sDEVICE=pdfwrite -dSAFER -sOutputFile=output/$pdf_filename -c '.setpdfwrite $psopts' -f - < output/$pdf_filename.pdf >&2");
 } elsif ($filename =~ /(.*)\.(c|cc|cpp|cs|h|py|rb|pl|diff|patch|js|php[1-5]?|hs|f|f90|java|css|sql|l|y|s?ml|sh|awk|m|v)$/i) {
@@ -121,7 +122,7 @@ if ($filename =~ /(.*)\.(?:e?ps|pdf)$/i) {
        (my $sanitized_filename = $filename) =~ tr/a-zA-Z0-9./_/c;
 
        # This is just perverse :-P 
-       system("vim -Z -R +\"set printheader=\%<$sanitized_filename\%h\%m\%=Page\\ \%N\" +\"ha >/home/cassarossa/itk/sesse/public_html/pdf/output/$pdf_filename.ps\" +:q output/$pdf_filename.$ext");
+       system("vim -Z -R +\"set printheader=\%<$sanitized_filename\%h\%m\%=Page\\ \%N\" +\"ha >$pdfweb::config::outputdir/$pdf_filename.ps\" +:q output/$pdf_filename.$ext");
 
        system("gs $pdfopts -dCompatbilityLevel=1.4 -dNOPAUSE -dPATCH -sDEVICE=pdfwrite -dSAFER -sOutputFile=output/$pdf_filename -c '.setpdfwrite $psopts' -f - < output/$pdf_filename.ps >&2");
 } else {