restructured project
This commit is contained in:
parent
9616b56f53
commit
a27e7f561e
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
*
|
||||
!*.sh
|
||||
!scripts
|
||||
!scripts/*
|
||||
!scripts/*/*
|
||||
!.gitignore
|
||||
|
1
scripts/enabled/update_full_index.sh
Symbolic link
1
scripts/enabled/update_full_index.sh
Symbolic link
@ -0,0 +1 @@
|
||||
../update_full_index.sh
|
1
scripts/enabled/update_index.sh
Symbolic link
1
scripts/enabled/update_index.sh
Symbolic link
@ -0,0 +1 @@
|
||||
../update_index.sh
|
1
scripts/enabled/update_tasks.py
Symbolic link
1
scripts/enabled/update_tasks.py
Symbolic link
@ -0,0 +1 @@
|
||||
../update_tasks.py
|
@ -1,20 +1,23 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
JOURNAL_DIR=/home/tristan/Journal
|
||||
UPDATE_INDEX=$JOURNAL_DIR/update_index.sh
|
||||
|
||||
JOURNAL_DIR=~/Journal
|
||||
cd $JOURNAL_DIR
|
||||
UPDATE_ALL=$JOURNAL_DIR/scripts/update_all.sh
|
||||
DATE=`date +'%Y-%m-%d'`
|
||||
FILE="$DATE.wiki"
|
||||
FILE="$JOURNAL_DIR/$DATE.wiki"
|
||||
|
||||
[[ -f $JOURNAL_DIR/utils/journals.sh ]] && . $JOURNAL_DIR/utils/journals.sh
|
||||
|
||||
# Getting the last journal entry file
|
||||
LAST_JOURNAL_ENTRY=`ls $JOURNAL_DIR/*.wiki -1 | sort -n | tail -n 1`
|
||||
# Getting just the filename
|
||||
LAST_JOURNAL_ENTRY=`basename $LAST_JOURNAL_ENTRY`
|
||||
|
||||
# Updating my index notes
|
||||
[[ -f $UPDATE_INDEX ]] && $UPDATE_INDEX
|
||||
declare -a journals
|
||||
get_journals journals
|
||||
LAST_JOURNAL_ENTRY="${journals[-1]}"
|
||||
|
||||
declare -A topics
|
||||
|
||||
[[ -f $file ]] && exit
|
||||
|
||||
while read line; do
|
||||
# Stripping the '=' characters from the topic
|
||||
declare -i level=$( tr -cd '=' <<< "$line" | wc -c)
|
||||
@ -44,14 +47,12 @@ $( for topic in "${!topics[@]}"; do
|
||||
done )
|
||||
|
||||
# Times
|
||||
|
||||
$( for topic in "${!topics[@]}"; do
|
||||
level=${topics["$topic"]}
|
||||
[[ $level -eq 2 ]] && echo "[[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
|
||||
done )
|
||||
|
||||
# Subtopics
|
||||
|
||||
$( for topic in "${!topics[@]}"; do
|
||||
level=${topics["$topic"]}
|
||||
[[ $level -gt 2 ]] && echo "[[$LAST_JOURNAL_ENTRY#$topic|$topic]]";
|
||||
@ -59,3 +60,8 @@ done )
|
||||
|
||||
|
||||
" > $FILE
|
||||
|
||||
|
||||
|
||||
|
||||
[[ -f $UPDATE_ALL ]] && $UPDATE_ALL
|
11
scripts/update_all.sh
Executable file
11
scripts/update_all.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
JOURNAL_DIR=~/Journal
|
||||
SCRIPT_DIR=$JOURNAL_DIR/scripts/enabled
|
||||
|
||||
#set -x
|
||||
|
||||
cd $JOURNAL_DIR
|
||||
|
||||
for script in $SCRIPT_DIR/*; do
|
||||
[[ -x $script ]] && $script
|
||||
done
|
37
scripts/update_full_index.sh
Executable file
37
scripts/update_full_index.sh
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/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
|
||||
|
||||
declare -a journals
|
||||
get_journals journals
|
||||
|
||||
echo "
|
||||
%title Full Index
|
||||
|
||||
# Journals: Times & Topics
|
||||
$(
|
||||
for file in ${journals[@]}; do
|
||||
echo -e '\n\n'
|
||||
echo "[[$file|$(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
|
||||
|
||||
echo "# Topics"
|
||||
while read topic; do
|
||||
echo " - [[$file#$topic|$topic]]"
|
||||
done <<< "$( grep -Eo '^===[=]* .+ ===[=]*' $file | tr '=' ' ' | sort -u)"
|
||||
done
|
||||
)
|
||||
|
||||
|
||||
" > $JOURNAL_FULL_INDEX
|
25
scripts/update_index.sh
Executable file
25
scripts/update_index.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/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
|
||||
|
||||
declare -a journals
|
||||
get_journals journals
|
||||
|
||||
echo "
|
||||
%title Journal Index
|
||||
[[full_index.wiki|Full Index]]
|
||||
|
||||
# Journals
|
||||
$(
|
||||
for journal in ${journals[@]}; do
|
||||
echo "- [[$journal|$( echo $journal | cut -d'.' -f 1 | tr '-' ' ')]]"
|
||||
done
|
||||
)
|
||||
|
||||
" > $JOURNAL_INDEX
|
39
scripts/update_tasks.py
Executable file
39
scripts/update_tasks.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from pathlib import Path
|
||||
from utils.py.journals import *
|
||||
|
||||
TASK_FILE=Path.home()/"Journal"/"tasks.wiki"
|
||||
|
||||
if not TASK_FILE.exists():
|
||||
TASK_FILE.touch()
|
||||
else:
|
||||
# Clearing out the file
|
||||
with TASK_FILE.open('w') as file:
|
||||
file.write("")
|
||||
|
||||
|
||||
with TASK_FILE.open('a') as file:
|
||||
file.write("%title Tasks\n\n\n")
|
||||
|
||||
for fileobj in get_journal():
|
||||
filename = fileobj.name
|
||||
todo, done = get_task_lists(fileobj)
|
||||
|
||||
if len(todo) != 0 or len(done) != 0:
|
||||
file_date=filename.split('.')[0].replace('-',' ')
|
||||
file.write(f"[[{filename}|{file_date}]]\n")
|
||||
|
||||
if len(todo) != 0:
|
||||
file.write("# TODO\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")
|
||||
for task in done:
|
||||
task_string=task.replace('=','').strip()
|
||||
file.write(f"- [[{filename}#{task_string}|{task_string}]]\n")
|
||||
file.write("\n")
|
8
scripts/utils/journals.sh
Normal file
8
scripts/utils/journals.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/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 ) )
|
||||
}
|
26
scripts/utils/tasks.sh
Normal file
26
scripts/utils/tasks.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/bash
|
||||
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
|
||||
|
||||
function get_tasks () {
|
||||
set -x
|
||||
local -a journals
|
||||
get_journals journals
|
||||
|
||||
local TASK_REGEX='====[[:space:]]+.+[[:space:]]+===='
|
||||
|
||||
declare -n TODO="$1"
|
||||
declare -n DONE="$2"
|
||||
|
||||
for journal in "${journals[@]}"; do
|
||||
if grep -Eo $TASK_REGEX $journal >/dev/null 2>&1; then
|
||||
|
||||
while read line; do
|
||||
if [[ "$line" == *'(DUE: DONE)'* ]]; then
|
||||
DONE["$journal"]="$( echo -e "${DONE["$journal"]}\n$line" )"
|
||||
else
|
||||
TODO["$journal"]="$( echo -e "${TODO["$journal"]}\n$line" )"
|
||||
fi
|
||||
done <<< "$( grep -Eo $TASK_REGEX $journal | tr '=' ' ')"
|
||||
fi
|
||||
done
|
||||
}
|
16
scripts/utils/topics.sh
Normal file
16
scripts/utils/topics.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/bash
|
||||
[[ -f ~/Journal/utils/journals.sh ]] && . ~/Journal/utils/journals.sh
|
||||
|
||||
function get_tasks () {
|
||||
local -a journals
|
||||
get_journals journals
|
||||
local TOPIC_REGEX='^=== .+ ==='
|
||||
|
||||
declare -n TOPICS="$1"
|
||||
|
||||
for journal in "${journals[@]}"; do
|
||||
if grep -E "$TOPIC_REGEX" $journal >/dev/null 2>&1; then
|
||||
TOPICS["$journal"]="$( grep -Eo "$TOPIC_REGEX" $journal | tr '=' ' ' )"
|
||||
fi
|
||||
done
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
#set -x
|
||||
|
||||
JOURNAL_DIR=/home/tristan/Journal
|
||||
JOURNAL_INDEX=$JOURNAL_DIR/index.wiki
|
||||
|
||||
declare -A topics
|
||||
|
||||
for file in $JOURNAL_DIR/*.wiki; do
|
||||
if [[ -f $file ]]; then
|
||||
while read topic; do
|
||||
[[ "$topic" == "" ]] && continue
|
||||
base=`basename $file`
|
||||
topics+=( ["$topic"]="$base" )
|
||||
# Remember == .* == is reserved for times of entry
|
||||
done <<< "$( grep -Eo '= .^ =|=== .* ===' $file | tr '=' ' ' )"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "%title Journal Index
|
||||
|
||||
" > $JOURNAL_INDEX
|
||||
|
||||
printf -v topic_string '%s\n' "${!topics[@]}"
|
||||
|
||||
# Since the hash-table will auto sort things
|
||||
while read topic; do
|
||||
[[ "$topic" == "" ]] && continue
|
||||
file="${topics["$topic"]}"
|
||||
echo "[[$file#$topic|$topic]]" >> $JOURNAL_INDEX
|
||||
done <<< "$( sort -i <<< "$topic_string" )"
|
Loading…
Reference in New Issue
Block a user