keyboard/altgr: comparison index of sample keys [asSci1!ยน]
[sheet.git] / keyboard / altgr / index.inc.plp
1 <: # included from keyboard.plp
2 use 5.014;
3 use warnings;
4
5 my @incs = glob 'keyboard/altgr/*.eng.inc.pl';
6
7 Html({
8         title => "altgr keyboard cheat sheets",
9         version => '1.1',
10         description => [
11                 "Overview of alternate keyboard modes,",
12                 "offering extended Unicode characters if a modifier key",
13                 "(such as AltGr or option) is pressed.",
14         ],
15         keywords => [qw'
16                 sheet cheat reference overview keyboard altgr option
17         '],
18         image => 'data/keyboard/thumb/ibm-m.jpg',
19         stylesheet => [qw( light dark circus mono red )],
20         data => ['keyboard/altgr/index.inc.plp', @incs],
21         raw => <<'.',
22 <style>
23 table.keys {
24         display: inline-table;
25         margin: 0;
26 }
27 dt {
28         display: flex;
29         flex-direction: column;
30         justify-content: center;
31 }
32 dt img {
33         max-height: 10ex;
34 }
35 img {
36         object-fit: cover;
37         height: 100%;
38         vertical-align: middle;
39 }
40 </style>
41 .
42 });
43
44 :>
45 <h1>Extended keyboards</h1>
46
47 <p>Available key layouts with AltGr or similar modifier keys.</p>
48
49 <:
50 my @sample = split /(?<!\+)/, $get{sample} // 'asSci1!+1';
51 require Shiar_Sheet::Keyboard;
52
53 printf '<section class="%s">', @sample ? 'section' : 'gallery';
54 print '<dl>' if @sample;
55 my %idx = map {s/\Q.inc.pl\E$//; ($_ => eval{ Data($_) })} @incs;
56 for my $inc (sort {
57         $idx{$a}{category} cmp $idx{$b}{category} || $a cmp $b
58 } keys %idx) {
59         print @sample ? '<dt>' : '<figure>';
60         printf '<a href="/%s">', $inc =~ s/\.eng$//r;
61         my $table = $idx{$inc};
62         my $title = $table && $table->{title} || $inc;
63
64         unless (@sample) {
65                 if ($table and my $img = $table->{image}) {
66                         EscapeHTML $name = $table->{imagealt} // $img =~ m{.*/([^/.]*)};
67                         print qq{<img src="/$img" alt="$name" />};
68                 }
69                 printf '<figcaption>%s</figcaption>', $title;
70                 say '</a></figure>';
71         }
72         else {
73                 print $title;
74                 print '</a>';
75                 my $keys = Shiar_Sheet::Keyboard->new($table);
76                 print join(' ', map { $keys->{key}{$_} =~ s/\s.*//r } grep {$_} keys %{$_})
77                         for $keys->{mode} || ();
78                 say '<dd><table class="keys big"><tr>';
79                 $keys->print_key('', $_, $keys->{def}{''}{$_} // 'ni') for @sample;
80                 print '</tr></table>';
81                 say '</dd>';
82         }
83 }
84 :></dl></section>
85