X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/881b4a69e47004c59f35979620b65fd3d4aaaf16..5e2f32d08b77d469b7f190f40dde1e4ca9cd1af3:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index 4bf28bf..cb282c0 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -8,7 +8,11 @@ use open ':std' => ':utf8'; use File::stat 'stat'; use HTTP::Date; -use Shiar_Sheet::KeySigns qw(%sign); + +$PLP::ERROR = sub { + my ($text, $html) = @_; + print '

Fatal error: '.$html."

\n\n"; +}; our $style; our $showkeys = !exists $get{keys} ? undef : @@ -22,19 +26,21 @@ sub stylesheet { if (exists $get{style}) { $style = $styles{ $get{style} }; require CGI::Cookie; - AddCookie(CGI::Cookie->new( + if (my $cookie = CGI::Cookie->new( -name => 'style', -value => $style, -path => '/', # site-wide; current page is confusing to most users -expires => $style ? '+5y' : '-1d', - )->as_string); + )) { + AddCookie($cookie->as_string); + } } $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $_[0]; return join "\n", map { sprintf( '', - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.5", $_ + $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.6", $_ ) } @_; } @@ -77,13 +83,13 @@ sub Html { !$showkeys ? '' : $showkeys eq 'ghost' ? '' : (), - '', + '', ) if $meta->{keys}; # flatten arrays ref $_ eq 'ARRAY' and $_ = join ' ', @$_ for $meta->{description}; ref $_ eq 'ARRAY' and $_ = join ', ', @$_ for $meta->{keywords}; - ref $_ eq 'ARRAY' and $_ = join "\n", @$_ for $meta->{rawstyle}, $meta->{raw}; + ref $_ eq 'ARRAY' and $_ = join "\n", @$_ for $meta->{raw}; ref $_ eq 'ARRAY' and $_ = stylesheet(@$_)."\n" for $meta->{stylesheet}; # other vars @@ -115,7 +121,7 @@ EOT rel="code" title="Written in Perl">plp $meta->{version} - created by $sign{sep} + created by • AGPLv3