cc: names by default
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 13 Oct 2009 00:32:40 +0000 (00:32 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 13 Oct 2009 22:38:42 +0000 (22:38 +0000)
Abbreviated country names make for a better sheet.
Flag images have to be requested manually by getting ?show.

Makes most glyph styling apply to any table, including this one.
Enlarged text and uniform width remains .glyphs-specific, but colouring and
borders should be good to enforce for all (future) tables.

base.css
cc.inc.pl
cc.plp
dark.css

index 50e12f2998a0fbaf952bd49ad5ed123ce5033656..a488e979f1cb6693a829868282b50540e0c160cf 100644 (file)
--- a/base.css
+++ b/base.css
@@ -152,25 +152,30 @@ ul.keys.ctrl li b small { /* meta key indicator */
        font-weight: normal; /* nice and subtle */
 }
 
-/* character table */
+/* tables */
 
 li table {
        float: left;
        position: relative; /* prevents buggy hovering if table-caption present in gecko */
 }
 
-table.glyphs {
+table {
        border-collapse: collapse;
 }
-.glyphs thead th, .glyphs td {
-       text-align: center;
-       width: 1.6em; /* regular interval */
-}
-.glyphs th, .glyphs td {
+th, td {
        border-color: #778;
        border: 1px solid #888;
        background: #DDD;
 }
+thead th, td {
+       text-align: center;
+}
+
+/* character table */
+
+.glyphs thead th, .glyphs td {
+       width: 1.6em; /* regular interval */
+}
 .glyphs tbody td {
        font-size: 112%;
 }
@@ -186,22 +191,22 @@ table.glyphs {
 
 /* table headers */
 
-.glyphs th,
-.glyphs thead td {
+th,
+thead td {
        border: 0;
        background: transparent !important;
 }
 .glyphs thead td {
        width: auto; /* no glyph cells in header */
 }
-.glyphs th {
+th {
        padding: 0 0.2em;
 }
-.diinfo .glyphs th {
+.diinfo th {
        font-size: 50%; /* mostly insignificant here */
        font-weight: normal;
 }
-.diinfo .glyphs tbody th {
+.diinfo tbody th {
        text-align: right; /* variable width so keep near cells */
        padding: 0 0.5em;
 }
index 786655afd8f72c7f06426d0c5ef6bde9b1625c11..8be81c9a8237d8a420f7e536b3481f0360cc1a48 100644 (file)
--- a/cc.inc.pl
+++ b/cc.inc.pl
@@ -1,6 +1,6 @@
 # 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)})'
 {
-ac => ["Ascension (dependency of Saint Helena)", 'c-oc Xr', 'sh'],
+ac => ["Ascension (dependency of Saint Helena)", 'c-oc Xr', undef, 'sh'],
 ad => ["Andorra", 'c-eu'],
 ae => ["United Arab Emirates", 'c-as'],
 af => ["Afghanistan", 'c-as'],
@@ -48,7 +48,7 @@ cl => ["Chile", 'c-sa'],
 cm => ["Cameroon", 'c-af'],
 cn => ["China", 'c-as'],
 co => ["Colombia", 'c-sa'],
-cp => ["Clipperton (French possession)", 'c-na Xr', 'fr'],
+cp => ["Clipperton (French possession)", 'c-na Xr', undef, 'fr'],
 cr => ["Costa Rica", 'c-na'],
 cu => ["Cuba", 'c-na'],
 cv => ["Cape Verde", 'c-af'],
@@ -58,11 +58,11 @@ cz => ["Czech Republic", 'c-eu'],
 de => ["Germany", 'c-eu'],
 dj => ["Djibouti", 'c-af'],
 dk => ["Denmark", 'c-eu'],
-dg => ["Diego Garcia (British Territory)", 'c-as Xr', 'io'],
+dg => ["Diego Garcia (British Territory)", 'c-as Xr', undef, 'io'],
 dm => ["Dominica", 'c-na'],
 do => ["Dominican Republic", 'c-na'],
 dz => ["Algeria", 'c-af'],
-ea => ["Ceuta and Melilla (Spanish cities outside EU territory)", 'c-af Xr', 'es'],
+ea => ["Ceuta and Melilla (Spanish cities outside EU territory)", 'c-af Xr', undef, 'es'],
 ec => ["Ecuador", 'c-sa'],
 ee => ["Estonia", 'c-eu'],
 eg => ["Egypt", 'c-af'],
@@ -77,7 +77,7 @@ fk => ["Falkland Islands (Malvinas)", 'c-sa'],
 fm => ["Micronesia, Federated States of", 'c-oc'],
 fo => ["Faroe Islands", 'c-oc'],
 fr => ["France", 'c-eu'],
-fx => ["Metropolitan France", 'c-eu Xr', 'fr'],
+fx => ["Metropolitan France", 'c-eu Xr', undef, 'fr'],
 ga => ["Gabon", 'c-af'],
 gb => ["United Kingdom", 'c-eu'],
 gd => ["Grenada", 'c-na'],
@@ -107,7 +107,7 @@ id => ["Indonesia", 'c-as'],
 ie => ["Ireland", 'c-eu'],
 il => ["Israel", 'c-as'],
 in => ["India", 'c-as'],
-io => ["British Indian Ocean Territory", 'c-oc'],
+io => ["British Indian Ocean Territory", 'c-oc', 'Chagos'],
 iq => ["Iraq", 'c-as'],
 ir => ["Iran, Islamic Republic of", 'c-as'],
 is => ["Iceland", 'c-eu'],
@@ -121,12 +121,12 @@ 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'],
+kp => ["Korea, Democratic People's Republic of", 'c-as', "North Korea"],
+kr => ["Korea, Republic of", 'c-as', "South Korea"],
 kw => ["Kuwait", 'c-as'],
 ky => ["Cayman Islands", 'c-oc'],
 kz => ["Kazakhstan", 'c-as'],
-la => ["Lao People's Democratic Republic", 'c-as'],
+la => ["Lao People's Democratic Republic", 'c-as', "Lao"],
 lb => ["Lebanon", 'c-as'],
 lc => ["Saint Lucia", 'c-na'],
 li => ["Liechtenstein", 'c-eu'],
@@ -136,11 +136,11 @@ ls => ["Lesotho", 'c-af'],
 lt => ["Lithuania", 'c-eu'],
 lu => ["Luxembourg", 'c-eu'],
 lv => ["Latvia", 'c-eu'],
-ly => ["Libyan Arab Jamahiriya", 'c-af'],
+ly => ["Libyan Arab Jamahiriya", 'c-af', "Libya"],
 ma => ["Morocco", 'c-af'],
 mc => ["Monaco", 'c-eu'],
 md => ["Moldova, Republic of", 'c-eu'],
-me => ["Republic of Montenegro", 'c-eu'],
+me => ["Montenegro, Republic of", 'c-eu'],
 mg => ["Madagascar", 'c-af'],
 mh => ["Marshall Islands", 'c-oc'],
 mk => ["Macedonia, the Former Yugoslav Republic of", 'c-eu'],
@@ -189,8 +189,8 @@ 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'],
+rs => ["Serbia, Republic of", 'c-eu'],
+ru => ["Russian Federation", 'c-eu', "Russia"],
 rw => ["Rwanda", 'c-af'],
 sa => ["Saudi Arabia", 'c-as'],
 sb => ["Solomon Islands", 'c-oc'],
@@ -231,16 +231,16 @@ tw => ["Taiwan, Province of China", 'c-as'],
 tz => ["Tanzania, United Republic of", 'c-af'],
 ua => ["Ukraine", 'c-eu'],
 ug => ["Uganda", 'c-af'],
-uk => ["(United Kingdom)", 'c-eu Xr', 'gb'],
-um => ["United States Minor Outlying Islands", 'c-na'],
+uk => ["(United Kingdom)", 'c-eu Xr', undef, 'gb'],
+um => ["United States Minor Outlying Islands", 'c-na', 'U.S. isl.'],
 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'],
+vg => ["Virgin Islands, British", 'c-na', "British Virgin"],
+vi => ["Virgin Islands, U.S.", 'c-na', "U.S. Virgin"],
 vn => ["Vietnam", 'c-as'],
 vu => ["Vanuatu", 'c-oc'],
 wf => ["Wallis and Futuna", 'c-oc'],
diff --git a/cc.plp b/cc.plp
index 584884d74f43cbc9465d3b7dc249d08ad5b0a8bd..08a2341b2dc67434b827155f4b499b585c56c482 100644 (file)
--- a/cc.plp
+++ b/cc.plp
@@ -33,7 +33,7 @@ sub quote {
 }
 
 {
-       printf '<table class="glyphs ccmap">';
+       printf '<table class="mcmap">';
        print '<col>';
        for my $section (qw{thead}) {
                print "<$section><tr><th>↱";
@@ -49,11 +49,32 @@ sub quote {
                                print $code =~ /^x|^q[m-z]|^aa|^zz/ ? '<td class="X Co">' : '<td>';
                                next;
                        };
-                       $code = $country->[2] if defined $country->[2];
-                       my $img = sprintf '<img src="/flag/%s.png" alt="%s">', $code, $code
-                               if -e "flag/$code.png";
+                       my ($name, $class, $short, $ref) = @$country;
+                       $ref ||= $code;
+                       local $_ = $ref;
+                       if (exists $get{show}) {
+                               my $img = "flag/$ref.png";
+                               $_ = sprintf '<img src="/%s" alt="%s">', $img, $ref if -e $img;
+                       }
+                       else {
+                               $_ = $short || $name;
+                               s/,.*//;
+                               s/(?<=.)\(.*\)\s*//;
+                               s/ republic\b//gi;
+                               s/ islands?\b//gi;
+                               s/\bthe //g;
+                               s/ and / & /g;
+                               s/\bsaint /st /gi;
+                               s/South /S-/g;
+                               s/North /N-/g;
+                               s/New /n./g;
+                               s/(\S)(\S+)-/$1-/g;  # strip most chars preceding dash
+                               s/(\S{4}[b-df-hj-np-tv-xz])(\S{2,})/$1./g;  # abbreviate (at consonant)
+                               $_ = quote($_);
+                       }
+                       $name =~ s/([^,]*), (.*)/$2 $1/;
                        printf "\n".'<td class="%s" title="%s">%s',
-                               $img ? 'X '.$country->[1] : '', quote($country->[0]), $img;
+                               $_ ? 'X '.$class : '', quote("$code: $name"), $_;
                }
                print "\n";
        }
index b33e7da6469aa74c72fce320468c98ce61271aa4..732a5633c4a7cf3b1607137730c09ada7160a014 100644 (file)
--- a/dark.css
+++ b/dark.css
@@ -49,7 +49,7 @@ dl.legend-options dt {background: #333}
 
 /* character properties */
 
-.glyphs th, .glyphs td {
+th, td {
        border-color: #333;
        background: #181818;
 }