cc: page listing names for ISO-3166 country codes
[sheet.git] / cc.plp
diff --git a/cc.plp b/cc.plp
new file mode 100644 (file)
index 0000000..48b9910
--- /dev/null
+++ b/cc.plp
@@ -0,0 +1,87 @@
+<:
+use utf8;
+use strict;
+use warnings;
+use open IO => ':utf8';
+
+our $VERSION = 'v1.0';
+
+$header{content_type} = 'text/html; charset=utf-8';
+
+:><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+<title>country code cheat sheet</title>
+<meta http-equiv="content-type" content="utf-8">
+<link rel="stylesheet" type="text/css" media="all" href="/base.css">
+</head>
+
+<body>
+<h1>Country codes</h1>
+
+<:
+my $cc = do 'cc.inc.pl';
+
+sub quote {
+       local $_ = shift;
+       s/"/&quot;/g;
+       s/</&lt;/g;
+       s/>/&gt;/g;
+       return $_;
+}
+
+{
+       printf '<table class="glyphs">';
+       print '<col>';
+       for my $section (qw{thead}) {
+               print "<$section><tr><th>↱";
+               print '<th>', $_ for 'a' .. 'z';
+               print "\n";
+       }
+       print '<tbody>';
+       for my $row ('a' .. 'z') {
+               print '<tr><th>', $row;
+               for my $col ('a' .. 'z') {
+                       my $code = $row . $col;
+                       my $country = $cc->{$code} or do {
+                               print $code =~ /^x|^q[m-z]|^aa|^zz/ ? '<td class="X Co">' : '<td>';
+                               next;
+                       };
+                       my $img = sprintf '<img src="/flag/%s.png" alt="%s">', $code, $code
+                               if -e "flag/$code.png";
+                       printf "\n".'<td class="%s" title="%s">%s',
+                               $img ? 'X '.$country->[1] : '', quote($country->[0]), $img;
+               }
+               print "\n";
+       }
+       print "</table>\n";
+}
+
+:>
+<hr>
+
+<div class="legend">
+       <table class="glyphs"><tr>
+       <td class="X c-af">africa
+       <td class="X c-eu">europe
+       <td class="X c-as">asia
+       <td class="X c-oc">oceania
+       <td class="X c-aa">antarctica
+       <td class="X c-sa">south america
+       <td class="X c-na">north america
+       <td class="X Xi">reserved
+       <td class="X Co">user-assigned
+       </table>
+</div>
+
+<p class="footer">
+       <a href="/" rel="home">sheet.shiar.nl</a>/charset
+       <a href="git://git.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
+       created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
+       <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
+          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
+</p>
+
+</html>