index: release v1.18 with only altgr index linked
[sheet.git] / common.inc.plp
index 2976cbe37cd07615b1f9073d9fc332b403e19e24..a634733cba704de18de8e56605a78a796f8109c9 100644 (file)
@@ -76,7 +76,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.14", $_
+               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.18", $_
        ) } @avail;
 }
 
@@ -106,7 +106,7 @@ sub Data {
                local $/; # slurp
                return JSON::decode_json(readline $cache);
        };
-       if ($! or $@ or !@data or !$data[0]) {
+       if ($@ or !@data or !$data[0]) {
                die ['Table data not found', $@ || $!];
        }
        if (@data == 1 and ref $data[0] eq 'HASH' and not %{$data[0]}) {
@@ -147,8 +147,22 @@ sub Html {
                '<link rel="stylesheet" type="text/css" media="monochrome" href="/mono.css?1.11" title="light">',
        );
 
+       if (my $img = $meta->{image}) {
+               my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's');
+               my $url = "$proto$ENV{HTTP_HOST}/$img";
+               push @{ $meta->{raw} }, (
+                       qq(<meta property="og:image" content="$url" />),
+               );
+       }
+
        my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
 
+       $meta->{canonical} //= "/$file" . ($Request ne '' && "/$Request");
+       if (my $url = $meta->{canonical}) {
+               $url = "https://sheet.shiar.nl$url";
+               push @{ $meta->{raw} }, qq(<link rel="canonical" href="$url" />);
+       }
+
        PLP_START {
                # leading output
                say '<!DOCTYPE html>';