mk-atom.sh - tgtimes - The Gopher Times
(HTM) git clone git://bitreich.org/tgtimes git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tgtimes
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
---
mk-atom.sh (1095B)
---
1 #!/bin/sh
2
3 archivebaseuri="gopher://bitreich.org/9/tgtimes/archive"
4
5 releases="$(find . -type d | tail -n +2 | cut -d'/' -f 2-)"
6
7 cat news.atom.head.xml
8
9 updated="$(date +%FT%T%z)"
10 printf "\t<updated>%s</updated>\n" "${updated}"
11
12 for release in $releases;
13 do
14 uri="${archivebaseuri}/${release}"
15 printf "\t\t<entry>\n"
16 printf "\t\t<id>%s</id>\n" "${uri}"
17 printf "\t\t<title><![CDATA[%s]]></title>\n" "${release}"
18 printf "\t\t<author><name>The Gopher Times Authors</name></author>\n"
19
20 cd ${release}
21 txtedition=$(find . -type f -name "*.txt" | cut -d'/' -f 2-)
22 pdfedition=$(find . -type f -name "*.pdf" | cut -d'/' -f 2-)
23 printf "\t\t<content type=\"text\"><![CDATA["
24 cat $txtedition
25 printf "]]></content>\n"
26
27 lastmodified=$(stat --printf="%Y" ${txtedition})
28 lastupdated="$(date +%FT%T%z -d @${lastmodified})"
29 printf "\t\t<updated>%s</updated>\n" "${lastupdated}"
30 mimetype="$(file --mime-type -b "${pdfedition}")"
31 printf "\t\t<link type=\"%s\" href=\"%s/%s\" />\n" \
32 "${mimetype}" \
33 "${uri}" \
34 "${pdfedition}"
35 cd ..
36 printf "\t\t</entry>\n"
37 done
38
39 cat news.atom.footer.xml
40