summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos <christos@bauherren.ovh>2025-01-02 18:42:52 +0000
committerChristos <christos@bauherren.ovh>2025-01-02 18:42:52 +0000
commit39e43de0ea89943ff60dc40faaffa5c419256593 (patch)
tree9b4b9479b7a11f54f4b9ae96fa1b00250282a2d8
parent56097fdf8b3d35330164968ac8d7b953a2e297ea (diff)
Added horizontal sidebar script and CSS
-rw-r--r--cork-hbar.rc65
-rw-r--r--src/horizontal-sidebar.css29
2 files changed, 94 insertions, 0 deletions
diff --git a/cork-hbar.rc b/cork-hbar.rc
new file mode 100644
index 0000000..e3ca727
--- /dev/null
+++ b/cork-hbar.rc
@@ -0,0 +1,65 @@
+#!/bin/rc
+
+path=(. /bin)
+
+req_p=`{echo -n $REQUEST_URI }
+
+fn run {
+ lpaf=home$REQUEST_URI
+ rpafs='/'; wd='/'; ifs='/';
+ arg = `{echo -n $REQUEST_URI}
+ if (test -d $lpaf) {
+ lpaf=$lpaf^'i'
+ }
+ for (i in $arg) {
+ wd=$wd^$i
+ rpafs=($rpafs $wd)
+ wd=$wd'/'
+ }
+http_content_type='text/html'
+echo Content-Type: $http_content_type
+ echo;
+ for (h in $bar) { $$h }
+ mh $lpaf.md
+}
+
+
+fn sbar {
+ echo -n 'insert html preamble'
+ ls -F home/./$rpafs | sed -e 's,/+\./+,/,g' \
+ -e '/\/i\.(md)$/d' \
+ -e 's/\.(md)$//' -e 's!^home!!' | sort | awk -F/ '
+ function p(x, y, s) { for(i=0; i < x-y; i+=1) printf s }
+ BEGIN { lNF=2; printf "<ul>" }
+ {
+ d = ""
+ if(match($0, "/$"))
+ d = "/"
+ sub("/$", "") # Strip trailing / for dirs so NF is consistent
+
+ p(NF, lNF, "<ul>» 「"); p(lNF, NF, "」</ul>")
+ lNF = NF
+
+ bname = $NF d
+ path = $0 d
+ gsub(/[\-_]/, " ", bname)
+
+ # To avoid false matches add trailing / even for plain files to act as delimiter
+ pa = path
+ gsub(/[^\/]$/, "&/", pa)
+
+ if(index(ENVIRON["req_p"] "/", pa) == 1)
+ printf "<li><a href="path" class=\"c\">"bname"</a>"
+ else
+ printf "<li><a href="path">"bname"</a>"
+ }
+ END { p(lNF, 2, "</ul>"); printf "</ul></nav><hr><article>" }'
+}
+
+fn add {
+ _l = $1^_^$#$1
+ $_l = $*(2-)
+ $1 = ($$1 $_l)
+}
+
+add bar sbar; run
diff --git a/src/horizontal-sidebar.css b/src/horizontal-sidebar.css
new file mode 100644
index 0000000..4692463
--- /dev/null
+++ b/src/horizontal-sidebar.css
@@ -0,0 +1,29 @@
+ul {
+ display: inline;
+}
+li {
+ list-style-position: inside;
+ display: inline;
+}
+ ul {
+ margin: 0;
+ padding: 0.3em;
+ list-style-type: none;
+ list-style-image: none;
+ border: 0;
+}
+ li {
+ display: inline;
+ white-space: nowrap;
+ line-height: 1.6em;
+}
+ ul li a {
+ margin: 0;
+ padding: 0.1em 1ex 0.1em 1ex;
+ text-decoration: none;
+ font-size: 1em;
+ border: 0;
+}
+ul > ul {
+ padding-left: 40px; /* Padding for nested <ul> inside the first <ul> */
+}