new: auto-indexing
authorNiki Roo <niki@nikiroo.be>
Fri, 28 Feb 2025 12:32:40 +0000 (13:32 +0100)
committerNiki Roo <niki@nikiroo.be>
Fri, 28 Feb 2025 12:32:40 +0000 (13:32 +0100)
index.md
mkdocs/site
update-index.sh [new file with mode: 0755]

index 6c5b97e1ed9e2371611deb374d14703ba53219e1..d27f4c7c275a11d9421b2f343bf3371caf70479f 100644 (file)
--- a/index.md
+++ b/index.md
@@ -6,6 +6,8 @@ Some documentation:
     * [Framagenda](/Phone/Framagenda)
 * Politique:
     * [Le droit d'asile (France)](/Politique/Le%20droit%20d%27asile%20pour%20les%20nuls)
+* History
+    * [Ancient Rome](/Ancient%20Rome)
 * Tech:
     * [Dark-Olympic](/Tech/color-theme)
     * [Git](/Tech/git)
index 58d1fed77c89324fdbef2900ddbadf385255b293..8282b241103eaeaaef0be2497b7e16855943b8f0 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 58d1fed77c89324fdbef2900ddbadf385255b293
+Subproject commit 8282b241103eaeaaef0be2497b7e16855943b8f0
diff --git a/update-index.sh b/update-index.sh
new file mode 100755 (executable)
index 0000000..6979f30
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# ready to use url-link to the given file
+url() {
+       echo "$1" | sed 's: :%20:g' | sed 's:\.md$::g'
+}
+
+work() {
+       read ln || return
+       
+       title="$1"
+       lvl="$2"
+       pre="$3"
+       
+       cur_lvl=$(echo "$ln" | sed 's:[^/]::g' | wc -c)
+
+       if [ $cur_lvl -gt $lvl ]; then
+               title=$(dirname "$ln")
+               title=$(basename "$title")
+               if [ "$pre" = "" ]; then
+                       pre="*"
+               else
+                       pre="    $pre"
+               fi
+       elif [ $cur_lvl -lt $lvl ]; then
+               pre=$(echo "$pre" | cut -c5-)
+       fi
+       
+       if [ "$ln" = "" ]; then
+               echo Some documentation:
+               echo
+       elif [ -d "$ln" ]; then
+               name=$(basename "$ln")
+               if [ -e "$ln/README.md" ]; then
+                       echo "$pre [$name](/$(url "$ln")): "
+               else
+                       echo "$pre $name:"
+               fi
+       else
+               name=$(basename "$ln" .md)
+               name=$(head -n1 "$ln" | cut -c3-)
+               if [ "$name" != README ]; then
+                       echo "$pre [$name](/$(url "$ln"))"
+               fi
+       fi
+       
+       work "$title" "$cur_lvl" "$pre"
+}
+
+cd $(dirname "$0")
+find . | cut -c3- | grep -Ev '(index.md)|(^mkdocs)|(^\.)|(\.sh$)' \
+       | work "" -1 ""
+