cc: page listing names for ISO-3166 country codes
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 28 Apr 2009 00:29:01 +0000 (00:29 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 28 Apr 2009 00:29:01 +0000 (00:29 +0000)
Initial data set up using:

perl -MDBIx::Simple -MData::Dump=pp -e 'pp({
DBIx::Simple->new("dbi:SQLite:dbname=locale.db")->query(q[
SELECT country.code_alpha2, country.name, continent.name
FROM country LEFT JOIN continent ON country.code_alpha2 = continent.country_code
ORDER BY country.code_alpha2
])->map_arrays(0)
})'

base.css
cc.inc.pl [new file with mode: 0644]
cc.plp [new file with mode: 0644]

index 759a3eab5148f745c47168acab29fbdfa941652f..ee92ec1abc7746cd275cabe4327158ffa7edb715 100644 (file)
--- a/base.css
+++ b/base.css
@@ -306,6 +306,15 @@ td.di-a       {background: #EFD} /* ascii */
 td.di-rare    {background: #EEE} /* disfavoured */
 td.di-invalid {background: #BBB} /* impossible */
 
+/* continents */
+td.c-af       {background: #FFC}
+td.c-eu       {background: #FDC}
+td.c-as       {background: #FDD}
+td.c-oc       {background: #EEDDF4}
+td.c-aa       {background: #E3E8FF}
+td.c-sa       {background: #DFF}
+td.c-na       {background: #DFD}
+
 /* hover effects */
 td.di-d,
 td.X:hover {cursor: help}
diff --git a/cc.inc.pl b/cc.inc.pl
new file mode 100644 (file)
index 0000000..703471b
--- /dev/null
+++ b/cc.inc.pl
@@ -0,0 +1,246 @@
+# perl -MDBIx::Simple -MData::Dump=pp -e 'pp({DBIx::Simple->new("dbi:SQLite:dbname=locale.db")->query("SELECT country.code_alpha2, country.name, continent.name FROM country LEFT JOIN continent ON country.code_alpha2 = continent.country_code ORDER BY country.code_alpha2")->map_arrays(0)})'
+{
+ad => ["Andorra", 'c-eu'],
+ae => ["United Arab Emirates", 'c-as'],
+af => ["Afghanistan", 'c-as'],
+ag => ["Antigua and Barbuda", 'c-na'],
+ai => ["Anguilla", 'c-na'],
+al => ["Albania", 'c-eu'],
+am => ["Armenia", 'c-eu'],
+an => ["Netherlands Antilles", 'c-oc'],
+ao => ["Angola", 'c-af'],
+aq => ["Antarctica", "c-aa"],
+ar => ["Argentina", 'c-sa'],
+as => ["American Samoa", 'c-na'],
+at => ["Austria", 'c-eu'],
+au => ["Australia", 'c-oc'],
+aw => ["Aruba", 'c-na'],
+az => ["Azerbaijan", 'c-eu'],
+ba => ["Bosnia and Herzegovina", 'c-eu'],
+bb => ["Barbados", 'c-na'],
+bd => ["Bangladesh", 'c-as'],
+be => ["Belgium", 'c-eu'],
+bf => ["Burkina Faso", 'c-oc'],
+bg => ["Bulgaria", 'c-eu'],
+bh => ["Bahrain", 'c-as'],
+bi => ["Burundi", 'c-af'],
+bj => ["Benin", 'c-af'],
+bm => ["Bermuda", 'c-na'],
+bn => ["Brunei Darussalam", 'c-as'],
+bo => ["Bolivia", 'c-sa'],
+br => ["Brazil", 'c-sa'],
+bs => ["Bahamas", 'c-na'],
+bt => ["Bhutan", 'c-as'],
+bv => ["Bouvet Island", 'c-oc'],
+bw => ["Botswana", 'c-af'],
+by => ["Belarus", 'c-eu'],
+bz => ["Belize", 'c-na'],
+ca => ["Canada", 'c-na'],
+cc => ["Cocos (Keeling) Islands", 'c-oc'],
+cd => ["Congo, the Democratic Republic of the", 'c-af'],
+cf => ["Central African Republic", 'c-af'],
+cg => ["Congo", 'c-af'],
+ch => ["Switzerland", 'c-eu'],
+ci => ["Cote D'Ivoire", 'c-af'],
+ck => ["Cook Islands", 'c-oc'],
+cl => ["Chile", 'c-sa'],
+cm => ["Cameroon", 'c-af'],
+cn => ["China", 'c-as'],
+co => ["Colombia", 'c-sa'],
+cr => ["Costa Rica", 'c-na'],
+cu => ["Cuba", 'c-na'],
+cv => ["Cape Verde", 'c-af'],
+cx => ["Christmas Island", 'c-oc'],
+cy => ["Cyprus", 'c-eu'],
+cz => ["Czech Republic", 'c-eu'],
+de => ["Germany", 'c-eu'],
+dj => ["Djibouti", 'c-af'],
+dk => ["Denmark", 'c-eu'],
+dm => ["Dominica", 'c-na'],
+do => ["Dominican Republic", 'c-na'],
+dz => ["Algeria", 'c-af'],
+ec => ["Ecuador", 'c-sa'],
+ee => ["Estonia", 'c-eu'],
+eg => ["Egypt", 'c-af'],
+eh => ["Western Sahara", 'c-af'],
+er => ["Eritrea", 'c-af'],
+es => ["Spain", 'c-eu'],
+et => ["Ethiopia", 'c-af'],
+fi => ["Finland", 'c-eu'],
+fj => ["Fiji", 'c-oc'],
+fk => ["Falkland Islands (Malvinas)", 'c-sa'],
+fm => ["Micronesia, Federated States of", 'c-oc'],
+fo => ["Faroe Islands", 'c-oc'],
+fr => ["France", 'c-eu'],
+fx => ["France, Metropolitan", 'c-eu'],
+ga => ["Gabon", 'c-af'],
+gb => ["United Kingdom", 'c-eu'],
+gd => ["Grenada", 'c-na'],
+ge => ["Georgia", 'c-eu'],
+gf => ["French Guiana", 'c-sa'],
+gh => ["Ghana", 'c-af'],
+gi => ["Gibraltar", 'c-eu'],
+gl => ["Greenland", 'c-eu'],
+gm => ["Gambia", 'c-af'],
+gn => ["Guinea", 'c-af'],
+gp => ["Guadeloupe", 'c-sa'],
+gq => ["Equatorial Guinea", 'c-af'],
+gr => ["Greece", 'c-eu'],
+gs => ["South Georgia and the South Sandwich Islands", 'c-oc'],
+gt => ["Guatemala", 'c-na'],
+gu => ["Guam", 'c-na'],
+gw => ["Guinea-Bissau", 'c-af'],
+gy => ["Guyana", 'c-sa'],
+hk => ["Hong Kong", 'c-as'],
+hm => ["Heard Island and McDonald Islands", 'c-oc'],
+hn => ["Honduras", 'c-na'],
+hr => ["Croatia", 'c-eu'],
+ht => ["Haiti", 'c-na'],
+hu => ["Hungary", 'c-eu'],
+id => ["Indonesia", 'c-as'],
+ie => ["Ireland", 'c-eu'],
+il => ["Israel", 'c-as'],
+in => ["India", 'c-as'],
+io => ["British Indian Ocean Territory", 'c-oc'],
+iq => ["Iraq", 'c-as'],
+ir => ["Iran, Islamic Republic of", 'c-as'],
+is => ["Iceland", 'c-eu'],
+it => ["Italy", 'c-eu'],
+jm => ["Jamaica", 'c-na'],
+jo => ["Jordan", 'c-as'],
+jp => ["Japan", 'c-as'],
+ke => ["Kenya", 'c-af'],
+kg => ["Kyrgyzstan", 'c-as'],
+kh => ["Cambodia", 'c-as'],
+ki => ["Kiribati", 'c-oc'],
+km => ["Comoros", 'c-af'],
+kn => ["Saint Kitts and Nevis", 'c-na'],
+kp => ["Korea, Democratic People's Republic of", 'c-as'],
+kr => ["Korea, Republic of", 'c-as'],
+kw => ["Kuwait", 'c-as'],
+ky => ["Cayman Islands", 'c-oc'],
+kz => ["Kazakhstan", 'c-as'],
+la => ["Lao People's Democratic Republic", 'c-as'],
+lb => ["Lebanon", 'c-as'],
+lc => ["Saint Lucia", 'c-na'],
+li => ["Liechtenstein", 'c-eu'],
+lk => ["Sri Lanka", 'c-as'],
+lr => ["Liberia", 'c-af'],
+ls => ["Lesotho", 'c-af'],
+lt => ["Lithuania", 'c-eu'],
+lu => ["Luxembourg", 'c-eu'],
+lv => ["Latvia", 'c-eu'],
+ly => ["Libyan Arab Jamahiriya", 'c-af'],
+ma => ["Morocco", 'c-af'],
+mc => ["Monaco", 'c-eu'],
+md => ["Moldova, Republic of", 'c-eu'],
+me => ["Republic of Montenegro", 'c-eu'],
+mg => ["Madagascar", 'c-af'],
+mh => ["Marshall Islands", 'c-oc'],
+mk => ["Macedonia, the Former Yugoslav Republic of", 'c-eu'],
+ml => ["Mali", 'c-af'],
+mm => ["Myanmar", 'c-as'],
+mn => ["Mongolia", 'c-as'],
+mo => ["Macao", 'c-as'],
+mp => ["Northern Mariana Islands", 'c-oc'],
+mq => ["Martinique", 'c-na'],
+mr => ["Mauritania", 'c-af'],
+ms => ["Montserrat", 'c-na'],
+mt => ["Malta", 'c-eu'],
+mu => ["Mauritius", 'c-af'],
+mv => ["Maldives", 'c-as'],
+mw => ["Malawi", 'c-af'],
+mx => ["Mexico", 'c-na'],
+my => ["Malaysia", 'c-as'],
+mz => ["Mozambique", 'c-af'],
+na => ["Namibia", 'c-af'],
+nc => ["New Caledonia", 'c-oc'],
+ne => ["Niger", 'c-af'],
+nf => ["Norfolk Island", 'c-oc'],
+ng => ["Nigeria", 'c-af'],
+ni => ["Nicaragua", 'c-na'],
+nl => ["Netherlands", 'c-eu'],
+no => ["Norway", 'c-eu'],
+np => ["Nepal", 'c-as'],
+nr => ["Nauru", 'c-oc'],
+nu => ["Niue", 'c-oc'],
+nz => ["New Zealand", 'c-oc'],
+om => ["Oman", 'c-as'],
+pa => ["Panama", 'c-na'],
+pe => ["Peru", 'c-sa'],
+pf => ["French Polynesia", 'c-oc'],
+pg => ["Papua New Guinea", 'c-oc'],
+ph => ["Philippines", 'c-as'],
+pk => ["Pakistan", 'c-as'],
+pl => ["Poland", 'c-eu'],
+pm => ["Saint Pierre and Miquelon", 'c-oc'],
+pn => ["Pitcairn", 'c-oc'],
+pr => ["Puerto Rico", 'c-na'],
+ps => ["Palestinian Territory, Occupied", 'c-as'],
+pt => ["Portugal", 'c-eu'],
+pw => ["Palau", 'c-oc'],
+py => ["Paraguay", 'c-sa'],
+qa => ["Qatar", 'c-as'],
+re => ["Reunion", 'c-oc'],
+ro => ["Romania", 'c-eu'],
+rs => ["Republic of Serbia", 'c-eu'],
+ru => ["Russian Federation", 'c-eu'],
+rw => ["Rwanda", 'c-af'],
+sa => ["Saudi Arabia", 'c-as'],
+sb => ["Solomon Islands", 'c-oc'],
+sc => ["Seychelles", 'c-af'],
+sd => ["Sudan", 'c-af'],
+se => ["Sweden", 'c-eu'],
+sg => ["Singapore", 'c-as'],
+sh => ["Saint Helena", 'c-oc'],
+si => ["Slovenia", 'c-eu'],
+sj => ["Svalbard and Jan Mayen", 'c-oc'],
+sk => ["Slovakia", 'c-eu'],
+sl => ["Sierra Leone", 'c-af'],
+sm => ["San Marino", 'c-eu'],
+sn => ["Senegal", 'c-af'],
+so => ["Somalia", 'c-af'],
+sr => ["Suriname", 'c-sa'],
+st => ["Sao Tome and Principe", 'c-af'],
+sv => ["El Salvador", 'c-na'],
+sy => ["Syrian Arab Republic", 'c-as'],
+sz => ["Swaziland", 'c-af'],
+tc => ["Turks and Caicos Islands", 'c-na'],
+td => ["Chad", 'c-af'],
+tf => ["French Southern Territories", 'c-oc'],
+tg => ["Togo", 'c-af'],
+th => ["Thailand", 'c-as'],
+tj => ["Tajikistan", 'c-as'],
+tk => ["Tokelau", 'c-oc'],
+tl => ["East Timor", 'c-as'],
+tm => ["Turkmenistan", 'c-as'],
+tn => ["Tunisia", 'c-af'],
+to => ["Tonga", 'c-oc'],
+tr => ["Turkey", 'c-as'],
+tt => ["Trinidad and Tobago", 'c-na'],
+tv => ["Tuvalu", 'c-oc'],
+tw => ["Taiwan, Province of China", 'c-as'],
+tz => ["Tanzania, United Republic of", 'c-af'],
+ua => ["Ukraine", 'c-eu'],
+ug => ["Uganda", 'c-af'],
+um => ["United States Minor Outlying Islands", 'c-na'],
+us => ["United States", 'c-na'],
+uy => ["Uruguay", 'c-sa'],
+uz => ["Uzbekistan", 'c-as'],
+va => ["Holy See (Vatican City State)", 'c-eu'],
+vc => ["Saint Vincent and the Grenadines", 'c-na'],
+ve => ["Venezuela", 'c-sa'],
+vg => ["Virgin Islands, British", 'c-na'],
+vi => ["Virgin Islands, U.S.", 'c-na'],
+vn => ["Vietnam", 'c-as'],
+vu => ["Vanuatu", 'c-oc'],
+wf => ["Wallis and Futuna", 'c-oc'],
+ws => ["Samoa", 'c-oc'],
+ye => ["Yemen", 'c-as'],
+yt => ["Mayotte", 'c-oc'],
+yu => ["Yugoslavia", 'c-eu'],
+za => ["South Africa", 'c-af'],
+zm => ["Zambia", 'c-af'],
+zr => ["Zaire", 'c-af'],
+zw => ["Zimbabwe", 'c-af'],
+}
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>