git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
readline: replace code by common keyboard page
[sheet.git]
/
common.inc.plp
diff --git
a/common.inc.plp
b/common.inc.plp
index 39865bdb55f2ca961da6d7f0ebcaecbc760aab9a..d282f091ca452598092ca2b7034c691f5d57ccbb 100644
(file)
--- a/
common.inc.plp
+++ b/
common.inc.plp
@@
-78,7
+78,7
@@
sub stylesheet {
return map { sprintf(
'<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
return map { sprintf(
'<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
- $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.1
3
", $_
+ $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.1
4
", $_
) } @avail;
}
) } @avail;
}
@@
-102,7
+102,11
@@
sub checkmodified {
sub Data {
my ($filename) = @_;
my @data = eval {
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', $@ || $!];
};
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';
# 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 $_ = [$_]
# convert options to arrays
ref $_ eq 'ARRAY' or $_ = [$_]
@@
-137,6
+142,7
@@
sub Html {
# document headers before output
$header{content_type} = "text/html; charset=$meta->{charset}"
unless $PLP::sentheaders;
# 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} }, (
unshift @{ $meta->{raw} }, stylesheet($meta->{stylesheet});
push @{ $meta->{raw} }, (
@@
-157,7
+163,7
@@
sub Html {
PLP_START {
# leading output
say '<!DOCTYPE html>';
PLP_START {
# leading output
say '<!DOCTYPE html>';
- say
'<html lang="en">'
;
+ say
qq(<html lang="$meta->{lang}">)
;
say '';
say '<head>';
say sprintf '<meta http-equiv="content-type" content="%s">', $_
say '';
say '<head>';
say sprintf '<meta http-equiv="content-type" content="%s">', $_
@@
-229,10
+235,9
@@
BEGIN {
sub showlink {
my ($title, $href, $selected) = @_;
sub showlink {
my ($title, $href, $selected) = @_;
- return sprintf(
- !$href ? '%s' :
- $selected ? '<strong>%s</strong>' : '<a href="%2$s">%s</a>',
- EscapeHTML($title), EscapeHTML($href)
- );
+ EscapeHTML($title);
+ return $title if not $href;
+ return "<strong>$title</strong>" if $selected;
+ return sprintf '<a href="%s">%s</a>', EscapeHTML($href), $title;
}
}