git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
common: copy plp errors on stderr
[sheet.git]
/
common.inc.plp
diff --git
a/common.inc.plp
b/common.inc.plp
index 11f1fb4a18a7e2959048542198551c2845204c40..593adb0619d2d2b579782e888772114f412058ad 100644
(file)
--- a/
common.inc.plp
+++ b/
common.inc.plp
@@
-1,6
+1,6
@@
<:
<:
+use 5.014;
use utf8;
use utf8;
-use strict;
use warnings;
no warnings 'qw'; # you know what you doing
no warnings 'uninitialized'; # save some useless checks for more legible code
use warnings;
no warnings 'qw'; # you know what you doing
no warnings 'uninitialized'; # save some useless checks for more legible code
@@
-12,8
+12,14
@@
use HTTP::Date;
$PLP::ERROR = sub {
my ($text, $html) = @_;
print '<p class="error"><strong>Fatal error</strong>: '.$html."</p>\n\n";
$PLP::ERROR = sub {
my ($text, $html) = @_;
print '<p class="error"><strong>Fatal error</strong>: '.$html."</p>\n\n";
+ warn $text;
};
};
+BEGIN {
+ require Time::HiRes;
+ our $Time = [Time::HiRes::gettimeofday];
+}
+
our $style;
our $showkeys = !exists $get{keys} ? undef :
($get{keys} ne '0' && ($get{keys} || 'always'));
our $style;
our $showkeys = !exists $get{keys} ? undef :
($get{keys} ne '0' && ($get{keys} || 'always'));
@@
-41,7
+47,7
@@
sub stylesheet {
return join "\n", map { sprintf(
'<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
return join "\n", map { sprintf(
'<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
- $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.
7
", $_
+ $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.
9
", $_
) } @_;
}
) } @_;
}
@@
-112,11
+118,12
@@
sub Html {
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/clip.png">
EOT
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="/clip.png">
EOT
-
print $_, "\n"
for $meta->{stylesheet} || ();
-
print $_, "\n"
for $meta->{raw} || ();
-
print qq{</head>\n\n<body id="$file">\n
};
+
say
for $meta->{stylesheet} || ();
+
say
for $meta->{raw} || ();
+
say qq{</head>\n\n<body id="$file">
};
# dev indicator
# dev indicator
+ my $Dev = $ENV{HTTP_HOST} =~ /\bdev\./;
printf '<p style="%s">beta</p>', join('; ',
'position: fixed',
'right: 1em',
printf '<p style="%s">beta</p>', join('; ',
'position: fixed',
'right: 1em',
@@
-125,7
+132,7
@@
EOT
'border-width: 1ex 0',
'z-index: 1',
'background: inherit',
'border-width: 1ex 0',
'z-index: 1',
'background: inherit',
- ) if $
ENV{HTTP_HOST} =~ /\bdev\./
;
+ ) if $
Dev
;
# prepare trailing output
PLP_END {
# prepare trailing output
PLP_END {
@@
-138,10
+145,11
@@
EOT
created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="license copyright"
title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>
created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="license copyright"
title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>
-</p>
-
-</html>
EOT
EOT
+ say sprintf '• %.3fs', Time::HiRes::tv_interval($Time) if $Dev;
+ say '</p>';
+ say '';
+ say '</html>';
};
}
};
}