The repository formerly known as dotfiles
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.

feed.sh 791B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. set -eu
  3. updated=$(date -u '+%FT%TZ')
  4. cat <<- EOF
  5. <?xml version="1.0" encoding="utf-8"?>
  6. <feed xmlns="http://www.w3.org/2005/Atom">
  7. <title>Causal Agency</title>
  8. <author><name>June</name><email>june@causal.agency</email></author>
  9. <link href="https://text.causal.agency"/>
  10. <id>https://text.causal.agency/</id>
  11. <updated>${updated}</updated>
  12. EOF
  13. for entry in *.7; do
  14. url="https://text.causal.agency/${entry%.7}.txt"
  15. title=$(grep '^\.Nm' "$entry" | cut -c 5-)
  16. summary=$(grep '^\.Nd' "$entry" | cut -c 5-)
  17. mtime=$(stat -f '%m' "$entry")
  18. updated=$(date -ju -f '%s' "$mtime" '+%FT%TZ')
  19. cat <<- EOF
  20. <entry>
  21. <title>${title}</title>
  22. <summary>${summary}</summary>
  23. <link href="${url}"/>
  24. <id>${url}</id>
  25. <updated>${updated}</updated>
  26. </entry>
  27. EOF
  28. done
  29. echo '</feed>'