💾 Archived View for celehner.com › 2021 › 07 › oldcomp › entry.awk captured on 2023-09-08 at 16:02:15.
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
function escape_html(text) { gsub(/&/, "\\&", text) gsub(/</, "\\<", text) gsub(/>/, "\\>", text) gsub(/"/, "\\"", text) return text } BEGIN { self = base name print "<?xml version=\"1.0\" encoding=\"utf-8\"?>" print "<feed xmlns=\"http://www.w3.org/2005/Atom\">" print " <title>" title "</title>" #print " <link rel=\"alternate\" type=\"text/html\" href=\"" base "\"/>" print " <link rel=\"self\" type=\"application/atom+xml\" href=\"" self "\"/>" print " <updated>" strftime("%FT%TZ") "</updated>" print " <id>" self "</id>" } FNR == 1 { if (NR != 1) { end_entry() } id = base FILENAME datecmd = "date -Isec -r " FILENAME datecmd | getline time close(datecmd) print "<entry>" print " <title>" FILENAME "</title>" print " <id>" id "</id>" print " <link rel=\"alternate\" href=\"" id "\" />" print " <author><name>" author_name "</name><email>" author_email "</email></author>" print " <updated>" time "</updated>" printf " <content type=\"html\"><pre>" } { print escape_html(escape_html($0)) } function end_entry() { print "</pre></content>" print "</entry>" } END { end_entry() print "</feed>" }