writing: fix non-verbose annotation setup
[sheet.git] / nethack.plp
index bb0be709369898e8132cd1d384a66b7593f7b998..3115e28d696a12121aad0da7a55218a169c3b31e 100644 (file)
@@ -1,77 +1,21 @@
-<:
-use utf8;
-use strict;
-use warnings;
-no  warnings 'qw';  # you know what you doing
-no  warnings 'uninitialized';  # save some useless checks for more legible code
-
-our $VERSION = '1.0';
-
-our $ascii = 0;
-if (exists $get{ascii}) {
-       $ascii = $get{ascii} ne '0';  # manual override
-} elsif (defined $ENV{HTTP_ACCEPT_CHARSET}) {
-       $ascii = 1;
-       for (split q{,}, $ENV{HTTP_ACCEPT_CHARSET}) {
-               $ascii = 0, last if $_ eq '*' or m{utf-?8}i;
-       }
-}
-
-my $charset = $ascii ? 'us-ascii' : 'utf-8';
-my $ctype = "text/html; charset=$charset";
-$header{content_type} = $ctype;
+<(common.inc.plp)><:
+
+Html({
+       title => 'nethack cheat sheet',
+       version => 'v1.1',
+       description => [
+               "Keyboard overview sheet for the Nethack console RPG game,",
+               "describing the default controls.",
+       ],
+       keywords => [qw'
+               nethack rogue game control controls sheet reference overview keyboard
+       '],
+       charset => $sign{charset},
+       stylesheet => [qw'light dark circus mono red terse'],
+       keys => 1,
+});
 
-:><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
-<head>
-<title>nethack cheat sheet</title>
-<meta http-equiv="content-type" content="<:= $ctype :>">
-<link rel="stylesheet" type="text/css" media="all" href="base.css">
-<!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->
-<!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]--><:
-       my %styles = map {$_ => $_} qw(dark circus mono terse);
-       our $style = exists $get{style} && $styles{$get{style}} || 'light';
-       printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
-       ) for keys %styles;
-
-       our $showkeys = exists $get{keys} && $get{keys} ne '0';
-       print "\n<style> .no {visibility:hidden} </style>" unless $showkeys;
-       print "\n<style> .no, .alias {opacity:.5} </style>"
-               if $showkeys and $get{keys} eq 'ghost';
 :>
-
-<script><!--
-function setmode(classname) {
-       // set style for each #rows>li>ul>li to display:none unless it matches classname
-       var showclass = classname ? ' '+classname+'(?!\\w)' : '^$';
-       var parentskip = /^keys/;
-       var row = document.getElementById('rows').firstChild;
-       do {
-               if (row.tagName == 'LI' && row.firstChild.tagName == 'UL'
-               && !row.firstChild.className.match(parentskip)) {
-                       var el = row.firstChild.firstChild;
-                       if (el) do {
-                               if (el.tagName == 'LI') {
-                                       el.style.display = el.className.match(showclass) ? 'block' : 'none';
-                               }
-                       } while (el = el.nextSibling);
-               }
-       } while (row = row.nextSibling);
-
-       // update H2 to reflect the first part of a currently active (but hidden) H3
-       var h3s = document.getElementsByTagName('H3');
-       for (var i = 0; i < h3s.length; i++) {
-               if (h3s[i].parentNode.style.display != 'block') continue;
-               document.getElementsByTagName('H2')[0].innerHTML = h3s[i].firstChild.data;
-       }
-} // setmode
-//--></script>
-
-<body>
-
 <h1>NetHack cheat sheet</h1>
 
 <h2>normal gameplay</h2>
