summary refs log tree commit diff stats
path: root/fwendplanet_html.awk
blob: c4ebe0e8135298eba1b616e62e8b05382e949407 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/awk -f
# Convert sfeed(1) formatted files into an HTML webpage for fwends
# Usage: sfeed_html.awk -- FILES...
BEGIN {
	TITLE = "fwend planet"
	FS = "\t"
}

BEGIN {
	print "<!DOCTYPE html>"
	print "<html>"
	print "<head>"
	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 "<title>" TITLE "</title>"
	print "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">"
	print "</head>"
	print "<body>"
	print "<h1>fwend planet</h1>"
}

{
	# Collect fields
	timestamp = $1
	title = $2
	link = $3
	content = unescape($4)
	content_type = $5
	id = $6
	author = $7
	enclosure = $8
	category = $9
	print "<details>"
	print "<summary>" title "</summary>"
	print "<div class=\"links\">"
	print "<a href=\"" link "\">read original</a>"
	if (enclosure) {
		print "<a href=\"" enclosure "\">enclosure</a>"
	}
	print "</div>"
	print "<div class=\"content\">" content "</div>"
	print "<details class=\"info\"><summary>item information</summary>"
	print "timestamp: " timestamp
	print "title: " title
	print "link: " link
	print "content_type: " content_type
	print "id: " id
	print "author: " author
	print "enclosure: " enclosure
	print "category: " category
	print "</details>"
	print "</details>"
}

END {
	print "<a href=\"mailto:fwends@me.acdw.net\">email acdw</a> if you have issues."
	print "</body>"
	print "</html>"
}


function unescape(t)
{
	gsub(/\\t/, "\t", t)
	gsub(/\\n/, "\n", t)
	gsub(/\\\\/, "\\", t)
	return t
}