sc: ghost upgrades
[sheet.git] / common.inc.plp
index afec9d11f2172bb2130301eaf7468422a86020a2..6ea11976106b6363bd8b0d88dfca1b267cae6476 100644 (file)
@@ -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 $_ = [$_]
@@ -161,7 +162,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 +234,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;
 }