X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/4b71762936d38dfebc9aa8093777e44aad5b41ab..c2f9c9e9c05d8639e4d968efd26c393fcf6da1f1:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index afec9d1..d282f09 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -78,7 +78,7 @@ sub stylesheet { return map { sprintf( '', - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.13", $_ + $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.14", $_ ) } @avail; } @@ -103,7 +103,7 @@ sub Data { my ($filename) = @_; my @data = eval { open my $cache, '<:raw', "data/$filename.json" - or return do "$filename.inc.pl"; # silent fallback to original code + or return do "./$filename.inc.pl"; # silent fallback to original code require JSON; local $/; # slurp return JSON::decode_json(readline $cache); @@ -133,6 +133,7 @@ sub Html { # default fallbacks $meta->{stylesheet} ||= [qw( light dark circus mono red )]; $meta->{charset} ||= 'utf-8'; + $meta->{lang} ||= 'en'; # convert options to arrays ref $_ eq 'ARRAY' or $_ = [$_] @@ -141,6 +142,7 @@ sub Html { # document headers before output $header{content_type} = "text/html; charset=$meta->{charset}" unless $PLP::sentheaders; + exit if $ENV{REQUEST_METHOD} eq 'HEAD'; unshift @{ $meta->{raw} }, stylesheet($meta->{stylesheet}); push @{ $meta->{raw} }, ( @@ -161,7 +163,7 @@ sub Html { PLP_START { # leading output say ''; - say ''; + say qq(); say ''; say ''; say sprintf '', $_ @@ -233,10 +235,9 @@ BEGIN { sub showlink { my ($title, $href, $selected) = @_; - return sprintf( - !$href ? '%s' : - $selected ? '%s' : '%s', - EscapeHTML($title), EscapeHTML($href) - ); + EscapeHTML($title); + return $title if not $href; + return "$title" if $selected; + return sprintf '%s', EscapeHTML($href), $title; }