summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordweller <dweller@cabin.digital>2024-03-08 19:53:47 +0200
committerdweller <dweller@cabin.digital>2024-03-08 19:53:47 +0200
commitd66f88febd3f19afd6b0ed0bee347e8f7db3e086 (patch)
tree0a931a777591fa6d4edaaeccefa27e4d2d75d090
parent12da9560c792ae5f3beb31dfdf5f41d70d03e4ab (diff)
fix formatting and parsing when using self-compiled mandoc that produced different HTML output
-rw-r--r--TODO6
-rw-r--r--common.php6
-rw-r--r--index.php8
-rw-r--r--js/lmmtfy.js2
-rw-r--r--search.php14
-rw-r--r--style/man.css15
-rw-r--r--style/search.css6
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 @@
<form action="/search.php">
<div id="query_wrap">
<div id="query_icon"></div>
- <input id="query" type='search' value='<?php if($action === 'lmmtfy') echo $query;?>' name='query' autocorrect="off" autocapitalize="none" required autofocus/>
- <button id="def" type='submit' value='man' name='action' class="btn-def" aria-hidden="true" tabindex="-1"></button>
+ <input id="query" type='search' value='<?php if($action === 'lmmtfy') echo $query;?>' name='query' autocorrect="off" autocapitalize="none" required autofocus/>
+ <button id="btn_def" type='submit' value='man' name='action' class="btn-def" aria-hidden="true" tabindex="-1"></button>
<input type="checkbox" id="query_opts_toggle"/>
<div id="query_opts">
<span class="query_opt" title="section">-s</span>
@@ -88,8 +88,8 @@
<span id="qfill"></span>
</div>
<div>
- <button id="mank" type='submit' value='apropos' name='action' title="apropos(1)">man -k</button>
- <button id="man" type='submit' value='man' name='action' title="Feeling lucky, punk?">man</button>
+ <button id="btn_mank" type='submit' value='apropos' name='action' title="apropos(1)">man -k</button>
+ <button id="btn_man" type='submit' value='man' name='action' title="Feeling lucky, punk?">man</button>
</div>
</form>
<?php
diff --git a/js/lmmtfy.js b/js/lmmtfy.js
index 0f9951d..ee15a2f 100644
--- a/js/lmmtfy.js
+++ b/js/lmmtfy.js
@@ -9,7 +9,7 @@
const dom_query = document.getElementById("query");
const dom_sect = document.getElementById("sect");
const dom_arch = document.getElementById("arch");
-const dom_man = document.getElementById("man");
+const dom_man = document.getElementById("btn_man");
const dom_opts = document.getElementById("query_opts_toggle");
const query = dom_query.value;
diff --git a/search.php b/search.php
index 5be46b6..ae84036 100644
--- a/search.php
+++ b/search.php
@@ -48,8 +48,8 @@
<nav id="search_pane">
<form>
<div id="query_wrap">
- <input id="query" type='searcg' value='<?=$query;?>' name='query' autocorrect="off" autocapitalize="none" required/>
- <button id="def" type='submit' value='man' name='action' class="btn-def" aria-hidden="true" tabindex="-1"></button>
+ <input id="query" type='searcg' value='<?=$query;?>' name='query' autocorrect="off" autocapitalize="none" required/>
+ <button id="btn_def" type='submit' value='man' name='action' class="btn-def" aria-hidden="true" tabindex="-1"></button>
<input type="checkbox" id="query_opts_toggle"/>
<div id="query_opts">
<span class="query_opt" title="section">-s</span>
@@ -79,8 +79,8 @@
?>
</select>
</div>
- <button id="mank" type='submit' value='apropos' name='action' title="apropos(1)">-k</button>
- <button id="man" type='submit' value='man' name='action' title="Feeling lucky, punk?" class="btn-acc">
+ <button id="btn_mank" type='submit' value='apropos' name='action' title="apropos(1)">-k</button>
+ <button id="btn_man" type='submit' value='man' name='action' title="Feeling lucky, punk?" class="btn-acc">
<div id="query_icon"></div>
</button>
</div>
@@ -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.*\>.+\((.+)\)\<\/td>/iu', $lines[4], $sect);
+ preg_match('/.+<span class="head-ltitle">.+\((.).*\)<\/span>/iu', $lines[1], $sect);
$url = "$root/?query=". urlencode($query) ."&ampsection=". 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;