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() {
local cache_key="notes cache _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
return 0
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
return 0
fi
@ -38,14 +34,17 @@ notes() (
if ! _is_deleted "$subfix"; then
echo "$subfix"
fi
_recurse_ids "$subfix" "$(echo "$json" | jq ".Branches.$line")"
_recurse_ids "$subfix" "$(echo "$json" | jq -c ".Branches[\"$line\"]")"
done
}
meta() {
local id="$1"
id="${id//\//.Branches.}"
_tree | jq -c ".Branches.$id.Leaf"
local tree="$(_tree)"
for subid in ${id//\// }; do
tree="$(echo "$tree" | jq -c .Branches | jq -c ".[\"$subid\"]")"
done
echo "$tree" | jq .Leaf
}
_is_deleted() {
@ -63,11 +62,7 @@ notes() (
}
get() {
local cache_key="notes cache $1"
if cache get "$cache_key"; then
return 0
fi
_get "$@" | cache put "$cache_key"
_get "$@"
}
_get() {
@ -91,7 +86,7 @@ notes() (
echo "$body" | _nncurl \
-X PUT \
-H "Title: $title" \
-d @- \
-d "$body" \
$NOTES_ADDR/api/v0/files/$id
}