#!/bin/sh
-# Copyright 2023 Paul Hänsch
+# Copyright 2023 - 2024 Paul Hänsch
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-DOC="${PATH_INFO%/}/" P="$_DATA/pages${DOC}" I="$_DATA/index/"
+P="$PWD" I="$_DATA/index/" _DATE=$((_DATE + 1))
-if [ -f "$P/#index.flag" -a ! "$P/#page.md" -nt "$P/#index.flag" ] || [ ! -d "$P" ]; then
+if [ "$SEARCH_INDEX" != true ] || [ ! -d "$P" ] || \
+ [ -f "$P/#index.flag" -a ! "$P/#index.flag" -ot "$P/#page.md" ]
+then
cat
exit 0
fi
touch -d "@$_DATE" "$P/#index.flag"
mkdir -p "$I"
+DOC="$(STRING "${P#"$_DATA/pages"}")"
{ cat; printf \\n; } \
| while IFS='' read -r line; do
| while read -r num total freq word; do
[ "$word" ] || continue
printf "%i %s %f %i %i\n" \
- "$_DATE" "$(STRING "$DOC")" \
- "$freq" "$num" "$total" \
+ "$_DATE" "$DOC" "$freq" "$num" "$total" \
>>"$I/$word"
done