Altered other scripts to implement config.sh

This commit is contained in:
Tristan Ancelet 2023-12-08 12:35:05 -06:00
parent 06ee4b76bb
commit 6990ca264d
7 changed files with 24 additions and 19 deletions

View File

@ -1,12 +1,13 @@
#!/usr/local/bin/bash #!/usr/local/bin/bash
export CONFIG=1
export PROJ_DIR=~/Notes export PROJ_DIR=~/Notes
export JOURNAL_DIR=$PROJ_DIR/wikis export JOURNAL_DIR=$PROJ_DIR/wikis
export SCRIPT_DIR=$PROJ_DIR/scripts export SCRIPT_DIR=$PROJ_DIR/scripts
export FILES_DIR=$PROJ_DIR/files export FILES_DIR=$PROJ_DIR/files
export SUBJECTS_DIR=$PROJ_DIR/subjects export SUBJECTS_DIR=$PROJ_DIR/subjects
export UTILS_DIR=$SCRIPT_DIR/utils export UTILS_DIR=$SCRIPT_DIR/utils
export SITE_NAV='[[/index.wiki|Index]] [[/full_index.wiki|Full Index]] [[/tasks.wiki|Tasks Index]] [[/how-to.wiki|How-To Index]] [[/subjects.wiki|Subjects]]'
function import () { function import () {
local SCRIPT_NAME="${1:?"import : script name not provided"}" local SCRIPT_NAME="${1:?"import : script name not provided"}"
@ -24,3 +25,5 @@ function import () {
fi fi
} }
export -f import

View File

@ -1,5 +1,6 @@
#!/opt/homebrew/bin/bash #!/opt/homebrew/bin/bash
[[ $CONFIG -ne 1 ]] && [[ -f config.sh ]] && . config.sh
cd $JOURNAL_DIR cd $JOURNAL_DIR
DATE=`date +'%Y-%m-%d'` DATE=`date +'%Y-%m-%d'`
FILE="$JOURNAL_DIR/$DATE.wiki" FILE="$JOURNAL_DIR/$DATE.wiki"
@ -39,7 +40,7 @@ echo "[[$LAST_JOURNAL_ENTRY|Last Journal Entry]]
%title $DATE Journal Entry %title $DATE Journal Entry
--------------------- ---------------------
[[/index.wiki|Index]] $SITE_NAV
--------------------- ---------------------
Main Topics from previous journal entry Main Topics from previous journal entry

View File

@ -1,11 +0,0 @@
#!/opt/homebrew/bin/bash
export PROJ_DIR=~/Notes
export JOURNAL_DIR=$PROJ_DIR/wikis
export FILES_DIR=$PROJ_DIR/files
export SCRIPT_DIR=$PROJ_DIR/scripts
cd $PROJ_DIR
for script in $SCRIPT_DIR/enabled/**; do
[[ -x $script ]] && $script
done

View File

@ -1,8 +1,7 @@
#!/opt/homebrew/bin/bash #!/opt/homebrew/bin/bash
#set -x [[ $CONFIG -ne 1 ]] && [[ -f config.sh ]] && . config.sh
import journals
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh
JOURNAL_FULL_INDEX=$PROJ_DIR/full_index.wiki JOURNAL_FULL_INDEX=$PROJ_DIR/full_index.wiki
declare -a journals declare -a journals

9
scripts/update_hook.sh Executable file
View File

@ -0,0 +1,9 @@
#!/opt/homebrew/bin/bash
[[ -f config.sh ]] && [[ $CONFIG -ne 1 ]] && . config.sh
cd $PROJ_DIR
for script in $SCRIPT_DIR/enabled/**; do
[[ -x $script ]] && $script
done

View File

@ -1,15 +1,17 @@
#!/opt/homebrew/bin/bash #!/opt/homebrew/bin/bash
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh [[ $CONFIG -ne 1 ]] && [[ -f config.sh ]] && . config.sh
JOURNAL_INDEX=$PROJ_DIR/index.wiki
import journals
JOURNAL_INDEX=$PROJ_DIR/index.wiki
declare -a journals declare -a journals
get_journals journals get_journals journals
echo " echo "
%title Journal Index %title Journal Index
----------------------------------------------- -----------------------------------------------
[[/index.wiki|Index]] [[full_index.wiki|Full Index]] [[tasks.wiki|Tasks Index]] [[how-to.wiki|How-To Index]] $SITE_NAV
----------------------------------------------- -----------------------------------------------
Journals Journals

View File

@ -6,6 +6,7 @@ import os
PROJ_DIR=Path(os.getenv("PROJ_DIR")) PROJ_DIR=Path(os.getenv("PROJ_DIR"))
TASK_FILE=PROJ_DIR/"tasks.wiki" TASK_FILE=PROJ_DIR/"tasks.wiki"
NAV=os.getenv("SITE_NAV")
if not TASK_FILE.exists(): if not TASK_FILE.exists():
TASK_FILE.touch() TASK_FILE.touch()
@ -17,6 +18,7 @@ else:
with TASK_FILE.open('a') as file: with TASK_FILE.open('a') as file:
file.write("%title Tasks\n\n\n") file.write("%title Tasks\n\n\n")
file.write(f"{NAV}\n")
for fileobj in get_journal(): for fileobj in get_journal():
filename = fileobj.name filename = fileobj.name