The source code of blog.fyber.space https://blog.fyber.space
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stitch.sh 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # File : stitch.sh
  3. # Author : Vincent Truchseß <redtux@posteo.net>
  4. # Date : 10.04.2019
  5. # Last Modified Date: 11.04.2019
  6. # Last Modified By : Vincent Truchseß <redtux@posteo.net>
  7. # Config Section
  8. POSTS_DIR="$HOME/blog/posts"
  9. USER="blog"
  10. PASSWD="$(pass internet/social.fyber.space/blog)"
  11. INSTANCE="social.fyber.space"
  12. BLOG_DOMAIN="blog.fyber.space"
  13. CC="@vi@social.fyber.space"
  14. # Setup Paths, Filenames and urls
  15. DRAFT="$1"
  16. BASENAME="$(basename "$DRAFT")"
  17. NAME="${BASENAME%.*}"
  18. TARGET="$(date +%Y-%m-%d)-$NAME"
  19. POST_URL="https://$BLOG_DOMAIN/posts/$TARGET.html"
  20. # Copy draft to posts-folder adding date to filename
  21. cp "$DRAFT" "$POSTS_DIR"/"$TARGET".md
  22. # Posting title and link to article in fediverse-instance, getting status-url as response
  23. TITLE="$(grep title: "$DRAFT" | sed -E 's/^.+:\s*//' | sed -E 's/\s*$//')"
  24. TEXT="$TITLE"%0D%0A"$POST_URL%0D%0ACC: $CC"
  25. REQUEST_URL="https://$INSTANCE/api/v1/statuses"
  26. STATUS_URL="$(curl -u $USER:$PASSWD --data status="$TEXT" -X POST $REQUEST_URL | jq -r .url)"
  27. # Appending Discussion-Link to the fediverse-status at the End of Blogpost
  28. printf "\n\n[Discussion](%s)\n" "$STATUS_URL" >> "$POSTS_DIR"/"$TARGET".md