browser: parse support data first
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 8 Dec 2010 19:49:25 +0000 (20:49 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 15 Dec 2010 21:40:44 +0000 (22:40 +0100)
Move code right after header (no changes), so results can be used in intro
and during usage parse.

browser.plp

index b05286354b9099976b026a5749ba15ca2969e797..27dcb1b4d7213bdb45f181ce4253cf0b5eed8a87 100644 (file)
@@ -17,33 +17,8 @@ Html({
        data => ['browser-support.inc.pl'],
 });
 
-:>
-<h1>Browser compatibility</h1>
-
-<p id="intro">Alternate rendition of Fyrd's <a href="http://caniuse.com/">when can I use...</a> page<:
-my ($canihas, $usage);
-given ($get{usage} // 'wm') {
-       when (!$_) {
-               # none
-       }
-       when (!/^\w+$/) {
-               printf "<p>Invalid browser usage data request: <em>%s</em>",
-                       'identifier must be alphanumeric name or <q>0</q>';
-       }
-       $canihas = do "browser-usage-$_.inc.pl" or do {
-               printf "<p>Browser usage data not found: <em>%s</em>", $! || $@;
-               break;
-       };
-       $usage = $_;
-       my $ref = $canihas->{-source} || 'unknown';
-       $ref = sprintf '<a href="%s">%s</a>', $_, $ref for $canihas->{-url} || ();
-       $ref .= " $_" for $canihas->{-date} || ();
-       print "\nwith $ref browser usage statistics";
-}
-:>.
-</p>
+say "<h1>Browser compatibility</h1>\n";
 
-<:
 my $caniuse = do 'browser-support.inc.pl' or die $! || $@;
 $_->{verrelease} = {
        # mark last two (future) versions as unreleased, ensure current isn't
@@ -94,6 +69,32 @@ 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);
 
+print <<'';
+<p id="intro">Alternate rendition of Fyrd's <a href="http://caniuse.com/">when can I use...</a> page
+
+my ($canihas, $usage);
+given ($get{usage} // 'wm') {
+       when (!$_) {
+               # none
+       }
+       when (!/^\w+$/) {
+               printf "<p>Invalid browser usage data request: <em>%s</em>",
+                       'identifier must be alphanumeric name or <q>0</q>';
+       }
+       $canihas = do "browser-usage-$_.inc.pl" or do {
+               printf "<p>Browser usage data not found: <em>%s</em>", $! || $@;
+               break;
+       };
+       $usage = $_;
+       my $ref = $canihas->{-source} || 'unknown';
+       $ref = sprintf '<a href="%s">%s</a>', $_, $ref for $canihas->{-url} || ();
+       $ref .= " $_" for $canihas->{-date} || ();
+       print "\nwith $ref browser usage statistics";
+}
+:>.
+</p>
+
+<:
 $canihas ||= {
        map {
                $_ => +{