ccb7fb63fc3388bacad4d944102fda5cc2e28906
[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 .keys.cmp {
24         display: inline-table; /* centered */
25         float: none;
26         margin: 0;
27         border-collapse: separate;
28         border-spacing: 2px;
29         border-spacing: .4vw; /* inline td margin equivalent */
30 }
31 .keys.big.cmp tbody {
32         font-size: 150%;
33 }
34 .keys.cmp tbody {
35         display: table-row-group;
36 }
37 .keys.cmp tr {
38         display: table-row;
39 }
40 .keys.cmp tr > * {
41         display: table-cell;
42         position: static; /* under sticky thead */
43 }
44 .keys.cmp tbody th {
45         padding-right: 1ex;
46         text-align: right;
47 }
48
49 img {
50         object-fit: cover;
51         height: 100%;
52         vertical-align: middle;
53 }
54 </style>
55 .
56 });
57
58 :>
59 <h1>Extended keyboards</h1>
60
61 <p>Overview of available key layouts with AltGr or similar modifier keys.</p>
62
63 <:
64 my @sample = split /(?<!\+)/, $get{sample} // 'asSci1!+1';
65 require Shiar_Sheet::Keyboard;
66
67 printf '<section class="%s">', @sample ? 'section' : 'gallery';
68 if (@sample) {
69         print '<table class="big keys cmp">';
70         print '<thead><tr><th>';
71         print "<th>$_" for @sample;
72         say '</tr></thead>';
73 }
74 my %idx = map {s/\Q.inc.pl\E$//; ($_ => eval{ Data($_) })} @incs;
75 for my $inc (sort {
76         $idx{$a}{category} cmp $idx{$b}{category} || $a cmp $b
77 } keys %idx) {
78         print @sample ? '<tr><th>' : '<figure>';
79         printf '<a href="/%s">', $inc =~ s/\.eng$//r;
80         my $table = $idx{$inc};
81         my $title = $table && $table->{title} || $inc;
82
83         unless (@sample) {
84                 if ($table and my $img = $table->{image}) {
85                         EscapeHTML $name = $table->{imagealt} // $img =~ m{.*/([^/.]*)};
86                         print qq{<img src="/$img" alt="$name" />};
87                 }
88                 printf '<figcaption>%s</figcaption>', $title;
89                 say '</a></figure>';
90         }
91         else {
92                 print $title;
93                 print '</a>';
94                 my $keys = Shiar_Sheet::Keyboard->new($table);
95                 print '<br>', join(' ', map { $keys->{key}{$_} =~ s/\s.*//r } grep {$_} keys %{$_})
96                         for $keys->{mode} || ();
97                 $keys->print_key('', $_, $keys->{def}{''}{$_} // 'ni') for @sample;
98                 say '</tr>';
99         }
100 }
101 print '</table>' if @sample;
102 :></section>
103