From d66f88febd3f19afd6b0ed0bee347e8f7db3e086 Mon Sep 17 00:00:00 2001 From: dweller Date: Fri, 8 Mar 2024 19:53:47 +0200 Subject: fix formatting and parsing when using self-compiled mandoc that produced different HTML output --- TODO | 6 +++--- common.php | 6 +++--- index.php | 8 ++++---- js/lmmtfy.js | 2 +- search.php | 14 +++++++------- style/man.css | 15 +++++++++++---- style/search.css | 6 +++--- 7 files changed, 32 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index f3cb261..0d645ff 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,6 @@ TODO: decouple PHP from HTML, merge index.php and search.php. Just have templat TODO: change GET query vars to be shorter or switch to a different schema TODO: populate all the static pages, like About and stuff FIXME: flash of white on load for /search.php, also stuck loading with no args -TODO: sgrep TODO -FIXME: on manup.sh the mandoc generates slightly different HTML, like the headers. Needs CSS fixes. - This also breaks section # parsing I think. +TODO: sgrep TODO/FIXME +TODO: Maybe use a default arch to speed up search? Could try to detect arch via user-agent in PHP. +TODO: Minify, consolidate diff --git a/common.php b/common.php index b9bc1d4..3114683 100644 --- a/common.php +++ b/common.php @@ -7,10 +7,10 @@ */ - $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; + $manbin = "/home/dwlr/nfs_red/deb_man/mandoc/bin/man"; + $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST']; $manpath = "/home/dwlr/nfs_red/deb_man/mans/bookworm/man"; - require "$manpath/archs.php"; - + require "$manpath/archs.php"; $action = trim($_GET['action'] ?? null); $query = trim($_GET['query'] ?? null); diff --git a/index.php b/index.php index 6b2cc12..6c8a8ed 100644 --- a/index.php +++ b/index.php @@ -54,8 +54,8 @@
- ' name='query' autocorrect="off" autocapitalize="none" required autofocus/> - + ' name='query' autocorrect="off" autocapitalize="none" required autofocus/> +
-s @@ -88,8 +88,8 @@
- - + +
- - + +
-s @@ -79,8 +79,8 @@ ?>
- - +
@@ -103,13 +103,13 @@ $found_man = false; if($action === "man") { - $res = exec("man -M $manpath -T html -O fragment,toc $arg_section " + $res = exec("$manbin -M $manpath -T html -O fragment,toc $arg_section " . escapeshellarg($query), $lines, $ret); if($ret === 0) { /* TODO: maybe hardcoding a line isn't such a good idea, but I don't wanna regex the * whole thing */ - preg_match('/\.+\((.+)\)\<\/td>/iu', $lines[4], $sect); + preg_match('/.+.+\((.).*\)<\/span>/iu', $lines[1], $sect); $url = "$root/?query=". urlencode($query) ."&section=". urlencode($sect[1]) ."&arch=". urlencode($arch) ."&action=lmmtfy"; @@ -139,7 +139,7 @@ if(($action === "apropos") || !$found_man) { - $res = exec("man -M $manpath $arg_section -k " . escapeshellarg($query), $lines, $ret); + $res = exec("$manbin -M $manpath $arg_section -k " . escapeshellarg($query), $lines, $ret); if($ret === 0) { $n = count($lines); diff --git a/style/man.css b/style/man.css index e61ad91..7915ccc 100644 --- a/style/man.css +++ b/style/man.css @@ -138,9 +138,6 @@ tr:first-of-type td:last-of-type { border-top-right-radius: 0.5em; } tr:last-of-type td:first-of-type { border-bottom-left-radius: 0.5em; } tr:last-of-type td:last-of-type { border-bottom-right-radius: 0.5em; } -table.head, table.foot, -td.head-ltitle, td.head-vol, td.head-rtitle, -td.foot-date, td.foot-os, table.Nm, table.Nm tbody, table.Nm tbody tr, table.Nm tbody tr td { word-break: break-word; @@ -148,7 +145,17 @@ table.Nm, table.Nm tbody, table.Nm tbody tr, table.Nm tbody tr td border: none !important; } -table.head, table.foot { display: table; } +.head, .foot +{ + width: 100%; + display: grid; + grid-template-columns: 1fr 2fr 1fr; + grid-template-rows: 1fr; +} + +.head-ltitle, .foot-left { text-align: left; } +.head-vol, .foot-date { text-align: center; } +.head-rtitle, .foot-os { text-align: right; } pre { diff --git a/style/search.css b/style/search.css index 9f8a88f..835c612 100644 --- a/style/search.css +++ b/style/search.css @@ -49,7 +49,7 @@ #logo { margin-right: 1.5rem; } -#man, #mank +#btn_man, #btn_mank { flex-shrink: 0; height: 4em; @@ -59,14 +59,14 @@ border-radius: 0; } -#mank +#btn_mank { background-color: var(--qbgh); color: var(--fg-light); border-color: transparent; } -#man:hover, #mank:hover +#btn_man:hover, #btn_mank:hover { text-decoration: underline; box-shadow: none; -- cgit v1.2.3