reorg repo

This commit is contained in:
Bel LaPointe
2022-02-16 12:01:11 -07:00
parent 8cd9a5d472
commit 9739a73265
45 changed files with 12 additions and 13 deletions

View File

@@ -0,0 +1,28 @@
#! /bin/bash
ODO_TOKEN="${ODO_TOKEN:-"ac9a9e4d-9c6b-4049-9e8d-c8b97fe053aa"}"
BLOB="$BLOB"
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
blob="$(urlencode "$BLOB")"
echo curl -i -sS -H "Authorization: Bearer $ODO_TOKEN" "https://odo-public-api.corp.qualtrics.com/odo-api/parsoid/odo.corp.qualtrics.com/v3/page/html/$blob?body_only=true"
echo

3
.spike/crawl/env.env Normal file
View File

@@ -0,0 +1,3 @@
export GITLAB_PAT=LkaMCFFfqdHd-r4Cubnw
export ODO_TOKEN=ac9a9e4d-9c6b-4049-9e8d-c8b97fe053aa
export GDOC_TOKEN=

View File

@@ -0,0 +1 @@
../gitlab/expand.sh

View File

@@ -0,0 +1,29 @@
#! /bin/bash
GITLAB_PAT="$GITLAB_PAT"
PROJECT="$PROJECT"
BLOB="$BLOB"
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
project="$(urlencode $PROJECT)"
blob="$(urlencode $BLOB)"
path="api/v4/projects/$project/wikis/$blob"
curl -sS -H "Authorization: Bearer $GITLAB_PAT" "https://gitlab-app.eng.qops.net/$path" | jq -r .content

View File

@@ -0,0 +1,69 @@
#! /bin/bash
GITLAB_PAT="$GITLAB_PAT"
PROJECT="$PROJECT"
GITLAB_PATH="$GITLAB_PATH"
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
pat="${GITLAB_PAT:-"$(security find-generic-password -a "${USER}" -s GITLAB_PAT -w 2> /dev/null )"}"
project="$(urlencode ${PROJECT:-"data-store/orchestration/runbooks"})"
path="/api/v4/projects/$project/repository/tree"
list() {
local query="recursive=true&path=$(test -n "$GITLAB_PATH" && echo "$GITLAB_PATH")"
curl -sS \
-H "Authorization: Bearer $pat" \
"https://gitlab-app.eng.qops.net/$path?$query"
}
list_wiki() {
curl -sS \
-H "Authorization: Bearer $pat" \
"https://gitlab-app.eng.qops.net/api/v4/projects/$project/wikis?with_content=0"
}
files=()
trees=("${GITLAB_PATH:-"/"}")
i=0
while [ "$i" -lt "${#trees[@]}" ]; do
gitlab_path="${trees[i]}"
echo gitlab_path=$gitlab_path, i=$i, trees=${#trees[@]}, files=${#files[@]}... >&2
got="$(GITLAB_PATH=$gitlab_path list)"
echo got="$got" >&2
for nested_path in $(echo "$got" | jq -c .[] | grep '"type":"tree"' | jq -r .path | while read -r line; do echo "$line" | base64; done | grep .); do
nested_path="$(echo "$nested_path" | base64 --decode)"
if echo "${trees[@]}" | grep -q "[ ^]$nested_path[ $]"; then
continue
fi
trees+=("$nested_path")
done
for nested_path in $(echo "$got" | jq -c .[] | grep '"type":"blob"' | jq -r .path | while read -r line; do echo "$line" | base64; done | grep .); do
nested_path="$(echo "$nested_path" | base64 --decode)"
if echo "${files[@]}" | grep -q "[ ^]$nested_path[ $]"; then
continue
fi
files+=("$PROJECT.git/$nested_path")
done
i=$((i+1))
if ((i>5)); then
break
fi
done
for file in "${files[@]}"; do
echo "gitlab://$file"
done | sort
list_wiki | jq -c .[] | jq -r .title | sed 's/^/wiki:\/\//'

View File

@@ -0,0 +1,29 @@
#! /bin/bash
GITLAB_PAT="$GITLAB_PAT"
PROJECT="$PROJECT"
BLOB="$BLOB"
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
project="$(urlencode $PROJECT)"
blob="$(urlencode $BLOB)"
path="api/v4/projects/$project/repository/files/$blob/raw"
curl -sS -H "Authorization: Bearer $GITLAB_PAT" "https://gitlab-app.eng.qops.net/$path"

1
.spike/crawl/rewrite.sh Normal file
View File

@@ -0,0 +1 @@
# for each file, map potential-original-links to internal links

6
.spike/request/get_id.sh Normal file
View File

@@ -0,0 +1,6 @@
#! /bin/bash
curl -i -sS localhost:3000/api/notes/$ID
curl -sS localhost:3000/api/notes/$ID \
| jq '{id:.id, content:.content, title:.title}'

View File

@@ -0,0 +1,3 @@
#! /bin/bash
curl -sS localhost:3000/api/tree | jq -r '.items | to_entries[].value.id' | grep -v ^root$

8
.spike/request/put_id.sh Normal file
View File

@@ -0,0 +1,8 @@
#! /bin/bash
api_response="$(curl -i -sS localhost:3000/api)"
csrf_key="xsrf-token"
csrf_token="$(echo "$api_response" | grep -o '"csrfToken":[^,]*' | tr ':' '\n' | jq -r . | tail -n 1)"
notea_auth_cookie="$(echo "$api_response" | grep ^set.cookie: | sed 's/^set.cookie: //' | tr ';' '\n' | head -n 1)"
curl --fail -sS -X POST localhost:3000/api/notes/$ID -H "$csrf_key: $csrf_token" -b "$notea_auth_cookie" -H 'Content-Type: application/json' -d '{"content": "g"}'
echo $?

View File

@@ -0,0 +1,7 @@
* last write wins, no clobber detect
* not made for multi-user
* editor blips around a bit
* doesnt import obsidian even close to correctly
* very pleasant with auto-save and always-editing
* [[ exists but doesnt work well and doesnt like being changed and un-renders on bad setup via click-away and back
* hedge* collab editor for bigger use cases but per-bucket and minio based and ez backup and edit a page to create an import page is all too good

View File

@@ -0,0 +1,26 @@
#! /bin/bash
killall -9 minio
d=$(mktemp -d)
cleanup() {
killall -9 minio
rm -rf $d
}
trap cleanup EXIT
MINIO_ACCESS_KEY=access_key MINIO_SECRET_KEY=secret_key minio server --address :9000 $d &
sleep 1
mc mb sink/notea
docker run --rm -it \
--name notea \
-p 3001:3000 \
-e STORE_ACCESS_KEY=access_key \
-e STORE_SECRET_KEY=secret_key \
-e STORE_BUCKET=notea \
-e STORE_PREFIX=notea/ \
-e STORE_END_POINT=http://$(ifconfig en0 | grep inet\ | awk '{print $2}'):9000 \
-e STORE_FORCE_PATH_STYLE=true \
-e PASSWORD=notea \
-e DISABLE_PASSWORD=true \
-e COOKIE_SECURE=false \
cinwell/notea

View File

@@ -0,0 +1,3 @@
* https://github.com/Ionaru/easy-markdown-editor
* https://www.npmjs.com/package/rich-markdown-editor
* npm+more dependences but is notea+bookstack's bread n butter