about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xsfeed_html.awk123
1 files changed, 71 insertions, 52 deletions
diff --git a/sfeed_html.awk b/sfeed_html.awk index 9af5b2e..70226a7 100755 --- a/sfeed_html.awk +++ b/sfeed_html.awk
@@ -70,53 +70,8 @@ BEGIN {
70 STDERR = "/dev/stderr" 70 STDERR = "/dev/stderr"
71} 71}
72 72
73## Print HTML header
74BEGIN { 73BEGIN {
75 fortunecmd = "fortune" 74 html_top()
76 fortunecmd | getline LOGO_TITLE
77 close(fortunecmd)
78 sub(/"/, "", LOGO_TITLE)
79 datecmd = "date -u +'" DATEFMT "'"
80 datecmd | getline UPDATE_TIME
81 close(datecmd)
82 print "<!DOCTYPE html>"
83 print "<html>"
84 # <head>
85 print "<head>"
86 print "<meta charset=\"utf-8\">"
87 print "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
88 print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
89 print "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
90 print "<title>" TITLE "</title>"
91 print "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">"
92 print "<link rel=\"shortcut icon\" type=\"image/png\" href=\"mars-eyes.png\">"
93 print "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"rss (full)\" href=\"feeds.xml\">"
94 print "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"rss (short)\" href=\"feeds-short.xml\">"
95 print "<link rel=\"alternate\" type=\"application/xml\" title=\"opml\" href=\"feeds.opml\">"
96 print "<link rel=\"alternate\" type=\"text/plain\" title=\"twtxt\" href=\"feeds.txt\">"
97 print "</head>"
98 print "<body>"
99 # <header>
100 print "<header id=\"page-header\">"
101 print "<h1>"
102 printf "<a id=\"logo\" href=\"index.html\"><img src=\"mars-eyes.png\""
103 printf " title=\"%s\" ", LOGO_TITLE
104 printf "width=\"40\" height=\"39\""
105 print "alt=\"mars, but with eyes\" /></a>"
106 print TITLE "</h1>"
107 print "<p id=\"last-updated\">last updated at <time>" UPDATE_TIME "</time></p>"
108 print "</header>"
109 # <nav>
110 print "<nav id=\"page-nav\">"
111 print "<a href=\"#\" id=\"stalebutton\">hide stale</a>", SEPARATOR
112 print "<a href=\"feeds-short.xml\">rss</a>", SEPARATOR
113 print "<a href=\"feeds.html\">all</a>", "(<a href=\"feeds.xml\">rss</a>)", SEPARATOR
114 print "<a href=\"feeds.txt\">twtxt</a>", SEPARATOR
115 print "<a href=\"feeds.opml\">opml</a>"
116 print "</nav>"
117 # first part of <main>
118 print "<main>"
119 print "<section id=\"list\">"
120} 75}
121 76
122FNR == 1 { 77FNR == 1 {
@@ -142,8 +97,11 @@ FNR == 1 {
142 stamp = "." 97 stamp = "."
143 buf = "" 98 buf = ""
144 ni = 0 99 ni = 0
100 stale_total += stale_count
145 stale_count = 0 101 stale_count = 0
102 fresh_total += fresh_count
146 fresh_count = 0 103 fresh_count = 0
104 item_total += item_count
147 item_count = 0 105 item_count = 0
148 file_count++ 106 file_count++
149 siloed = 0 107 siloed = 0
@@ -206,7 +164,7 @@ FNR == 1 {
206 if ((silo != id) && (id != enclosure) && (id ~ /^https?:/)) { 164 if ((silo != id) && (id != enclosure) && (id ~ /^https?:/)) {
207 # alternate links (comments, etc.) 165 # alternate links (comments, etc.)
208 stamp = ALT_LINK_STAMP 166 stamp = ALT_LINK_STAMP
209 print_link(id, "alternate link", stamp) 167 print_link(silo_link(id), "alternate link", stamp)
210 } 168 }
211 bufprint("</td>") 169 bufprint("</td>")
212 # Title 170 # Title
@@ -262,13 +220,16 @@ function end_file()
262 getline feed_url < URLS 220 getline feed_url < URLS
263 getline site_url < URLS 221 getline site_url < URLS
264 if (site_url) { 222 if (site_url) {
265 printf "<a class=\"site-url\" href=\"%s\">%s</a>\n", site_url, (yt ? "chan" : "site") 223 print_link(site_url, "", (yt ? "chan" : "site"), "site-url")
224 # printf "<a class=\"site-url\" href=\"%s\">%s</a>\n", site_url, (yt ? "chan" : "site")
266 } 225 }
267 if (feed_url) { 226 if (feed_url) {
268 printf "<a class=\"feed-url\" href=\"%s\">feed</a>\n", feed_url 227 print_link(feed_url, "", "feed", "feed-url")
228 # printf "<a class=\"feed-url\" href=\"%s\">feed</a>\n", feed_url
269 } 229 }
270 # Top link 230 # Top link
271 printf "<a class=\"top\" href=\"#\">top</a>" 231 print_link("#", "back to top", "top", "top")
232 # printf "<a class=\"top\" href=\"#\">top</a>"
272 printf "</nav>" 233 printf "</nav>"
273 printf "</header>\n" 234 printf "</header>\n"
274 # Feed entries 235 # Feed entries
@@ -297,9 +258,67 @@ function html_escape(t)
297 return t 258 return t
298} 259}
299 260
300function print_link(href, title, text) 261function html_top()
262{
263 # Print HTML header
264 fortunecmd = "fortune"
265 fortunecmd | getline LOGO_TITLE
266 close(fortunecmd)
267 sub(/"/, "", LOGO_TITLE)
268 datecmd = "date -u +'" DATEFMT "'"
269 datecmd | getline UPDATE_TIME
270 close(datecmd)
271 print "<!DOCTYPE html>"
272 print "<html>"
273 # <head>
274 print "<head>"
275 print "<meta charset=\"utf-8\">"
276 print "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
277 print "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">"
278 print "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
279 print "<title>" TITLE "</title>"
280 print "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">"
281 print "<link rel=\"shortcut icon\" type=\"image/png\" href=\"mars-eyes.png\">"
282 print "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"rss (full)\" href=\"feeds.xml\">"
283 print "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"rss (short)\" href=\"feeds-short.xml\">"
284 print "<link rel=\"alternate\" type=\"application/xml\" title=\"opml\" href=\"feeds.opml\">"
285 print "<link rel=\"alternate\" type=\"text/plain\" title=\"twtxt\" href=\"feeds.txt\">"
286 print "</head>"
287 print "<body>"
288 # <header>
289 print "<header id=\"page-header\">"
290 print "<h1>"
291 printf "<a id=\"logo\" href=\"index.html\"><img src=\"mars-eyes.png\""
292 printf " title=\"%s\" ", LOGO_TITLE
293 printf "width=\"40\" height=\"39\""
294 print "alt=\"mars, but with eyes\" /></a>"
295 print TITLE "</h1>"
296 print "<p id=\"last-updated\">last updated at <time>" UPDATE_TIME "</time></p>"
297 print "</header>"
298 # <nav>
299 print "<nav id=\"page-nav\">"
300 print "<a href=\"#\" id=\"stalebutton\">hide stale</a>", SEPARATOR
301 print "<a href=\"feeds-short.xml\">rss</a>", SEPARATOR
302 print "<a href=\"feeds.html\">all</a>", "(<a href=\"feeds.xml\">rss</a>)", SEPARATOR
303 print "<a href=\"feeds.txt\">twtxt</a>", SEPARATOR
304 print "<a href=\"feeds.opml\">opml</a>"
305 print "</nav>"
306 # first part of <main>
307 print "<main>"
308 print "<section id=\"list\">"
309}
310
311function print_link(href, title, text, class)
301{ 312{
302 bufprint("<a href=\"" href "\" title=\"" title "\" target=\"_blank\">" text "</a>", 0) 313 link = "<a href=\"" href "\""
314 if (class) {
315 link = link " class=\"" class "\""
316 }
317 link = link " title=\"" title "\""
318 link = link "rel=\"nofollow\" target=\"_blank\">"
319 link = link text
320 link = link "</a>"
321 bufprint(link, 0)
303} 322}
304 323
305function silo_class(link) 324function silo_class(link)