diff options
Diffstat (limited to 'src/index.sh')
-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 "$@" |