X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fautohandler;h=8ff09966b953143dfd474a4a0d43c66913f47c38;hp=ba6c8b9bfd318bd66ec751c37f215101537cdfc7;hb=efd685a5df610ffefc545a41be67e2e0d4b69c7c;hpb=e1104ec9b3f093f6c496cd9763b06b0792b679ff diff --git a/yarrg/web/autohandler b/yarrg/web/autohandler index ba6c8b9..8ff0996 100644 --- a/yarrg/web/autohandler +++ b/yarrg/web/autohandler @@ -1,7 +1,98 @@ - -% $m->call_next; -<%init> +<%doc> + + This is part of the YARRG website. YARRG is a tool and website + for assisting players of Yohoho Puzzle Pirates. + + Copyright (C) 2009 Ian Jackson + Copyright (C) 2009 Clare Boothby + + YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). + The YARRG website is covered by the GNU Affero GPL v3 or later, which + basically means that every installation of the website will let you + download the source. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + are used without permission. This program is not endorsed or + sponsored by Three Rings. + + + This Mason autohandler contains the doctype, charset and + copyright message. + + +<%perl> + use CommodsWeb; + +my $printable= printable($m); +if ($printable =~ m/^pdf|^ps/) { + my $output; + my $got= $m->call_self(\$output); + if ($got) { + my @htargs= qw(htmldoc --continuous --gray --size 210x279mm + --left 1cm --right 1cm); + $printable =~ m/^[a-z]+/; + push @htargs, '-t',$&; + if ($printable =~ m/2$/) { + push @htargs, qw(--nup 2); + } + push @htargs, qw(-); + + my $tmpfile= IO::File::new_tmpfile(); + print $tmpfile $output or die $!; + $tmpfile->flush() or die $!; + seek $tmpfile,0,0 or die $!; + my $htmldoc= open HTMLDOC, "-|"; + defined $htmldoc or die $!; + if (!$htmldoc) { + eval { + $ENV{'HTMLDOC_NOCGI'}=1; + open STDIN, '<&', $tmpfile or die $!; + + exec @htargs; + die $!; + }; + print STDERR "HTMLDOC FAILURE $@"; + _exit(1); + } + my ($data,$read); + $r->content_type($printable eq 'pdf' ? 'application/pdf' : + 'application/postscript'); + while ($read= read HTMLDOC,$data,32768) { print $data; } + defined $read or die $!; + $?=0; $!=0; close HTMLDOC or die "$! $? $output "; + return; + } +} set_ctype_utf8(); $r->content_type('text/html; charset=UTF-8'); - + + + + +% $m->call_next();