💾 Archived View for midnight.pub › replies › 516 captured on 2023-04-26 at 17:20:30. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
Thanks. I'm actually embarrassed right now because I think I should have thought of that myself. And if I use printf instead of echo I can pass in the title and description as arguments along with the filename. Then again echo would probably work fine, too, but I'm used to printf because of my feedgen script.
I use this to generate Atom feeds from a tab-delimited file. Though the usage function needs updating.
#!/bin/sh -e main() { test -n "$1" || usage test -n "$2" || usage url="$1" head="$2" entries="$3" feed_start "$head" process_entries "$url" "$entries" feed_end "" } usage() { echo "usage:\n\t${0##*/} <header file> <entries file>" >&2 echo "\tHeader file is tab-delimited: title, subtitle, link, name, email." >&2 echo "\tEntries file is tab-delimited: title, link, id, updated, summary." >&2 echo "\tPlease note that entries file will be read in reverse order." >&2 exit 1 } feed_start() { title=`cut -f 1 ${1}` subtitle=`cut -f 2 ${1}` link=`cut -f 3 ${1}` updated=`date "+%Y-%m-%dT%H:%M:%S.000-05:00"` name=`cut -f 4 ${1}` email=`cut -f 5 ${1}` printf '<?xml version="1.0" encoding="utf-8"?>\n' printf '<feed xmlns="http://www.w3.org/2005/Atom">\n' printf '\t<title>%s</title>\n' "$title" printf '\t<subtitle>%s</subtitle>\n' "$subtitle" printf '\t<link href="%s"/>\n' "$link" printf '\t<updated>%s</updated>\n' "$updated" printf '\t<author>\n' printf '\t\t<name>%s</name>\n' "$name" printf '\t\t<email>%s</email>\n' "$email" printf '\t</author>\n' printf '\t<id>%s</id>\n' "$link" } process_entries() { url=$1 while IFS= read -r line do write_entry "$url" "$line" done < $2 } write_entry() { url=$1 title=`echo "$2" | cut -f 3` link=`echo "$2" | cut -f 2` updated=`echo "$2" | cut -f 1` summary=`echo "$2" | cut -f 4` printf '\t<entry>\n' printf '\t\t<title>%s</title>\n' "$title" printf '\t\t<link rel="alternate" href="%s%s"/>\n' "$url" "$link" printf '\t\t<id>%s%s</id>\n' "$url" "$link" printf '\t\t<updated>%sT23:58:00.000-0500</updated>\n' "$updated" printf '\t\t<summary>%s</summary>\n' "$summary" printf '\t</entry>\n' } feed_end() { printf '</feed>\n' } main "$@"
Btw, pandoc has support for templates.
m4_include(website.m4) m4_define([__title], []) m4_define([__description], []) m4_include(article-header.html) <section> $body$ </section> m4_include(footer.html)
(Or you might not even need to use m4 if you used pandoc's templates.)
YW♥
blog.webb.page is annoying but somewhat readable, since the text is hardwrapped.
Which is definitely a very bad idea to do on Gemini, with Gemini text, but good for Markdown.