git ssb

0+

cel / gitfeed



Tree: f0c709532d3d86f2e3360b5d43577c65562665f9

Files: f0c709532d3d86f2e3360b5d43577c65562665f9 / xml.awk

1602 bytesRaw
1function escape_html(text) {
2 gsub(/&/, "\\&", text)
3 gsub(/</, "\\&lt;", text)
4 gsub(/>/, "\\&gt;", text)
5 gsub(/"/, "\\&quot;", text)
6 return text
7}
8
9function get_value() {
10 sub(/^[^ ]* */, "")
11 return $0
12}
13
14function end() {
15 print "&lt;/pre&gt;</content>"
16 print "</entry>"
17}
18
19$1 == "entry" {
20 if (in_content && $2 == end_of_content) {
21 in_content = 0
22 in_stat = 0
23 end()
24 }
25
26 title = ""
27 id = ""
28 name = ""
29 email = ""
30 updated = ""
31
32 next
33}
34
35$1 == "stat" && $2 == end_of_content {
36 in_stat = 1
37 next
38}
39
40$1 == "content" {
41 end_of_content = $2
42 print "<entry>"
43 print " <title>" escape_html(title) "</title>"
44 print " <id>" id "</id>"
45 print " <author>"
46 print " <name>" escape_html(name) "</name>"
47 print " <email>" escape_html(email) "</email>"
48 print " </author>"
49 print " <updated>" escape_html(updated) "</updated>"
50 printf " <content type=\"html\">&lt;pre&gt;"
51 in_content = 1
52 next
53}
54
55in_stat && /^ [^ ]* *\|/ {
56 if (match($0, /.\html\.sh /)) {
57 sub(/\.html\.sh /, ".html ")
58 suffix = ".sh"
59 } else {
60 suffix = ""
61 }
62 sub(/[^ ][^ ]*/, "<a href=\"" site "&\">&</a>" suffix)
63}
64
65in_stat && / \+*-*$/ {
66 sub(/ \++/, "<span style=\"color:green\">&</span>")
67 sub(/-+$/, "<span style=\"color:red\">&</span>")
68}
69
70in_content {
71 print escape_html($0)
72 next
73}
74
75$1 == "title" { title = get_value() }
76$1 == "name" { name = get_value() }
77$1 == "email" { email = get_value() }
78$1 == "id" {
79 id = get_value()
80 id = site ".git/objects/" substr(id, 1, 2) "/" substr(id, 3)
81}
82$1 == "updated" {
83 updated = $2 "T" $3 substr($4, 1, 3) ":" substr($4, 3, 2)
84}
85
86END {
87 if (in_content)
88 end()
89}
90

Built with git-ssb-web