From 85d87d47f870c692772276345655ebf8e2da7ed5 Mon Sep 17 00:00:00 2001
From: Holden Rohrer
Date: Tue, 2 Jun 2020 22:33:03 -0400
Subject: restructuring and perliness
---
.gitignore | 2 ++
Makefile | 9 ++++---
format.tex | 78 ---------------------------------------------------------
minimun.orig | 49 ------------------------------------
orig/format.tex | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
orig/minimun | 55 ++++++++++++++++++++++++++++++++++++++++
6 files changed, 141 insertions(+), 130 deletions(-)
delete mode 100644 format.tex
delete mode 100644 minimun.orig
create mode 100644 orig/format.tex
create mode 100644 orig/minimun
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/format.tex b/format.tex
deleted file mode 100644
index 3ee1120..0000000
--- a/format.tex
+++ /dev/null
@@ -1,78 +0,0 @@
-%gives ''\newfont myfont=cmr10@14pt''
-\newcount\spacing
-\newdimen\size
-\def\adjs{%adjust spacing
- \baselineskip=\size \multiply\baselineskip by \spacing \divide\baselineskip by 10
-}
-\def\newfont#1=#2@#3pt{%name, base, size
- \expandafter\font\csname x#1\endcsname=#2 at #3pt
- \expandafter\edef\csname #1\endcsname{\size=#3pt \adjs \csname x#1\endcsname}
-}
-
-\newfont ful=cmb10@144pt
-\newfont mas=cmb10@72pt
-\newfont big=cmr10@48pt
-\font\big=cmr10 at 48pt
-\newfont sml=cmr10@20pt
-\spacing=12
-
-\pdfpageheight=8.5in
-\pdfpagewidth=11in
-\voffset=-.5in\hoffset=-.5in
-\vsize=7.5in
-\hsize=10in
-\nopagenumbers
-
-\newdimen\sigheight
-\def\award#1#2#3#4{
- \vbox to \vsize{
- \sml\leftskip=0pt plus 1fil\rightskip=0pt plus 1fil\parindent=0pt\parfillskip=0pt
- \vfil
-
- {\big Centennial High School Model United Nations\par}
- \bigskip
- Awards this certificate to:
-
- {\mas #1\par}
- \bigskip
- \hrule
- \bigskip
-
- \line{\hfil\vbox{
- \hsize=.5\hsize
- For #2 in #3
- }\hfil}
- \vfil
-
- \line{
- \vtop{
- \hsize=3in
- \hrule\medskip Committee Chair
- }
- \hfil
- \vtop{
- \hsize=3in
- \hrule\medskip Secretary-General\vskip.7in
- \hrule\medskip Director-General
- }
- }
- \vskip\sigheight
- #4
-
- MiniMUN \number\year
-
- November \number\day, \number\year
- \vfil
- }
- \eject
-}
-
-\def\room#1{
- \vbox to\vsize{
- \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}
- \vfil
- }
-}
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 '404 Error. Go back.';
- 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 ;
-close(DOC);
-unlink "/tmp/$timestamp.pdf", "/tmp/$timestamp.log";
diff --git a/orig/format.tex b/orig/format.tex
new file mode 100644
index 0000000..7089762
--- /dev/null
+++ b/orig/format.tex
@@ -0,0 +1,78 @@
+%gives ''\newfont myfont=cmr10@14pt''
+\newcount\spacing
+\newdimen\size
+\def\adjs{%adjust spacing
+ \baselineskip=\size \multiply\baselineskip by \spacing \divide\baselineskip by 10
+}
+\def\newfont#1=#2@#3pt{%name, base, size
+ \expandafter\font\csname x#1\endcsname=#2 at #3pt
+ \expandafter\edef\csname #1\endcsname{\size=#3pt \adjs \csname x#1\endcsname}
+}
+
+\newfont ful=cmb10@144pt
+\newfont mas=cmb10@72pt
+\newfont big=cmr10@48pt
+\font\big=cmr10 at 48pt
+\newfont sml=cmr10@20pt
+\spacing=12
+
+\pdfpageheight=8.5in
+\pdfpagewidth=11in
+\voffset=-.5in\hoffset=-.5in
+\vsize=7.5in
+\hsize=10in
+\nopagenumbers
+
+\newdimen\sigheight
+\def\award#1#2#3#4{
+ \vbox to \vsize{
+ \sml\leftskip=0pt plus 1fil\rightskip=0pt plus 1fil\parindent=0pt\parfillskip=0pt
+ \vfil
+
+ {\big Centennial High School Model United Nations\par}
+ \bigskip
+ Awards this certificate to:
+
+ {\mas #1\par}
+ \bigskip
+ \hrule
+ \bigskip
+
+ \line{\hfil\vbox{
+ \hsize=.5\hsize
+ For #2 in #3
+ }\hfil}
+ \vfil
+
+ \line{
+ \vtop{
+ \hsize=3in
+ \hrule\medskip Committee Chair
+ }
+ \hfil
+ \vtop{
+ \hsize=3in
+ \hrule\medskip Secretary-General\vskip.7in
+ \hrule\medskip Director-General
+ }
+ }
+ \vskip\sigheight
+ #4
+
+ MiniMUN \number\year
+
+ November \number\day, \number\year
+ \vfil
+ }
+ \eject
+}
+
+\def\room#1{
+ \vbox to\vsize{
+ \ful\leftskip=0pt plus 1fil\rightskip=0pt plus 1fil\parindent=0pt\parfillskip=0pt
+ \vfil
+ #1\vfil
+ \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 '404 Error. Go back.';
+ 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 '400 Bad Request
';
+ die;
+}
+print "Content-type: application/pdf\n\n";
+print ;
+close(DOC);
+unlink "$filename.pdf", "$filename.log";
--
cgit