diff options
author | Louie S <louie@example.com> | 2024-06-20 16:56:29 -0400 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-06-20 16:56:29 -0400 |
commit | 75a9d380fdeb015e09a93e875a9a9edca9f16344 (patch) | |
tree | fd5e768e36e304724507e2fffb37dd1ebe13e852 /src | |
parent | 31a4726c13d6000dc3c97d088d6f027ef1d1fb5d (diff) |
Update Makefile
Diffstat (limited to 'src')
-rwxr-xr-x | src/index.sh | 26 |
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 "$@" |