source: last-modified negotiation for json output
[sheet.git] / browser.plp
index b2a7867fd7a402b64bfd45971c3abf88bbd526a8..6c06a2eb5745e53dc26a140ddae27510cf6aadc2 100644 (file)
@@ -6,8 +6,10 @@ use List::Util qw(sum max first);
 Html({
        title => 'browser compatibility cheat sheet',
        version => 'v1.0',
-       description =>
-               "caniuse.",
+       description => [
+               "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)",
+               "comparing support and usage share for all popular browser versions.",
+       ],
        keywords => [qw'
                web browser support compatibility usage available feature
                html html5 css css3 svg javascript js dom mobile
@@ -86,8 +88,9 @@ given ($get{usage} // 'wm') {
                break;
        };
        $usage = $_;
-       my $ref = $canihas->{-source} || 'unknown';
-       $ref = sprintf '<a href="%s">%s</a>', $_, $ref for $canihas->{-url} || ();
+       my $ref = $canihas->{-title} || 'unknown';
+       $ref = sprintf '<a href="%s">%s</a>', $_, $ref
+               for $canihas->{-site} || $canihas->{-source} || ();
        $ref .= " $_" for $canihas->{-date} || ();
        print "\nwith $ref browser usage statistics";
 }
@@ -236,10 +239,14 @@ sub saytitlecol {
        } $row->{title};
        print '<div class=aside>';
        s/\.?$/./, print "<p>$_</p>" for map { ref $_ ? @$_ : $_ || () }
-               Entity($row->{description}), formathtml($row->{notes});  # sic
+               Entity($row->{description}),
+               map { s/\s*\n/\n<br>/g; $_ } $row->{notes};
        printf 'Resources: %s.', join(', ', map {
                sprintf '<a href="%s">%s</a>', EscapeHTML($_->{url}), $_->{title}
        } @$_) for grep { @$_ } $row->{links} // ();
+       printf '<br>Parent feature: %s.', join(', ', map {
+               sprintf '<a href="%s">%s</a>', EscapeHTML("#$_"), $caniuse->{data}->{$_}->{title}
+       } $_) for $row->{parent} || ();
        print '</div>';
 }
 
@@ -310,16 +317,6 @@ for my $id (sort {
 say '</tbody>';
 say '</table>';
 
-sub formathtml {
-       my $ref = defined wantarray ? [@_] : \@_;
-       for (@$ref) {
-               s/& (?!\w)/&amp;/gx;
-               s/< \s/&lt;/gx;
-               s/\n\K\n/<br>/g;
-       }
-       return @$ref;
-}
-
 sub paddedver {
        # normalised version number comparable as string (cmp)
        shift =~ /(?:.*-|^)(\d*)(.*)/;
@@ -329,10 +326,11 @@ sub paddedver {
 
 sub showversions {
        my @span = ($_[0], @_>1 ? $_[-1] : ());
+       s/-.*// for $span[0];
        for (@span) {
                s/^\./0./;
                s/x$/.*/;
-               s/-.*//;
+               s/.*-//;
        }
        return join('‒', @span);
 }