fix for multiple posts in remote, set up for nested dirs

master
Bel LaPointe 2021-11-29 13:04:21 -07:00
parent 44f6e57379
commit 65b515b9ce
4 changed files with 21 additions and 11 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
blog/.hugo_build.lock
**/*.sw*

View File

@ -10,5 +10,5 @@ cleanup() {
}
trap cleanup EXIT
hugo -D --gc
simpleserve -d ./public/ -p 35813
hugo -D --gc
simpleserve -d ./public/ -p 35813 || simpleserve -d ./public/ -p 35813 -md-css /dev/null

View File

@ -4,13 +4,15 @@ HUGO_POSTS="${HUGO_POSTS:-"./posts"}"
RCLONE_ALIAS="${RCLONE_ALIAS:-"hugo"}"
RCLONE_CONFIG="${RCLONE_CONFIG:-./rclone.conf}"
RCLONE_FOLDER="${RCLONE_FOLDER:-"shared_from_bbarl64"}"
RCLONE_FOLDER_POSTS="${RCLONE_FOLDER_POSTS:-"posts"}"
RCLONE_FOLDER_META="${RCLONE_FOLDER_META:-"meta"}"
RCLONE_OPTS="${RCLONE_OPTS:-"--drive-shared-with-me"}"
TMPDIR="${TMPDIR:-"/tmp"}"
main() {
flags "$@"
local want=()
for b64_json in "$(list)"; do
for b64_json in $(list); do
local json="$(echo "$b64_json" | base64 --decode)"
local filename="$(echo "$json" | jq -r .Name)"
want+=("$(imported "$json")")
@ -52,7 +54,7 @@ log() {
}
list() {
gd list
gd list_posts
}
up_to_date() {
@ -70,7 +72,8 @@ pulled() {
}
pull() {
gd pull "$filename"
local filename="$(echo "$json" | jq -r .Name)"
gd pull_posts "$filename"
}
extracted() {
@ -99,7 +102,7 @@ extract() {
| sed 's/<\/body>.*/<\/body>/' \
> "$index_html"
local tags=($(cat "$index_html" | sed '/^$/!{s/<[^>]*>//g;p;}' | grep -o '#[a-zA-Z0-9]*' | grep '[a-zA-Z]' | sed 's/^#//' | sort -u))
local tags_csv="$(first=false; for tag in "${tags[@]}"; do true; if $first; then echo -n ", "; fi; first=true; echo -n "$tag"; done)"
local tags_csv="$(first=false; for tag in "${tags[@]}"; do true; if $first; then echo -n ", "; fi; first=true; echo -n "$tag"; done)"
printf '
---
@ -151,11 +154,16 @@ metadata() {
}
gd() (
list() {
rc lsjson "$RCLONE_ALIAS:$RCLONE_FOLDER" | jq -c .[] | grep zip\" | base64
list_posts() {
rc lsjson "$RCLONE_ALIAS:$RCLONE_FOLDER/$RCLONE_FOLDER_POSTS" \
| jq -c .[] \
| grep zip\" \
| while read -r line; do
echo "$line" | base64
done
}
pull() {
rc copy "$RCLONE_ALIAS:$RCLONE_FOLDER/$1" "$TMPDIR"/
pull_posts() {
rc copy "$RCLONE_ALIAS:$RCLONE_FOLDER/$RCLONE_FOLDER_POSTS/$1" "$TMPDIR"/
}
rc() {
rclone \

View File

@ -6,5 +6,5 @@ scope = drive
#team_drive = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
#root_folder_id = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
formats = zip,html,rtf,odt,docx,xlsx,pptx,svg
token = {"access_token":"ya29.a0ARrdaM_kpbDUGroFqB3HY6EW2xzX6tYkhtlHRPgaSJ6ytxMp7CLgao5SIF1cvABho-5YTaZtfpOWPIdySiPHIgrtV7YC9Yk3Y5nB0ZCM6WcG3_4dglc4D0bbd9AhEmnBRtYI7UjlEL3L0X3hh0K7CN11HzZXsQ","token_type":"Bearer","refresh_token":"1//04sQD4800FsqyCgYIARAAGAQSNwF-L9IrB1_7BV8ScFnqmIz8FNWgXfr80--6VG6KX1pTnneQKAz6Ss3YtxqmCdf2tRBy2ndkhek","expiry":"2021-11-29T00:48:36.393616466-07:00"}
token = {"access_token":"ya29.a0ARrdaM-Ca19JFA2LNKls0IsuLLGEF2M2eytTRxRP-YoS73oJvhDOi_xdw48uu0c8q5wrLglRfPBVZM5h48Oe4fJBVTPMR96b1ySUXWCscuh-GtWHV0iF4JxlIqY3bgR6lg5odyiUvXRFauh0JcZ10ozJ7mUy4g","token_type":"Bearer","refresh_token":"1//04sQD4800FsqyCgYIARAAGAQSNwF-L9IrB1_7BV8ScFnqmIz8FNWgXfr80--6VG6KX1pTnneQKAz6Ss3YtxqmCdf2tRBy2ndkhek","expiry":"2021-11-29T13:47:23.55774-07:00"}