diff --git a/register.sh b/register.sh index cd72cbe..cfa01eb 100755 --- a/register.sh +++ b/register.sh @@ -8,16 +8,14 @@ query_db() { printf '%s\n' "$(PGPASSWORD=$DB_PASS psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d "$DB_NAME" -t -A -P pager=off -P border=0 -P format=unaligned -P tuples_only=on -c "$1")" } -query_db "SELECT * FROM sites WHERE status = 'down' OR status = 'diff';" | while IFS='|' read -r _ directory _ _ _ _ _ _ _ title slogan banner json_data; do +query_db "SELECT * FROM sites WHERE status = 'down' OR status = 'diff';" | while IFS='|' read -r _ directory _ _ _ _ _ _ _ title slogan banner json_data _ _ tags; do rm -f "$TMPDIR/site.md" "$TMPDIR/site.json" - json_data="${json_data%|*}" - json_data="${json_data%|*}" printf '%s' "$json_data" > "$TMPDIR/site.json" json2md -j "$TMPDIR/site.json" -t markdown -o "$TMPDIR/site.md" markdown_data="$(cat "$TMPDIR/site.md")" rm -f "$TMPDIR/site.md" "$TMPDIR/site.json" mkdir -p "content/$directory" - printf '%s\ndate: %s\ntitle: %s\ndescription: %s\nbanner: %s\ntags: %s\nlayout: single\n%s\n\n%s\n' \ - '---' "$(date -I)" "$title" "$slogan" "$banner" "$tags" '---' "$markdown_data" > "content/$directory/_index.md" + printf '%s\ndate: %s\ntitle: %s\ndescription: %s\ntags: %s\nbanner: %s\nlayout: single\n%s\n\n%s\n' \ + '---' "$(date -I)" "$title" "$slogan" "$tags" "$banner" '---' "$markdown_data" > "content/$directory/_index.md" done