diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | src/index.sh | 65 |
4 files changed, 34 insertions, 38 deletions
@@ -1,3 +1,3 @@ -/GNU_Make.docset -/GNU_Make.tgz +/GNU_Autoconf_Archive.docset +/GNU_Autoconf_Archive.tgz /tmp @@ -10,7 +10,7 @@ INDEX_FILE = $(RESOURCES_DIR)/docSet.dsidx ICON_FILE = $(DOCSET_DIR)/icon.png ARCHIVE_FILE = $(DOCSET_NAME).tgz -MANUAL_VERSION = 2022.09.03 +MANUAL_VERSION = 2023.02.20 MANUAL_URL = https://ftp.gnu.org/gnu/autoconf-archive/autoconf-archive-$(MANUAL_VERSION).tar.xz MANUAL_SRC = tmp/autoconf-archive-$(MANUAL_VERSION) MANUAL_SRC_MAKEFILE = $(MANUAL_SRC)/Makefile @@ -12,5 +12,6 @@ Requirements: - any POSIX-compliant shell - curl - make +- pup - sqlite3 - texinfo diff --git a/src/index.sh b/src/index.sh index 4d4b12b..05c066e 100755 --- a/src/index.sh +++ b/src/index.sh @@ -1,29 +1,20 @@ #!/usr/bin/env sh -DB_PATH="$1" -shift +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);" +} get_title() { FILE="$1" - PATTERN="<title>.*\(Autoconf Archive\).*</title>" - - #Find pattern in file - grep -Eo "$PATTERN" "$FILE" | - #Remove tag - sed 's/<[^>]*>//g' | \ - #Remove '(automake)' + pup -p -f "$FILE" 'title text{}' | \ sed 's/(Autoconf Archive)//g' | \ - #Remove trailing space - sed 's/[ ]*$//g' | \ - #Replace '&' with '&' - sed 's/&/&/g' | \ - #Replace '<' with '<' - sed 's/</</g' + sed 's/\"/\"\"/g' } get_type() { - FILE="$(basename $1)" + FILE="$(basename "$1")" MACRO_PATTERN="^ax_" if echo "$FILE" | grep -q "$MACRO_PATTERN"; then @@ -39,23 +30,27 @@ insert() { sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"$PAGE_PATH\");" } -# 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);" - -# 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")" - if [ -n "$PAGE_NAME" ]; then - PAGE_TYPE="$(get_type "$1")" - #get_type "$1" - if [ -z "$PAGE_TYPE" ]; then - PAGE_TYPE="Guide" +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")" + if [ -n "$PAGE_NAME" ]; then + PAGE_TYPE="$(get_type "$1")" + #get_type "$1" + if [ -z "$PAGE_TYPE" ]; then + PAGE_TYPE="Guide" + fi + #echo "$PAGE_TYPE" + insert "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")" fi - #echo "$PAGE_TYPE" - insert "$PAGE_NAME" "$PAGE_TYPE" "$(basename "$1")" - fi - shift -done + shift + done +} + +DB_PATH="$1" +shift + +create_table +insert_pages "$@" |