#!/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" NEXT = ENVIRON["NEXT"] PREV = ENVIRON["PREV"] } BEGIN { print "" print "" print "" print "" print "" print "" print "" print "" TITLE "" print "" print "" print "" print "
" print "

fwend planet" if (PREV) { p = (PREV ~ /index/ ? 1 : PREV) gsub(/[^0-9]/, "", p) print "p. " (int(p) + 1) } print "

" print "
" if (PREV) { print "prev" } if (NEXT) { print "next" } print "
" } { # Collect fields timestamp = $1 title = $2 link = $3 content = unescape($4) content_type = $5 id = $6 author = $7 enclosure = $8 category = $9 datecmd = "date -d@" timestamp " +%F" datecmd | getline date close(datecmd) print "
" print "" (title ? title : "") print " : " print "
" print "
" if (link && title !~ /linkbudz/ && link != enclosure) { print "read original" } if (enclosure) { print "enclosure" } print "
" print "
" content "
" print "
item information" print "
" 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 "
" print "
" print "
" } END { print "
" if (PREV) { print "prev" } if (NEXT) { print "next" } print "
" print "
" print "sourced from " print "a mug of opml." print "problems? suggestions?" print "
" print "
" print "" print "" } function unescape(t) { gsub(/\\t/, "\t", t) gsub(/\\n/, "\n", t) gsub(/\\\\/, "\\", t) return t }