]> git.plutz.net Git - shellwiki/blobdiff - searchindex.sh
automatically enable --titles in pagelist macro in multilingual setups
[shellwiki] / searchindex.sh
index 66f2704e97472657c7b1c5e97f53fd34043e6e24..162fad12e72109af68e6ad3365142112202affb6 100755 (executable)
@@ -1,6 +1,6 @@
 #!/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
@@ -14,7 +14,7 @@
 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-export _EXEC="${0%/*}/" _DATA="."
+export _EXEC="${_EXEC:-${0%/*}/}" _DATA="${_DATA:-.}"
 verb="" v=0 cmd="" force="" location=""
 
 help() {
@@ -59,14 +59,15 @@ help() {
        Options:
 
        --exec INSTALL_DIR
-           Point to the location of your shellwiki installation. This will
-           default to the path at which the script is called, if it can be
-           determined.
+           Point to the location of your shellwiki installation. Without
+           this optin, the location will be read from the environments
+           variable "\$_EXEC", or will default to the path at which the
+           script is called, if it can be determined.
 
        --data SITE_DIR
            Point to the location of your site installation. I.e. the directory
-           containing your "pages/" and "index/" dir. Defaults to working
-           directory.
+           containing your "pages/" and "index/" dir. Defaults to the
+           environment variable "\$_DATA" or the working directory.
 
        --force
            Add pages to index even if they seem to be indexed already.
@@ -86,6 +87,7 @@ help() {
 while [ $# -gt 0 ]; do case $1 in
   --exec|-e) _EXEC="${2%/}"; shift 2;;
   --data|-d) _DATA="${2%/}"; shift 2;;
+  --location) location="${2}"; shift 2;;
   --verbose|-v) verb=true; shift 1;;
   --force) force=true; shift 1;;
   --help) help 0 2>&1;;
@@ -133,7 +135,7 @@ prune() {
 }
 
 index() {
-  export PATH_INFO="" _DATE="$(date +%s)"
+  export PATH_INFO="" _DATE="$(date +%s)" SEARCH_INDEX=true
 
   if [ "$location" ]; then
     location="${location#/}" location="${location%/}"
@@ -150,6 +152,7 @@ index() {
   then
       [ "$verb" ] && printf "%${v}s\r%s\r" "" "$PATH_INFO" >&2
       v="${#PATH_INFO}"
+      cd -- "$_DATA/pages/$PATH_INFO"
       "$_EXEC/parsers/40_indexer.sh" <"$_DATA/pages/$PATH_INFO/#page.md" >/dev/null
     fi
   done