~.town / ~cel

newsgroups.html.sh

newsgroups.html.sh: newsgroups.html

#!/bin/sh
export TITLE="Newsgroups"

list_news() {
	(echo LIST NEWSGROUPS; echo LIST) | nc localhost 119
}

./template.html.sh <<EOF
<h3>tilde.town Newsgroups</h3>

<p>Generated: $(date)</p>

<table>
	<thead>
		<tr>
			<th>Group</th>
			<th>Total</th>
			<th>Current</th>
			<th>Description</th>
		</tr>
	</thead>
<tbody>
$(list_news | awk '
BEGIN {
	OFS = "</td><td>"
}
!in_list && $1 == "215" {
	in_list = 1
	list++
	next
}
in_list && /^\./ {
	in_list = 0
	next
}
in_list && list == 1 {
	group = $1
	sub(/[^		]*[		]*/, "")
	desc = $0
	descs[group] = desc
	next
}
in_list && list == 2 {
	group = $1
	high = +$2
	low = +$3
	status = $4
	current = high - low + 1
	desc = descs[group]

	if (status ~ "^n") {
		# Skip groups with no posting
		next
	}

	print "<tr><td>" group, high, current, desc "</td></tr"
}
')
</tbody>
</table>

<p>Due to the
<a href="https://github.com/nathanielksmith/puppet-tilde/pull/27">configuration
of the NNTP server</a>, all messages before 2015-09-21 have permanently
expired. However, if you include with your new messages an Expires
header with a date in the future, you can postpone their expiration
indefinitely.</p>
EOF