X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/58725794d72361cc70cb082476a32d08e22d21d0..aad474b0ccf6fddd73b11d8c7ed4c57093ce1741:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index 39865bd..6ea1197 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -102,7 +102,11 @@ sub checkmodified { sub Data { my ($filename) = @_; my @data = eval { - do "$filename.inc.pl"; + open my $cache, '<:raw', "data/$filename.json" + or return do "./$filename.inc.pl"; # silent fallback to original code + require JSON; + local $/; # slurp + return JSON::decode_json(readline $cache); }; if ($! or $@ or !@data or !$data[0]) { die ['Table data not found', $@ || $!]; @@ -129,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 $_ = [$_] @@ -157,7 +162,7 @@ sub Html { PLP_START { # leading output say ''; - say ''; + say qq(); say ''; say ''; say sprintf '', $_ @@ -229,10 +234,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; }