summaryrefslogtreecommitdiff
path: root/src/feed
blob: aa42899cdd9ad335d0dac740aa6ee5e87176f921 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
set -euo pipefail


usage() {
	echo 'Usage: feed BASECONF GLOBALCONF FILENAME.sortdata...'
}

BASECONF="${1:-}"
GLOBALCONF="${2:-}"
FILES="${3:-}"
eval "$(assert-arg -- "$BASECONF"   'BASECONF')"
eval "$(assert-arg -- "$GLOBALCONF" 'GLOBALCONF')"
eval "$(assert-arg -- "$FILES"      'FILENAME.sortdata...')"
. "$(realpath -- "$BASECONF")"
. "$(realpath -- "$GLOBALCONF")"
shift
shift


pre() {
	cat <<EOF | sed '/^$/d'
<feed
    xmlns="http://www.w3.org/2005/Atom"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xml:lang="en">
  <link rel="self"      type="application/atom+xml" href="$feed_url_absolute" />
  <link rel="alternate" type="text/html"            href="$feed_alternate_url_absolute" hreflang="en" />
  <title>$site_name_html</title>
  <subtitle>$feed_title_html</subtitle>
  <id>$feed_url_absolute</id>
  <updated>$now_iso</updated>

  <author>
    <name>$author</name>
    <email>$email</email>
  </author>
EOF
}

post() {
	printf '</feed>\n'
}

pre
find "$@" |
	xargs cat |
	sort -nr |
	xargs cat |
	sed 's/\.conf$/.feedentry/' |
	xargs cat
post