3 $Request ||= 'altgr/windows';
4 my $mode = lc $Request;
5 my $include = "keyboard/$mode.eng";
7 if (-e (my $page = "keyboard/$Request/index.inc.plp")) {
12 my $info = eval { Data($include) } || {};
13 warn "error in $include: ", @{$@} if ref $@;
14 $mode = $info->{title} // $mode;
16 my $showkeys //= !exists $get{keys} ? undef :
17 ($get{keys} ne '0' && ($get{keys} || 'always'));
19 '<!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->',
20 '<!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]-->',
21 !$showkeys ? '<style> .no {visibility:hidden} </style>' :
22 $showkeys eq 'ghost' ? '<style> .no, .alias {opacity:.5} </style>' : (),
23 '<script type="text/javascript" src="/keys.js?1.6" async></script>',
25 if ($Request =~ /^altgr/ and open my $cssinc, '<', 'keyboard/altgr.css') {
27 my $data = readline $cssinc;
28 push @keystyle, "<style>\n$data</style>";
32 title => "\L$mode\E keyboard cheat sheet",
33 version => $info->{version} || '0.1',
34 canonical => -e "$Request.plp" ? "/$Request" : undef, # historic shorthand
35 description => $info->{description} //
36 ["Keyboard cheat sheet for the default controls of $mode."],
37 keywords => [@{ $info->{keywords} // [] }, qw'
38 sheet cheat reference overview keyboard control commands shortkey
40 image => $info->{image},
41 stylesheet => [qw( light dark circus mono red )],
42 data => ["$include.inc.pl"],
47 "Requested keyboard <q>$mode</q> not available",
48 '404 request not found',
51 say "<h1>$mode keyboard</h1>";
52 say "<p>$_</p>" for $info->{intro} // ();
53 say "<h2>", $info->{mode}->{''}, " (default)</h2>"
54 if $info->{mode} and %{ $info->{mode} } > 1;
56 use Shiar_Sheet::Keyboard 2.08;
57 my $keys = Shiar_Sheet::Keyboard->new($info);
58 $keys->map($get{map}) or undef $get{map};
59 $keys->print_rows($get{rows} || $info->{moderows}, $info->{rows});
63 say '<div class="help">';
65 use List::MoreUtils qw( part );
66 my @gflags = part {/^g\d/} sort keys %{ $keys->{flag} };
68 say "\t", '<div class="left">';
69 $keys->print_legend('legend-types', $gflags[1]);
72 say "\t", '<div class="right">';
73 $keys->print_legend('legend-options', $gflags[0]);
76 say "\t\t", '<ul class="legend legend-set">';
78 say "\t\t<li>keyboard <strong>map</strong> is ",
79 ($get{map} ? 'set to ' : ''), "<em>$keys->{map}</em>";
80 say "\t\t<li><strong>keys</strong> are ",
81 "<em>", ($showkeys ? 'always shown' : 'hidden if unassigned'), "</em>",
82 (!defined $showkeys && ' by default');
83 say "\t\t<li>default <strong>style</strong> is ",
84 (defined $get{style} && 'set to '), "<em>$style</em>";