Add base dir variable for easier publishing - postreich - Unnamed repository; edit this file 'description' to name the repository.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit 02d1ce0c4810e687bb9328f110964262260f49e2
 (DIR) parent 38d93a291fc4336ff48f355dc61ee65ef4f2813c
 (HTM) Author: Scarlett McAllister <no+reply@roygbyte.com>
       Date:   Mon, 29 Jan 2024 21:43:40 -0400
       
       Add base dir variable for easier publishing
       
       Diffstat:
         M src/geomyidae/api/common            |       2 ++
         M src/geomyidae/index.dcgi            |       4 ++--
         M src/geomyidae/sendmail.dcgi         |      10 +++++-----
       
       3 files changed, 9 insertions(+), 7 deletions(-)
       ---
 (DIR) diff --git a/src/geomyidae/api/common b/src/geomyidae/api/common
       @@ -1,5 +1,7 @@
        #!/bin/sh
        
       +BASE_DIR="" # Leave empty if run from server root. Otherwise, show
       +            # directory with a leading slash but no trailing slash.
        PUBKEYS="pubkeys"
        TEMPLATES="templates"
        MAILBOXES="mailboxes"
 (DIR) diff --git a/src/geomyidae/index.dcgi b/src/geomyidae/index.dcgi
       @@ -15,8 +15,8 @@
        echo 'Welcome to Postreich, a gopher powered mail service. Here you can
        setup a mailbox and receive mail over the gopher protocol.'
        echo
       -echo "[1|Send mail|sendmail.dcgi|localhost|70]"
       -echo "[1|Get mail|getmail.dcgi|localhost|70]"
       +echo "[1|Send mail|$BASE_DIR/sendmail.dcgi|localhost|70]"
       +echo "[1|Get mail|$BASE_DIR/getmail.dcgi|localhost|70]"
        
        echo '
        
 (DIR) diff --git a/src/geomyidae/sendmail.dcgi b/src/geomyidae/sendmail.dcgi
       @@ -11,19 +11,19 @@ query=$( find_value_in_args "query" "$path" )
        
        choose_mailbox() {
            ls -x1 "api/$MAILBOXES" \
       -        | awk -v t="$template" \
       -              '{ printf "[1|%s|/sendmail.dcgi?handle=%s?template=%s|localhost|70]\n", $1, $1, t }'
       +        | awk -v t="$template" -v base_dir="$BASE_DIR" \
       +              '{ printf "[1|%s|/%ssendmail.dcgi?handle=%s?template=%s|localhost|70]\n", $1, base_dir, $1, t }'
        }
        
        choose_template() {
            ls -x1 "api/$TEMPLATES" \
                | xargs -d '\n' -I x cat "api/$TEMPLATES/"x"/info" \
       -        | awk -F '\t' -v h="$handle" \
       -              '{ printf "[1|%s|/sendmail.dcgi?template=%s?handle=%s|localhost|70]\n", $2, $1, h }'
       +        | awk -F '\t' -v h="$handle" -v base_dir="$BASE_DIR" \
       +              '{ printf "[1|%s|/%ssendmail.dcgi?template=%s?handle=%s|localhost|70]\n", $2, base_dir, $1, h }'
        }
        
        show_footer() {
       -    printf "\n\n[1|Start over|/sendmail.dcgi|localhost|70]"
       +    printf "\n\n[1|Start over|$BASE_DIR/sendmail.dcgi|localhost|70]"
        }
        
        if [ -z "$handle" ]; then