summaryrefslogtreecommitdiff
path: root/src/index.sh
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-06-20 16:56:29 -0400
committerLouie S <louie@example.com>2024-06-20 16:56:29 -0400
commit75a9d380fdeb015e09a93e875a9a9edca9f16344 (patch)
treefd5e768e36e304724507e2fffb37dd1ebe13e852 /src/index.sh
parent31a4726c13d6000dc3c97d088d6f027ef1d1fb5d (diff)
Update Makefile
Diffstat (limited to 'src/index.sh')
-rwxr-xr-xsrc/index.sh26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/index.sh b/src/index.sh
index 05c066e..0e583e4 100755
--- a/src/index.sh
+++ b/src/index.sh
@@ -1,9 +1,12 @@
#!/usr/bin/env sh
-create_table() {
- sqlite3 "$DB_PATH" "CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"
- sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);"
-}
+# shellcheck source=../../../scripts/create_table.sh
+. "$(dirname "$0")"/../../../scripts/create_table.sh
+# shellcheck source=../../../scripts/insert.sh
+. "$(dirname "$0")"/../../../scripts/insert.sh
+
+DB_PATH="$1"
+shift
get_title() {
FILE="$1"
@@ -22,14 +25,6 @@ get_type() {
fi
}
-insert() {
- NAME="$1"
- TYPE="$2"
- PAGE_PATH="$3"
-
- sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"$PAGE_PATH\");"
-}
-
insert_pages() {
# Get title and insert into table for each html file
while [ -n "$1" ]; do
@@ -43,14 +38,11 @@ insert_pages() {
PAGE_TYPE="Guide"
fi
#echo "$PAGE_TYPE"
- insert "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")"
+ insert "$DB_PATH" "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")"
fi
shift
done
}
-DB_PATH="$1"
-shift
-
-create_table
+create_table "$DB_PATH"
insert_pages "$@"