Calendar: remove past event
[tails/test.git] / bin / generate-Tor-blog-post
blob0b5e5601981a85c73f03ad87c00bff2ed1ced998
1 #!/bin/sh
3 set -eu
5 error () {
6 echo "error: ${*}" >&2
7 exit 1
10 USAGE="Usage: $(basename "$0") VERSION"
12 [ $# -eq 1 ] || error "$USAGE"
14 VERSION="$1"
16 TMPFILE=$(mktemp /tmp/tor-blog-post-XXXXXX.html)
18 ikiwiki --setup ikiwiki.setup \
19 --render "wiki/src/news/version_${VERSION:?}.mdwn" \
20 | tidy --quiet yes \
21 --mute MISSING_ENDTAG_BEFORE,INSERTING_TAG,DISCARDING_UNEXPECTED,UNKNOWN_ENTITY,MISSING_ATTRIBUTE,TRIM_EMPTY_ELEMENT,STRING_CONTENT_LOOKS \
22 --wrap 99999 \
23 | sed '0,/^<div id="content" role="main">$/d' \
24 | sed '/^<div id="footer" class="pagefooter" role="contentinfo">$/,$d' \
25 | sed '/^<div class="toc">$/,+7d'\
26 | sed '/^<p><img [^<>]*\/><\/p>$/d' \
27 | sed '/^<div[^<>]*\>/d' \
28 | sed '/^<\/div>$/d' \
29 | sed 's@<a name[^<>]*></a>@@g' \
30 | sed 's@href="\.\./@href="https://tails.boum.org/@g' \
31 | sed 's@src="\./@src="https://tails.boum.org/news/@g' \
32 | sed 's@\(\.en\)\?.html@/@g' \
33 > "$TMPFILE"
35 cat >> "$TMPFILE" <<EOF
36 <h1>Support and feedback</h1>
37 <p>For support and feedback, visit the <a href="https://tails.boum.org/support/">Support section</a> on the Tails website.</p>
38 EOF
40 echo "Done! The draft Tor blog post was written to $TMPFILE"