diff options
-rw-r--r-- | config.mk | 5 | ||||
-rwxr-xr-x | src/index-pages.py | 25 | ||||
-rwxr-xr-x | src/index-pages.sh | 43 |
3 files changed, 28 insertions, 45 deletions
@@ -10,6 +10,7 @@ $(DOCUMENTS_DIR): $(RESOURCES_DIR) $(MANUAL_FILE) mkdir -p $@ tar -x -z -f $(MANUAL_FILE) -C $@ -$(INDEX_FILE): $(SOURCE_DIR)/src/index-pages.sh $(DOCUMENTS_DIR) +$(INDEX_FILE): $(SOURCE_DIR)/src/index-pages.py $(SCRIPTS_DIR)/gnu/index-terms-colon.py $(DOCUMENTS_DIR) rm -f $@ - $(SOURCE_DIR)/src/index-pages.sh $@ $(DOCUMENTS_DIR)/*.html + $(SOURCE_DIR)/src/index-pages.py $@ $(DOCUMENTS_DIR)/*.html + $(SCRIPTS_DIR)/gnu/index-terms-colon.py Entry $@ $(DOCUMENTS_DIR)/Index.html diff --git a/src/index-pages.py b/src/index-pages.py new file mode 100755 index 0000000..6dee7d0 --- /dev/null +++ b/src/index-pages.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import os +import re +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts")) +from create_table import create_table +from get_title import get_title +from insert import insert + +def insert_page(db_path, html_path): + page_name = get_title(html_path) + page_name = page_name.replace('(GNU Coding Standards)', '') + + page_type = "Guide" + + insert(db_path, page_name, page_type, os.path.basename(html_path)) + +if __name__ == '__main__': + db_path = sys.argv[1] + + create_table(db_path) + for html_path in sys.argv[2:]: + insert_page(db_path, html_path) diff --git a/src/index-pages.sh b/src/index-pages.sh deleted file mode 100755 index d6b4c88..0000000 --- a/src/index-pages.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env sh - -# shellcheck source=../../../scripts/create_table.sh -. "$(dirname "$0")"/../../../scripts/create_table.sh -# shellcheck source=../../../scripts/get_title.sh -. "$(dirname "$0")"/../../../scripts/get_title.sh -# shellcheck source=../../../scripts/insert.sh -. "$(dirname "$0")"/../../../scripts/insert.sh - -DB_PATH="$1" -shift - -#get_title() { -# FILE="$1" -# -# PATTERN="<title>.*\(GNU Coding Standards\).*</title>" -# -# #Find pattern in file -# grep -Eo "$PATTERN" "$FILE" | -# #Remove tag -# sed 's/<[^>]*>//g' | \ -# #Remove '(automake)' -# sed 's/(GNU Coding Standards)//g' | \ -# #Remove trailing space -# sed 's/[ ]*$//g' | \ -# #Replace '&' with '&' -# sed 's/&/&/g' -#} - -insert_pages() { - # Get title and insert into table for each html file - while [ -n "$1" ]; do - unset PAGE_NAME - PAGE_NAME="$(get_title "$1" | sed 's/(GNU Coding Standards)//g')" - if [ -n "$PAGE_NAME" ]; then - insert "$DB_PATH" "$PAGE_NAME" "Guide" "$(basename "$1")" - fi - shift - done -} - -create_table "$DB_PATH" -insert_pages "$@" |