From b0060d114740f866161b5871976e41278acacfd2 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 5 Dec 2010 19:25:22 +0100 Subject: [PATCH] browser: source metadata in usage include --- browser.plp | 46 ++++++++++++++++++-------------- tools/convert-stats-wikimedia.pl | 7 +++++ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/browser.plp b/browser.plp index a4af534..2de8458 100644 --- a/browser.plp +++ b/browser.plp @@ -17,8 +17,18 @@ Html({

Browser compatibility

Alternate view of Fyrd's when can I use... page -with Wikimedia -browser usage statistics.

+<: +my $canihas = do 'browser-usage.inc.pl' + or printf "

Browser usage data not found: %s.

\n", $! || $@; + +print "with $_ browser usage statistics." for map { + my $ref = $_->{-source} || 'unknown'; + $ref = sprintf '%s', $_, $ref for $_->{-url} || (); + $ref .= " $_" for $_->{-date} || (); + $ref +} $canihas || (); +:> +

<: @@ -52,24 +62,20 @@ if (my ($somerow) = values %{ $caniuse->{data} }) { my @browsers = grep { $versions{$_} } qw(trident gecko webkit_saf ios_saf webkit_chr android presto op_mob op_mini); -my $canihas = do 'browser-usage.inc.pl' || do { - printf "

Browser usage data not found: %s.

\n", $_ - for $! || $@; - +{ - map { - $_ => +{ - map { - ($_->[4] => 0 ), # future - ($_->[3] => .5), # next - ($_->[0] => 5 ), # past - ($_->[1] => 10 ), # previous - ($_->[2] => 30 ), # current - } $caniuse->{agents}->{$_}->{versions} - } - } @browsers - }; # fallback hash based on release semantics -}; -my $scorediv = (max(map { sum(values %$_) } values %$canihas) // 1) / 100; +$canihas ||= { + map { + $_ => +{ + map { + ($_->[4] => 0 ), # future + ($_->[3] => .5), # next + ($_->[0] => 5 ), # past + ($_->[1] => 10 ), # previous + ($_->[2] => 30 ), # current + } $caniuse->{agents}->{$_}->{versions} + } + } @browsers +}; # fallback hash based on release semantics +my $scorediv = (max(map { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100; print ''; print '' x 3; diff --git a/tools/convert-stats-wikimedia.pl b/tools/convert-stats-wikimedia.pl index 42faf20..5ee59ca 100644 --- a/tools/convert-stats-wikimedia.pl +++ b/tools/convert-stats-wikimedia.pl @@ -3,6 +3,13 @@ use 5.010; use strict; use warnings; our %count; our $mobile; +if (m{
} .. m{}) { + $count{-url} = 'http://stats.wikimedia.org/archive/squid_reports/'; + $count{-source} = 'Wikimedia'; + $count{-date} = $1 if m{ period: (?:\d+ )?(\w+ \d+) }; + next; +} + # select relevant columns />Browser versions(.*)/ ... m{
} && last or next; my ($tr, $id, $count2, $count) = split /(?:<[^>]*>)+/; -- 2.30.0