summaryrefslogtreecommitdiff
path: root/src/index-pages.sh
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-06-09 11:26:54 -0700
committerLouie Shprung <lshprung@scu.edu>2023-06-09 11:26:54 -0700
commita4784bbacc356d381ff833e1c181b75c30f776c6 (patch)
tree431af41591d4407546548f2f01c76b0bc5af5bd7 /src/index-pages.sh
parente397123c70d2ad564753f8aad1e1ac82276234f0 (diff)
Clean up, base more on dash-docset-template, dumb down entry types for name-index (consider all of these directives)
Diffstat (limited to 'src/index-pages.sh')
-rwxr-xr-xsrc/index-pages.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/index-pages.sh b/src/index-pages.sh
new file mode 100755
index 0000000..99531b7
--- /dev/null
+++ b/src/index-pages.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env sh
+
+# shellcheck source=./lib/create_table
+. "$(dirname "$0")"/lib/create_table
+# shellcheck source=./lib/insert
+. "$(dirname "$0")"/lib/insert
+
+DB_PATH="$1"
+shift
+
+get_title() {
+ FILE="$1"
+
+ pup -p -f "$FILE" 'title text{}' | \
+ tr -d \\n | \
+ sed 's/(GNU make)//g' | \
+ sed 's/\"/\"\"/g'
+}
+
+insert_pages() {
+ # Get title and insert into table for each html file
+ while [ -n "$1" ]; do
+ unset PAGE_NAME
+ unset PAGE_TYPE
+ PAGE_NAME="$(get_title "$1")"
+ PAGE_TYPE="Guide"
+ if [ -n "$PAGE_NAME" ]; then
+ insert "$DB_PATH" "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")"
+ fi
+ shift
+ done
+}
+
+create_table "$DB_PATH"
+insert_pages "$@"