@@ -80,31 +24,18 @@ function setmode(classname) {
 
 <li class="row">
        <ul class="keys omni">
-       <li class="mo" onclick="setmode()"><b>Esc</b>
-               <!-- not as static anymore, but never bothered; just see ^[ -->
+       <li class="me chr27" onclick="setmode()"><b>Esc</b>
+               <!-- static reset button, even though it's not (officially) in the game -->
        </ul>
 </li>
 
 <:
-our %sign = (
-       arg    => $ascii ? '.' : '·',  # described as 'dot'
-       argi   => $ascii ? ':' : ':',
-       motion => $ascii ? '|' : '↕',
-       alias  => $ascii ? 'see: ' : '»',
-       up     => $ascii ? 'up'    : '▲',
-       right  => $ascii ? 'right' : '▶',
-       down   => $ascii ? 'down'  : '▼',
-       left   => $ascii ? 'left'  : '◀',
-       sep    => $ascii ? '*'     : '•',
-       _      => exists $get{ascii} && !$ascii ? "\x{200b}" : '<wbr>',
-               # use the correct ZWNJ only when unicode is forced on
-               # default to use unofficial html for best support
-);
-
-use Shiar_Sheet::Keyboard;
-my $keys = Shiar_Sheet::Keyboard->new({do 'nethack.inc.pl'});
+use Shiar_Sheet::Keyboard 2;
+my $info = do 'nethack.eng.inc.pl' or die $@;
+$info->{def} = do 'nethack.inc.pl';
+my $keys = Shiar_Sheet::Keyboard->new($info);
 $keys->map($get{map}) or undef $get{map};
-$keys->print_rows($get{static});
+$keys->print_rows($get{rows} || '4321-421', [3,2,1,0]);
 :>
 </ul>
 
@@ -113,8 +44,6 @@ $keys->print_rows($get{static});
 <div class="help">
        <div class="left">
                <dl class="legend legend-types">
-               <dt class="ci">
-                       <dd>
                <dt class="pm">direction
                        <dd>Direction to move to or target a command (<:= $sign{motion} :>).
                <dt class="po">move
@@ -127,8 +56,6 @@ $keys->print_rows($get{static});
                        <dd>Display invertory menu.
                <dt class="mv">menu
                        <dd>Enters some other menu.
-               <dt class="me">
-                       <dd>
                </dl>
        </div>
 
@@ -136,18 +63,18 @@ $keys->print_rows($get{static});
                <dl class="legend legend-options">
                <dt>key<:= $sign{arg} :>
                        <dd>Commands with a dot need at least one argument afterwards.
-               <dt>key<:= $sign{motion} :>
-                       <dd>Requires a direction afterwards.
                <dt>key<:= $sign{argi} :>
                        <dd>Asks for an inventory item.
+               <dt>key<:= $sign{argm} :>
+                       <dd>Requires a direction afterwards.
                </dl>
 
                <ul class="legend legend-set">
                <li>keyboard <strong>map</strong> is
                        <:= $get{map} ? 'set to ' : '' :><em><:= $keys->{map} :></em>
                <li><strong>ascii</strong> mode is
-                       <:= exists $get{ascii} && 'forced ' :><em><:=
-                               $ascii ? 'on' : 'off' :></em>
+                       <:= defined $sign{-ascii} && 'forced ' :><em><:=
+                               $sign{-ascii} ? 'on' : 'off' :></em>
                <li><strong>keys</strong> are
                        <em><:= $showkeys ? 'always shown' : 'hidden if unassigned' :></em><:=
                                !exists $get{keys} && ' by default' :>
@@ -157,16 +84,3 @@ $keys->print_rows($get{static});
        </div>
 </div>
 
-<p class="footer">
-       <a href="http://sheet.shiar.nl/nethack">sheet.shiar.nl<strong>/nethack</strong></a>
-       <a href="git://dev.shiar.net/vi-cheat"><:= "v$VERSION" :></a>
-       created by Shiar <:= $sign{sep} :>
-       <a title="Licensed under the GNU Affero General Public License, version 3"
-          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> <:= $sign{sep} :>
-       last update <:
-               use Time::Format qw(time_format);
-               print time_format('yyyy-mm-dd', (stat 'nethack.inc.pl')[9]);
-       :>
-</p>
-
-</html>