From: Mischa POSLAWSKY Date: Fri, 15 Dec 2023 22:59:26 +0000 (+0100) Subject: keyboard: move ?keys code and styling from common include X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/26a71f36c68773b18095911e99be7294cbd66f39 keyboard: move ?keys code and styling from common include --- diff --git a/common.inc.plp b/common.inc.plp index d282f09..2976cbe 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -50,8 +50,6 @@ BEGIN { our $Request //= decode_utf8($ENV{PATH_INFO} =~ s{^/}{}r); our $style; -our $showkeys //= !exists $get{keys} ? undef : - ($get{keys} ne '0' && ($get{keys} || 'always')); $header{content_type} = 'text/html; charset=utf-8'; @@ -149,15 +147,6 @@ sub Html { '', ); - # optional amends - push @{ $meta->{raw} }, ( - '', - '', - !$showkeys ? '' : - $showkeys eq 'ghost' ? '' : (), - '', - ) if $meta->{keys}; - my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x; PLP_START { diff --git a/keyboard.plp b/keyboard.plp index 8bbe8f7..4a49ebb 100644 --- a/keyboard.plp +++ b/keyboard.plp @@ -7,6 +7,16 @@ my $info = eval { Data($include) } || {}; warn "error in $include: ", @{$@} if ref $@; $mode = $info->{title} // $mode; +my $showkeys //= !exists $get{keys} ? undef : + ($get{keys} ne '0' && ($get{keys} || 'always')); +my @keystyle = ( + '', + '', + !$showkeys ? '' : + $showkeys eq 'ghost' ? '' : (), + '', +); + Html({ title => "\L$mode\E keyboard cheat sheet", version => $info->{version} || '0.1', @@ -16,8 +26,8 @@ Html({ sheet cheat reference overview keyboard control commands shortkey '], stylesheet => [qw( light dark circus mono red )], - keys => 1, data => ["$include.inc.pl"], + raw => \@keystyle, }); %{$info} or Abort(