fix for multiple posts in remote, set up for nested dirs
parent
44f6e57379
commit
65b515b9ce
|
|
@ -0,0 +1,2 @@
|
||||||
|
blog/.hugo_build.lock
|
||||||
|
**/*.sw*
|
||||||
4
blog.sh
4
blog.sh
|
|
@ -10,5 +10,5 @@ cleanup() {
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
hugo -D --gc
|
hugo -D --gc
|
||||||
simpleserve -d ./public/ -p 35813
|
simpleserve -d ./public/ -p 35813 || simpleserve -d ./public/ -p 35813 -md-css /dev/null
|
||||||
|
|
|
||||||
24
posts.sh
24
posts.sh
|
|
@ -4,13 +4,15 @@ HUGO_POSTS="${HUGO_POSTS:-"./posts"}"
|
||||||
RCLONE_ALIAS="${RCLONE_ALIAS:-"hugo"}"
|
RCLONE_ALIAS="${RCLONE_ALIAS:-"hugo"}"
|
||||||
RCLONE_CONFIG="${RCLONE_CONFIG:-./rclone.conf}"
|
RCLONE_CONFIG="${RCLONE_CONFIG:-./rclone.conf}"
|
||||||
RCLONE_FOLDER="${RCLONE_FOLDER:-"shared_from_bbarl64"}"
|
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"}"
|
RCLONE_OPTS="${RCLONE_OPTS:-"--drive-shared-with-me"}"
|
||||||
TMPDIR="${TMPDIR:-"/tmp"}"
|
TMPDIR="${TMPDIR:-"/tmp"}"
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
flags "$@"
|
flags "$@"
|
||||||
local want=()
|
local want=()
|
||||||
for b64_json in "$(list)"; do
|
for b64_json in $(list); do
|
||||||
local json="$(echo "$b64_json" | base64 --decode)"
|
local json="$(echo "$b64_json" | base64 --decode)"
|
||||||
local filename="$(echo "$json" | jq -r .Name)"
|
local filename="$(echo "$json" | jq -r .Name)"
|
||||||
want+=("$(imported "$json")")
|
want+=("$(imported "$json")")
|
||||||
|
|
@ -52,7 +54,7 @@ log() {
|
||||||
}
|
}
|
||||||
|
|
||||||
list() {
|
list() {
|
||||||
gd list
|
gd list_posts
|
||||||
}
|
}
|
||||||
|
|
||||||
up_to_date() {
|
up_to_date() {
|
||||||
|
|
@ -70,7 +72,8 @@ pulled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pull() {
|
pull() {
|
||||||
gd pull "$filename"
|
local filename="$(echo "$json" | jq -r .Name)"
|
||||||
|
gd pull_posts "$filename"
|
||||||
}
|
}
|
||||||
|
|
||||||
extracted() {
|
extracted() {
|
||||||
|
|
@ -99,7 +102,7 @@ extract() {
|
||||||
| sed 's/<\/body>.*/<\/body>/' \
|
| sed 's/<\/body>.*/<\/body>/' \
|
||||||
> "$index_html"
|
> "$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=($(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 '
|
printf '
|
||||||
---
|
---
|
||||||
|
|
@ -151,11 +154,16 @@ metadata() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gd() (
|
gd() (
|
||||||
list() {
|
list_posts() {
|
||||||
rc lsjson "$RCLONE_ALIAS:$RCLONE_FOLDER" | jq -c .[] | grep zip\" | base64
|
rc lsjson "$RCLONE_ALIAS:$RCLONE_FOLDER/$RCLONE_FOLDER_POSTS" \
|
||||||
|
| jq -c .[] \
|
||||||
|
| grep zip\" \
|
||||||
|
| while read -r line; do
|
||||||
|
echo "$line" | base64
|
||||||
|
done
|
||||||
}
|
}
|
||||||
pull() {
|
pull_posts() {
|
||||||
rc copy "$RCLONE_ALIAS:$RCLONE_FOLDER/$1" "$TMPDIR"/
|
rc copy "$RCLONE_ALIAS:$RCLONE_FOLDER/$RCLONE_FOLDER_POSTS/$1" "$TMPDIR"/
|
||||||
}
|
}
|
||||||
rc() {
|
rc() {
|
||||||
rclone \
|
rclone \
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,5 @@ scope = drive
|
||||||
#team_drive = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
|
#team_drive = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
|
||||||
#root_folder_id = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
|
#root_folder_id = 1-p043gwMk88rj4-Sm5otARi_AJZYskbj
|
||||||
formats = zip,html,rtf,odt,docx,xlsx,pptx,svg
|
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"}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue