keyboard/altgr: comparison index of sample keys [asSci1!ยน]
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 27 Jan 2024 18:10:13 +0000 (19:10 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 29 Jan 2024 17:17:48 +0000 (18:17 +0100)
Replace pretty but non-descriptive gallery (unless explicitly requested).

keyboard/altgr/index.inc.plp

index e4ed3d87324f55ad25f061033ae6a1902737eab1..057d6a9e053b2b1a738d08a00f7a92cfe43346c6 100644 (file)
@@ -6,7 +6,7 @@ my @incs = glob 'keyboard/altgr/*.eng.inc.pl';
 
 Html({
        title => "altgr keyboard cheat sheets",
-       version => '1.0',
+       version => '1.1',
        description => [
                "Overview of alternate keyboard modes,",
                "offering extended Unicode characters if a modifier key",
@@ -15,13 +15,27 @@ Html({
        keywords => [qw'
                sheet cheat reference overview keyboard altgr option
        '],
+       image => 'data/keyboard/thumb/ibm-m.jpg',
        stylesheet => [qw( light dark circus mono red )],
        data => ['keyboard/altgr/index.inc.plp', @incs],
        raw => <<'.',
 <style>
+table.keys {
+       display: inline-table;
+       margin: 0;
+}
+dt {
+       display: flex;
+       flex-direction: column;
+       justify-content: center;
+}
+dt img {
+       max-height: 10ex;
+}
 img {
        object-fit: cover;
        height: 100%;
+       vertical-align: middle;
 }
 </style>
 .
@@ -30,25 +44,42 @@ img {
 :>
 <h1>Extended keyboards</h1>
 
-<p>Representative images of available layouts
-with AltGr or similar modifier keys.</p>
+<p>Available key layouts with AltGr or similar modifier keys.</p>
 
-<section class="gallery"><:
+<:
+my @sample = split /(?<!\+)/, $get{sample} // 'asSci1!+1';
+require Shiar_Sheet::Keyboard;
+
+printf '<section class="%s">', @sample ? 'section' : 'gallery';
+print '<dl>' if @sample;
 my %idx = map {s/\Q.inc.pl\E$//; ($_ => eval{ Data($_) })} @incs;
 for my $inc (sort {
        $idx{$a}{category} cmp $idx{$b}{category} || $a cmp $b
 } keys %idx) {
-       print '<figure>';
+       print @sample ? '<dt>' : '<figure>';
        printf '<a href="/%s">', $inc =~ s/\.eng$//r;
-       if ($table = $idx{$inc}) {
-               if (my $img = $table->{image}) {
+       my $table = $idx{$inc};
+       my $title = $table && $table->{title} || $inc;
+
+       unless (@sample) {
+               if ($table and my $img = $table->{image}) {
                        EscapeHTML $name = $table->{imagealt} // $img =~ m{.*/([^/.]*)};
                        print qq{<img src="/$img" alt="$name" />};
                }
-               $inc = $table->{title};
+               printf '<figcaption>%s</figcaption>', $title;
+               say '</a></figure>';
+       }
+       else {
+               print $title;
+               print '</a>';
+               my $keys = Shiar_Sheet::Keyboard->new($table);
+               print join(' ', map { $keys->{key}{$_} =~ s/\s.*//r } grep {$_} keys %{$_})
+                       for $keys->{mode} || ();
+               say '<dd><table class="keys big"><tr>';
+               $keys->print_key('', $_, $keys->{def}{''}{$_} // 'ni') for @sample;
+               print '</tr></table>';
+               say '</dd>';
        }
-       printf '<figcaption>%s</figcaption>', $inc;
-       say '</a></figure>';
 }
-:></section>
+:></dl></section>