X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/d22e7febda8720bc38069f7061adb43b98143c48..3e2a6f0b83acd0126dfd79a175fe53e400ec18a3:/common.inc.plp?ds=inline diff --git a/common.inc.plp b/common.inc.plp index e3316fc..dd41751 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -1,5 +1,6 @@ <: use 5.014; +use strict; use utf8; use warnings; no warnings 'qw'; # you know what you doing @@ -10,35 +11,40 @@ use File::stat 'stat'; use HTTP::Date; use Encode qw( decode_utf8 ); +our $Dev; + sub Alert { my ($html, $debug) = @_; ref $html eq 'ARRAY' or $html = [$html]; my ($title, @lines) = @{$html}; - $body = "
$_
" for @lines; $body .= "\n$debug" if $Dev and $debug; say "
$code" + . " after output!"; + } + Alert($html, $debug); + exit; +} + BEGIN { require Time::HiRes; our $Time = [Time::HiRes::gettimeofday()]; - $PLP::ERROR = sub { - my ($text, $html) = @_; - warn $text; - unless ($PLP::sentheaders and $PLP::sentheaders->[0] !~ m{/PLP\.pm$}) { - Html({nocache => 1}); - say '
beta
', join('; ', - 'position: fixed', - 'right: 1em', - 'opacity: .5', - 'border: 1ex solid red', - 'border-width: 1ex 0', - 'z-index: 1', - 'background: inherit', - ) if $Dev; + my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x; + + PLP_START { + # leading output + say ''; + say ''; + say ''; + say ''; + say sprintf '', $_ + for $header{content_type}; + say sprintf 'beta
', join('; ', + 'position: fixed', + 'right: 1em', + 'opacity: .5', + 'border: 1ex solid red', + 'border-width: 1ex 0', + 'z-index: 1', + 'background: inherit', + ) if $Dev; + }; # prepare trailing output PLP_END { @@ -176,6 +186,7 @@ sub Html { title="Licensed under the GNU Affero General Public License, version 3" rel="license">AGPLv3 EOT + our $Time; say sprintf '⢠%.3fs', Time::HiRes::tv_interval($Time) if $Dev and $Time; say ''; say ''; @@ -183,6 +194,18 @@ EOT }; } +BEGIN { + $PLP::ERROR = sub { + my ($text, $html) = @_; + warn $text; + unless ($PLP::sentheaders) { + Html({nocache => 1}); + say '