about summary refs log tree commit diff stats
path: root/sfeed_weed.awk
blob: d3a463c679b3d8b329dd26fcc68990e4bbe56f77 (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
#!/bin/awk -f
# convert weeds files to an html page
BEGIN {
	FS = "\t"
	print "<!DOCTYPE html>"
	print "<html>"
	print "<head><title>Weed Garden</title>"
	print "<meta charset=\"utf-8\">"
	print "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
	print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
	print "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
	print "<link rel=\"stylesheet\" type=\"text/css\" href=\"weed.css\">"
	print "</head>"
	print "<body>"
}

{
	timestamp = $1
	title = $2
	link = $3
	content = $4
	content_type = $5
	id = $6
	author = $7
	enclosure = $8
	category = $9
	datecmd = "date -u -d \"@" timestamp "\" '+%F (%a) %R'"
	datecmd | getline published
	close(datecmd)
	gsub(/\\t/, "\t", content)
	gsub(/\\n/, "\n", content)
	gsub(/\\/, "\\", content)
	print "<article>"
	print "<header><h2>" title "</h2>"
	print "<time>" published "</time></header>"
	print content
	print "</article>"
}

END {
	print "</body>"
	print "</html>"
}