aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-06-02 22:33:03 -0400
committerHolden Rohrer <hr@hrhr.dev>2020-06-02 22:33:38 -0400
commit85d87d47f870c692772276345655ebf8e2da7ed5 (patch)
tree09facd792d891f5cf41f775b16c62ac9e1f97e0d
parent84ce497a7743bc41bb60f5c0f01453e40a9d377b (diff)
restructuring and perliness
-rw-r--r--.gitignore2
-rw-r--r--Makefile9
-rw-r--r--minimun.orig49
-rw-r--r--orig/format.tex (renamed from format.tex)2
-rw-r--r--orig/minimun55
5 files changed, 64 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
index 2223198..2adc16f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
minimun
+format.tex
+!orig/*
minimun.tar.gz
diff --git a/Makefile b/Makefile
index dc7175d..aed056f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,13 @@
DESTDIR=/home/minimun/minimun
VER=1.0
-minimun: minimun.orig
- sed 's:%%DEST%%:$(DESTDIR):' minimun.orig > minimun
+minimun: orig/minimun
+ sed 's:%%DEST%%:$(DESTDIR):' orig/minimun > minimun
chmod +x minimun
+format.tex: orig/format.tex
+ sed 's:%%DEST%%:$(DESTDIR):' orig/format.tex > format.tex
+
clean:
rm minimun
@@ -17,7 +20,7 @@ uninstall:
rm $(DESTDIR)/{minimun,format.tex,logo.png}
rmdir -p $(DESTDIR)
-SRC = format.tex LICENCE logo.png Makefile minimun.ini minimun.orig\
+SRC = format.tex LICENCE logo.png Makefile minimun.ini orig\
nginx.example.conf README www minimun.spec
dist: minimun.tar.gz
minimun.tar.gz: $(SRC)
diff --git a/minimun.orig b/minimun.orig
deleted file mode 100644
index 5ad7dc8..0000000
--- a/minimun.orig
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-
-use IPC::Run qw(run);
-use Time::HiRes qw( time );
-
-chdir('%%DEST%%');
-
-my ($buffer, @pairs, $pair, $name, $val, %FORM);
-
-if ($ENV{'REQUEST_METHOD'} eq "GET") {
- $buffer = $ENV{'QUERY_STRING'};
-}
-@pairs = split(/&/, $buffer);
-
-foreach $pair (@pairs) {
- ($name, $val) = split(/=/, $pair);
- $val =~ tr/+/ /;
- $val =~ s/%(..)/pack("C", hex($1))/eg;
- $FORM{$name} = $val;
-}
-
-my ($in, $out);
-$in = "\n";
-
-if (index($ENV{'PATH_INFO'},'award.pdf') != -1){
- $in .= "\\award{$FORM{'committee'}}{$FORM{'country'}}{$FORM{'award'}}{$FORM{'school'}}";
-}
-elsif (index($ENV{'PATH_INFO'},'room.pdf') != -1){
- $in .= "\\room{$FORM{'committee'}}";
-}
-else{
- print "Content-type: text/html\n";
- print "Status: 404 File Not Found Error\n";
- print "\n";
- print '<a href="/">404 Error. Go back.</a>';
- die;
-}
-
-$in .= "\\bye\n";
-
-my $timestamp = time;
-run ['/usr/bin/pdftex', '-jobname', "/tmp/$timestamp", 'format.tex'], '<', \$in, '>', \$out;
-print "Content-type: application/pdf\n\n";
-open(DOC, '<', "/tmp/$timestamp.pdf");
-print <DOC>;
-close(DOC);
-unlink "/tmp/$timestamp.pdf", "/tmp/$timestamp.log";
diff --git a/format.tex b/orig/format.tex
index 3ee1120..7089762 100644
--- a/format.tex
+++ b/orig/format.tex
@@ -72,7 +72,7 @@
\ful\leftskip=0pt plus 1fil\rightskip=0pt plus 1fil\parindent=0pt\parfillskip=0pt
\vfil
#1\vfil
- \line{\hfil\pdfximage width 6in{logo.png}\pdfrefximage\pdflastximage\hfil}
+ \line{\hfil\pdfximage width 6in{%%DEST%%/logo.png}\pdfrefximage\pdflastximage\hfil}
\vfil
}
}
diff --git a/orig/minimun b/orig/minimun
new file mode 100644
index 0000000..f6f9407
--- /dev/null
+++ b/orig/minimun
@@ -0,0 +1,55 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use File::Temp qw( tempfile );
+use File::Copy;
+
+chdir('/tmp');
+
+$buffer, %FORM;
+
+if ($ENV{'REQUEST_METHOD'} eq "GET") {
+ $buffer = $ENV{'QUERY_STRING'};
+}
+@pairs = split(/&/, $buffer);
+
+foreach $pair (@pairs) {
+ my ($name, $val) = split(/=/, $pair);
+ $val =~ tr/+/ /;
+ $val =~ s/%(..)/pack("C", hex($1))/eg;
+ $val =~ s/([#%_\$^&{}\\])/\\$1/g;
+ $FORM{$name} = $val;
+}
+
+($fh, $filename) = tempfile(UNLINK => 1);
+copy("%%DEST%%/format.tex",$fh);
+
+print $fh "\n";
+
+if (index($ENV{'PATH_INFO'},'award.pdf') != -1){
+ say $fh "\\award{$FORM{'committee'}}{$FORM{'country'}}{$FORM{'award'}}{$FORM{'school'}}";
+}
+elsif (index($ENV{'PATH_INFO'},'room.pdf') != -1){
+ say $fh "\\room{$FORM{'committee'}}";
+}
+else{
+ print "Content-type: text/html\n";
+ print "Status: 404 File Not Found Error\n\n";
+ print '<a href="/">404 Error. Go back.</a>';
+ die;
+}
+
+say $fh "\\bye";
+
+system ('/usr/bin/pdftex', $filename);
+open(DOC, '<', "$filename.pdf") or {
+ print "Content-type: text/html\n";
+ print "Status: 400 Bad Request Error\n\n";
+ print '<h1>400 Bad Request</h1>';
+ die;
+}
+print "Content-type: application/pdf\n\n";
+print <DOC>;
+close(DOC);
+unlink "$filename.pdf", "$filename.log";