Had to update path-names to allow scripts to access the files after update to journals.sh

This commit is contained in:
Tristan Ancelet 2023-12-08 12:07:31 -06:00
parent fa16efc488
commit 4759318d29
9 changed files with 72 additions and 60 deletions

View File

@ -1,17 +1,16 @@
#!/usr/bin/bash
#!/opt/homebrew/bin/bash
JOURNAL_DIR=~/Journal
cd $JOURNAL_DIR
UPDATE_ALL=$JOURNAL_DIR/scripts/update_all.sh
DATE=`date +'%Y-%m-%d'`
FILE="$JOURNAL_DIR/$DATE.wiki"
[[ -f $JOURNAL_DIR/scripts/utils/journals.sh ]] && . $JOURNAL_DIR/scripts/utils/journals.sh
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh
# Getting the last journal entry file
declare -a journals
get_journals journals
LAST_JOURNAL_ENTRY="${journals[-1]}"
LAST_JOURNAL_ENTRY="${LAST_JOURNAL_ENTRY/*\/}"
declare -A topics
@ -39,28 +38,31 @@ echo "[[$LAST_JOURNAL_ENTRY|Last Journal Entry]]
%title $DATE Journal Entry
# Main Topics from previous journal entry
---------------------
[[/index.wiki|Index]]
---------------------
Main Topics from previous journal entry
---------------------------------------
$( for topic in "${!topics[@]}"; do
level=${topics["$topic"]}
[[ $level -eq 1 ]] && echo "[[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
[[ $level -eq 1 ]] && echo "- [[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
done )
# Times
Times
-----
$( for topic in "${!topics[@]}"; do
level=${topics["$topic"]}
[[ $level -eq 2 ]] && echo "[[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
[[ $level -eq 2 ]] && echo "- [[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
done )
# Subtopics
Subtopics
---------
$( for topic in "${!topics[@]}"; do
level=${topics["$topic"]}
[[ $level -gt 2 ]] && echo "[[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
[[ $level -gt 2 ]] && echo "- [[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
done )
" > $FILE
[[ -f $UPDATE_ALL ]] && $UPDATE_ALL

View File

