You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
2 years ago
|
#!/bin/bash
|
||
|
all=$1
|
||
|
notes=/Users/nige/notes/
|
||
|
marker=/Users/nige/lua/.marker
|
||
|
|
||
|
[ -f $marker ] || touch $marker
|
||
|
|
||
|
echo "Marker time: $(date -r "${marker}")"
|
||
|
|
||
|
now=$(date '+%Y%m%d%H%M.%S')
|
||
|
|
||
|
updateNote() {
|
||
|
local i=$1
|
||
|
echo
|
||
|
echo "Current filename: $i"
|
||
|
#count=$(grep -e "[\({]\(./\)*$(basename $i)\(/*#[^)}]*\)*[\)}]" ${notes}*| wc -l )
|
||
|
count=$(grep -e "$1" ${notes}*| wc -l )
|
||
|
echo "References: $count"
|
||
|
if [[ "${i}" == *.norg ]]; then
|
||
|
echo
|
||
|
echo "Current filetype: NEORG"
|
||
|
/Users/nige/bin/norg-functions.sh "$i" $count > /tmp/update.json
|
||
|
elif [[ "${i}" == *.md ]]; then
|
||
|
echo
|
||
|
echo "Current filetype: MARKDOWN"
|
||
|
/Users/nige/bin/md-functions.sh "$i" $count > /tmp/update.json
|
||
|
else
|
||
|
echo
|
||
|
echo "Unsupported filetype..."
|
||
|
return
|
||
|
fi
|
||
|
|
||
|
if [ -f /tmp/update.json ]; then
|
||
|
update=true
|
||
|
curl -X POST 'http://127.0.0.1:7700/indexes/notes/documents?primaryKey=id' -H 'Content-Type: application/json' --data-binary @/tmp/update.json
|
||
|
mv /tmp/update.json "/tmp/${i//\//\\}.json"
|
||
|
#rm /tmp/update.json
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
update() {
|
||
|
echo "Start Update"
|
||
|
update=false
|
||
|
for i in $( [ "$all" == "all" ] && find ~/notes/ -type f || find ~/notes/ -type f -newer "$marker"); do
|
||
|
time updateNote $i
|
||
|
echo "-----------------------"
|
||
|
done
|
||
|
if [ "$update" == "true" ]; then
|
||
|
echo
|
||
|
touch -t $now $marker
|
||
|
fi
|
||
|
echo "Update DONE"
|
||
|
echo "Current Marker time: $(date -r "${marker}")"
|
||
|
}
|
||
|
time update
|