keyboard: custom rows overrides in moderows attribute
[sheet.git] / common.inc.plp
index afec9d11f2172bb2130301eaf7468422a86020a2..d282f091ca452598092ca2b7034c691f5d57ccbb 100644 (file)
@@ -78,7 +78,7 @@ sub stylesheet {
 
        return map { sprintf(
                '<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
-               $_ 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 '<!DOCTYPE html>';
-               say '<html lang="en">';
+               say qq(<html lang="$meta->{lang}">);
                say '';
                say '<head>';
                say sprintf '<meta http-equiv="content-type" content="%s">', $_
@@ -233,10 +235,9 @@ BEGIN {
 
 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;
 }