use warnings;
use utf8;
-my @incs = glob 'keyboard/altgr/*.eng.inc.pl';
+my $dirbase = 'keyboard/altgr';
+my $indexfile = "$dirbase/index";
Html({
title => "altgr keyboard cheat sheets",
keywords => [qw'
sheet cheat reference overview keyboard altgr option
'],
- image => 'data/keyboard/thumb/ibm-m.jpg',
+ image => "$dirbase/thumb/ibm-m.jpg",
stylesheet => [qw( light dark circus mono red )],
- data => ['keyboard/altgr/index.inc.plp', @incs],
+ data => ["$dirbase/index.inc.plp", "$indexfile.inc.pl"],
raw => <<'.',
<style>
.keys.cmp {
<p>Overview of available key layouts with AltGr or similar modifier keys.</p>
<:
+my $idx = Data($indexfile);
+my @incs;
+push @incs, @{ $idx->{$_} } for @{ $idx->{default} };
+
my @sample = split /(?<!\+)/, $get{sample} // 'asSci1!+1';
require Shiar_Sheet::Keyboard;
use List::Util qw( uniq max );
print "<th>$_" for @sample;
say '</tr></thead>';
}
-my %idx = map {s/\Q.inc.pl\E$//; ($_ => eval{ Data($_) })} @incs;
+my %idx = map {($_ => scalar eval{ Data("$dirbase/$_.eng") })} @incs;
my $most = max(map { scalar keys %{$_->{def}{''}} } values %idx);
-for my $inc (sort {
- $idx{$a}{category} cmp $idx{$b}{category} || $a cmp $b
-} keys %idx) {
+for my $inc (@incs) {
print @sample ? '<tr><th>' : '<figure>';
- printf '<a href="/%s">', $inc =~ s/\.eng$//r;
+ printf '<a href="/%s">', "$dirbase/$inc";
my $table = $idx{$inc};
my $title = $table && $table->{title} || $inc;
$inventory{$_}++ for grep { /^g[2-9]/ } map { s/ (?!ext).*//r }
values %{ $keys->{def}{$mode} };
print '<span class=graph>';
- print "<label>$_</label>" for $keys->{key}{$mode} =~ s/\s.*//r || ();
+ printf '<label>%s</label>', s/\s.*//r for $keys->{key}{$mode} || ();
for my $g (sort keys %inventory) {
printf '<span class="%s" style="width:%.0f%%" title="%3$d %4$s"> %s</span>',
$g, $_/$most*100, $_,
say '</span>';
}
print "\t<td class=ni>";
- print join ' ', map { $caticon{$_} // () } split m{/}, $keys->{category};
+ print join ' ', map { $caticon{$_} // () } split m{/}, $keys->{category} // '';
say '';
$keys->print_key('', $_, ($keys->{def}{''}{$_} // 'ni') =~ s/ mode\S*//r)
for @sample;