From 75a9d380fdeb015e09a93e875a9a9edca9f16344 Mon Sep 17 00:00:00 2001 From: Louie S Date: Thu, 20 Jun 2024 16:56:29 -0400 Subject: Update Makefile --- src/index.sh | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'src') 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 "$@" -- cgit