Compare commits

..

2 Commits

10 changed files with 82 additions and 60 deletions

View File

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

10
scripts/new_hook.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/local/bin/bash
export PROJECT_DIR=~/Notes
export SCRIPT_DIR=$PROJECT_DIR/scripts
export JOURNAL_DIR=$PROJECT_DIR/wikis
cd $SCRIPT_DIR
./make_new.sh
./update_all.sh

View File

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

View File

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

View File

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

View File

@ -2,10 +2,10 @@
from pathlib import Path from pathlib import Path
from utils.py.journals import * from utils.py.journals import *
import os
SCRIPT_DIR=Path.home()/"Journal"/"scripts" PROJ_DIR=Path(os.getenv("PROJ_DIR"))
SCRIPT_DIR.cwd() TASK_FILE=PROJ_DIR/"tasks.wiki"
TASK_FILE=Path.home()/"Journal"/"tasks.wiki"
if not TASK_FILE.exists(): if not TASK_FILE.exists():
TASK_FILE.touch() TASK_FILE.touch()
@ -27,14 +27,17 @@ with TASK_FILE.open('a') as file:
file.write(f"[[{filename}|{file_date}]]\n") file.write(f"[[{filename}|{file_date}]]\n")
if len(todo) != 0: if len(todo) != 0:
file.write("# TODO\n") file.write("TODO\n")
file.write("----\n")
for task in todo: for task in todo:
task_string=task.replace('=','').strip() task_string=task.replace('=','').strip()
file.write(f"- [[{filename}#{task_string}|{task_string}]]\n") file.write(f"- [[{filename}#{task_string}|{task_string}]]\n")
file.write("\n") file.write("\n")
if len(done) != 0: if len(done) != 0:
file.write("# DONE\n") file.write("DONE\n")
file.write("----\n")
for task in done: for task in done:
task_string=task.replace('=','').strip() task_string=task.replace('=','').strip()
file.write(f"- [[{filename}#{task_string}|{task_string}]]\n") 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 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 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 () { function get_journals () {
local JOURNAL_REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}.wiki' local JOURNAL_REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}.wiki'
[[ "$1" ]] && declare -n hashmap="$1" declare -n array="${1:?"get_journals : Variable not passed through"}"
hashmap=( $( ls $JOURNAL_DIR -1 | grep -Eo $JOURNAL_REGEX | sort -n ) ) 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 #!/opt/homebrew/bin/bash
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh [[ -f ~/Notes/utils/journals.sh ]] && . ~/Notes/utils/journals.sh
function get_tasks () { function get_tasks () {
set -x set -x

View File

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