summaryrefslogtreecommitdiffstats
path: root/.local/bin/idea
blob: c3fc9b43c515d36b91b63ce3f565962f99ef92a1 (plain)
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
#!/bin/sh -e

if [ -z "$1" ]; then
	thought=$(cat -)
elif [ -f "$1" ]; then
	thought=$(cat "$1")
else
	thought="$*"
fi

thought="$(printf "%s" "${thought}" | sed '{s#^#\\t\\t\\t\\t\\t#;s#^\\t\\t\\t\\t\\t$#\\t\\t\\t\\t</p>\\\n\\t\\t\\t\\t<p>#;s#$#\\#;}')"
date=$(date '+%a, %d %b %Y %H:%M')
html_fmt='\t\t\t\t<h3>'"${date}"'</h3>\
\t\t\t\t<p>\
'"${thought}"'
\t\t\t\t</p>\
'
rss_fmt='\\t<item>\
\t  <title>'"${date}"'</title>\
\t  <pubDate>'"${date} $(date '+%Z')"'</pubDate>\
\t  <link>http://jozan.org/thoughts.html</link>\
\t  <guid isPermalink="false">'"$(uuidgen)"'</guid>\
\t  <description>\
\t\t<![CDATA[\
\t\t\t\t<p>\
'"${thought}"'
\t\t\t\t</p>\
\t\t]]>\
\t  </description>\
\t</item>
'

case $(hostname -s) in
	mother|po-rbo) sed="sed -i" ;;
	mars) sed="sed -i ''" ;;
esac

$sed -e '/<\/channel>/i '"${rss_fmt}" \
	"$HOME"/dev/web/joe-www/thoughts.xml
$sed -e '/<!-- thoughts here -->$/{n;s#^#'"${html_fmt}"'#;}' \
	"$HOME"/dev/web/joe-www/thoughts.html
git -C "$HOME"/dev/web/joe-www add -u
git -C "$HOME"/dev/web/joe-www commit -m "Thought: ${date}"
git -C "$HOME"/dev/web/joe-www push

vps