change notes.put to args for newlines

master
Bel LaPointe 2022-02-10 08:04:36 -07:00
parent 717ced0380
commit 82ff38ba32
1 changed files with 10 additions and 15 deletions

View File

@ -6,11 +6,7 @@ notes() (
} }
_tree() { _tree() {
local cache_key="notes cache _tree" __tree "$@"
if cache get "$cache_key"; then
return 0
fi
__tree "$@" | cache put "$cache_key"
} }
__tree() { __tree() {
@ -27,7 +23,7 @@ notes() (
if echo "$json" | jq .Branches | grep -q ^null$; then if echo "$json" | jq .Branches | grep -q ^null$; then
return 0 return 0
fi fi
local b64lines="$(echo "$json" | jq -r '.Branches | keys[]' | base64)" local b64lines="$(echo "$json" | jq -r '.Branches | keys[]' | while read -r line; do echo "$line" | base64; done)"
if [ -z "$b64lines" ]; then if [ -z "$b64lines" ]; then
return 0 return 0
fi fi
@ -38,14 +34,17 @@ notes() (
if ! _is_deleted "$subfix"; then if ! _is_deleted "$subfix"; then
echo "$subfix" echo "$subfix"
fi fi
_recurse_ids "$subfix" "$(echo "$json" | jq ".Branches.$line")" _recurse_ids "$subfix" "$(echo "$json" | jq -c ".Branches[\"$line\"]")"
done done
} }
meta() { meta() {
local id="$1" local id="$1"
id="${id//\//.Branches.}" local tree="$(_tree)"
_tree | jq -c ".Branches.$id.Leaf" for subid in ${id//\// }; do
tree="$(echo "$tree" | jq -c .Branches | jq -c ".[\"$subid\"]")"
done
echo "$tree" | jq .Leaf
} }
_is_deleted() { _is_deleted() {
@ -63,11 +62,7 @@ notes() (
} }
get() { get() {
local cache_key="notes cache $1" _get "$@"
if cache get "$cache_key"; then
return 0
fi
_get "$@" | cache put "$cache_key"
} }
_get() { _get() {
@ -91,7 +86,7 @@ notes() (
echo "$body" | _nncurl \ echo "$body" | _nncurl \
-X PUT \ -X PUT \
-H "Title: $title" \ -H "Title: $title" \
-d @- \ -d "$body" \
$NOTES_ADDR/api/v0/files/$id $NOTES_ADDR/api/v0/files/$id
} }