@ -1,12 +1,11 @@
#!/usr/bin/bash
JOURNAL_DIR=~/Journal
FILES_DIR=$JOURNAL_DIR/files
SCRIPT_DIR=$JOURNAL_DIR/scripts/enabled
#!/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
#set -x
cd $PROJ_DIR
cd $JOURNAL_DIR
for script in $SCRIPT_DIR/*; do
for script in $SCRIPT_DIR/enabled/**; do
[[ -x $script ]] && $script
done

View File

@ -1,11 +1,9 @@
#!/usr/bin/bash
#!/opt/homebrew/bin/bash
#set -x
JOURNAL_DIR=~/Journal
JOURNAL_SCRIPT_DIR=$JOURNAL_DIR/scripts
[[ -f $JOURNAL_SCRIPT_DIR/utils/journals.sh ]] && . $JOURNAL_SCRIPT_DIR/utils/journals.sh
JOURNAL_FULL_INDEX=$JOURNAL_DIR/full_index.wiki
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh
JOURNAL_FULL_INDEX=$PROJ_DIR/full_index.wiki
declare -a journals
get_journals journals
@ -15,21 +13,23 @@ echo "
# Journals: Times & Topics
$(
for file in ${journals[@]}; do
for file_path in ${journals[@]}; do
file="${file_path/*\/}"
journal_full_path=$PROJ_DIR$file_path
echo -e '\n\n'
echo "[[$file|$(echo $file | cut -d '.' -f 1 | tr '-' ' ')]]"
echo "[[$file_path|$(echo $file | cut -d '.' -f 1 | tr '-' '/')]]"
echo "# Times"
while read time; do
echo " - [[$file#$time|$time]]"
done <<< "$( grep '== ' $file | grep -Eo '[0-9]+:[0-9]+ [A-Za-z]{2} [A-Za-z]{3}')"
echo " - [[$file_path#$time|$time]]"
done <<< "$( grep '== ' $journal_full_path | grep -Eo '[0-9]+:[0-9]+ [A-Za-z]{2} [A-Za-z]{3}')"
echo
echo "# Topics"
while read topic; do
echo " - [[$file#$topic|$topic]]"
done <<< "$( grep -Eo '^===[=]* .+ ===[=]*' $file | tr '=' ' ' | sort -u)"
echo " - [[$file_path#$topic|$topic]]"
done <<< "$( grep -Eo '^===[=]* .+ ===[=]*' $journal_full_path | tr '=' ' ' | sort -u)"
done
)

View File

@ -1,26 +1,24 @@
#!/usr/bin/bash
#!/opt/homebrew/bin/bash
#set -x
JOURNAL_DIR=/home/tristan/Journal
JOURNAL_SCRIPT_DIR=$JOURNAL_DIR/scripts
[[ -f $JOURNAL_SCRIPT_DIR/utils/journals.sh ]] && . $JOURNAL_SCRIPT_DIR/utils/journals.sh
JOURNAL_INDEX=$JOURNAL_DIR/index.wiki
[[ -f $SCRIPT_DIR/utils/journals.sh ]] && . $SCRIPT_DIR/utils/journals.sh
JOURNAL_INDEX=$PROJ_DIR/index.wiki
declare -a journals
get_journals journals
echo "
%title Journal Index
[[full_index.wiki|Full Index]]
[[tasks.wiki|Tasks Index]]
[[how-to.wiki|How-To Index]]
-----------------------------------------------
[[/index.wiki|Index]] [[full_index.wiki|Full Index]] [[tasks.wiki|Tasks Index]] [[how-to.wiki|How-To Index]]
-----------------------------------------------
# Journals
Journals
--------
$(
for journal in ${journals[@]}; do
echo "- [[$journal|$( echo $journal | cut -d'.' -f 1 | tr '-' ' ')]]"
for journal_path in ${journals[@]}; do
journal_file="${journal_path/*\/}"
journal_name="$( echo $journal_file | cut -d '.' -f 1 | tr '-' '/' )"
echo "- [[$journal_path|$journal_name]]"
done
)

View File

@ -2,10 +2,10 @@
from pathlib import Path
from utils.py.journals import *
import os
SCRIPT_DIR=Path.home()/"Journal"/"scripts"
SCRIPT_DIR.cwd()
TASK_FILE=Path.home()/"Journal"/"tasks.wiki"
PROJ_DIR=Path(os.getenv("PROJ_DIR"))
TASK_FILE=PROJ_DIR/"tasks.wiki"
if not TASK_FILE.exists():
TASK_FILE.touch()
@ -27,14 +27,17 @@ with TASK_FILE.open('a') as file:
file.write(f"[[{filename}|{file_date}]]\n")
if len(todo) != 0:
file.write("# TODO\n")
file.write("TODO\n")
file.write("----\n")
for task in todo:
task_string=task.replace('=','').strip()
file.write(f"- [[{filename}#{task_string}|{task_string}]]\n")
file.write("\n")
if len(done) != 0:
file.write("# DONE\n")
file.write("DONE\n")
file.write("----\n")
for task in done:
task_string=task.replace('=','').strip()
file.write(f"- [[{filename}#{task_string}|{task_string}]]\n")

View File

@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/opt/homebrew/bin/bash
: "
get_task_number
This function will query sqlite db to either get the number of a task OR create the task and return the number

View File

@ -1,8 +1,18 @@
#!/usr/bin/bash
#!/opt/homebrew/bin/bash
function get_journals () {
local JOURNAL_REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}.wiki'
[[ "$1" ]] && declare -n hashmap="$1"
hashmap=( $( ls $JOURNAL_DIR -1 | grep -Eo $JOURNAL_REGEX | sort -n ) )
declare -n array="${1:?"get_journals : Variable not passed through"}"
array=( $( ls -1 $JOURNAL_DIR | grep -Eo $JOURNAL_REGEX | sort -n ) )
local file
for i in ${!array[@]}; do
file="${array[$i]}"
DIR=`basename $JOURNAL_DIR`
if [[ "$file" != $DIR/* ]]; then
file="/$DIR/$file"
array[$i]=$file
fi
done
}

View File

@ -1,5 +1,5 @@
#!/usr/bin/bash
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
#!/opt/homebrew/bin/bash
[[ -f ~/Notes/utils/journals.sh ]] && . ~/Notes/utils/journals.sh
function get_tasks () {
set -x

View File

@ -1,5 +1,5 @@
#!/usr/bin/bash
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
#!/opt/homebrew/bin/bash
[[ -f ~/Notes/utils/journals.sh ]] && . ~/Notes/utils/journals.sh
function get_tasks () {
local -a journals