From b00da74f1eb20f7c5889d681a9880302743e45d0 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 9 Nov 2010 22:46:31 +0100 Subject: [PATCH] browser: terse overview of caniuse.com data --- browser.plp | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 browser.plp diff --git a/browser.plp b/browser.plp new file mode 100644 index 0000000..a3068f5 --- /dev/null +++ b/browser.plp @@ -0,0 +1,105 @@ +<(common.inc.plp)><: +use 5.010; + +Html({ + title => 'browser compatibility cheat sheet', + version => 'v1.0', + description => + "caniuse.", + keywords => [qw'html css browser feature'], + stylesheet => [qw'light dark circus mono red'], + data => ['caniuse.js'], +}); + +:> +

Browser compatibility

+ +

Alternate view of Fyrd's when can I use... site.

+ +<: +use JSON; +use File::Slurp 'read_file'; +my $source = read_file('caniuse.js'); +for ($source) { # cleanup + # convert seperate variables to hash keys + s/\A/{/; + s/^caniuse\.(\w+) = /"$1":/gm; + s/;$/,/gm; + s/,\s*\Z/\n}/; + # fractions not supported by barekey + s/(?<=[,{]) (\d*\.\d) (?=:')/"$1"/gx; + # escapes not supported in singlequote + s{'((?:[^\\']+|\\.)*)'}{ + my $_ = $1; + s/"/\\"/g; + s/\\'/'/g; + qq("$_"); + }ge; +} +my $caniuse = from_json($source, { +# allow_singlequote => 1, + allow_barekey => 1, +}); + +my %CSTATS = ( + n => 'di-b', + y => 'di-a', + a => 'di-d', + j => 'di-prop', + p => 'di-prop', + 'y x' => 'di-a', +); +my %CSTATUS = ( + unoff => 'di-rare', # unofficial + wd => 'di-b', # draft + pr => 'di-prop', # proposed + cr => 'di-d', # candidate + rec => 'di-a', # recommendation + ietf => 'di-a', # standard +); +my @browsers = qw(trident gecko webkit_saf presto); +unshift @{ $caniuse->{agents}->{gecko}->{versions} }, 2; + +print ''; +print '' x 2; +printf '', scalar @{ $caniuse->{agents}->{$_}->{versions} } for @browsers; +print "\n"; + +print ''; +print "\n"; + +for my $id (keys %{ $caniuse->{data} }) { + my $row = $caniuse->{data}->{$id}; + my $data = $row->{stats} or next; # skip metadata [summary] + printf '', $id; + printf '
$_" for qw(feature status); +printf '%s', scalar @{ $_->{versions} }, $_->{browser} + for map { $caniuse->{agents}->{$_} } @browsers; +print "
%s', $row->{description}, $row->{title}; + printf '%s', $caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $_ for $row->{status}; + for my $browser (@browsers) { + printf '%s', $CSTATS{ $data->{$browser}->{$_} }, $_ + for @{ $caniuse->{agents}->{$browser}->{versions} }; + } +} +print '
'; + +:> +
+ +
+ +
yes + almost + plugin or js + no +
+ +
+
    +
  • default style is + <:= defined $get{style} && 'set to ' :><:= $style :> +
+
+
+ -- 2.30.0