#!/bin/awk -f # Convert sfeed(1) formatted files into an HTML webpage. # Usage: sfeed_html.awk -- FILES... ## Set up variables BEGIN { # Sidebar if (! ASIDE) { ASIDE = envor("SFEED_HTML_ASIDE", "/tmp/sfeed-aside.html") } print > ASIDE # clear out ASIDE in_aside = 0 # Don't show the feed in the sidebar # Formatting if (! DATEFMT) { DATEFMT = envor("SFEED_HTML_DATEFMT", "%F %RZ") } if (! TITLE) { TITLE = envor("SFEED_HTML_TITLE", "Planet ACDW") } if (! SEPARATOR) { SEPARATOR = envor("SFEED_HTML_SEPARATOR", "//") } if (! ALT_LINK_STAMP) { ALT_LINK_STAMP = envor("SFEED_ALT_LINK_STAMP", "&") } if (! ENCLOSURE_STAMP) { ENCLOSURE_STAMP = envor("SFEED_ENCLOSURE_STAMP", "@") } if (! SILO_STAMP) { SILO_STAMP = envor("SFEED_SILO_STAMP", "%") } # Limiting posts... ## by time if (! NOW) { datecmd = "date +%s" datecmd | getline NOW close(datecmd) } if (! FRESHDAYS) { FRESHDAYS = envor("SFEED_FRESHDAYS", 1.5) } if (! STALEDAYS) { STALEDAYS = envor("SFEED_STALEDAYS", 4) } fresh_secs = FRESHDAYS * 24 * 60 * 60 stale_secs = STALEDAYS * 24 * 60 * 60 fresh_age = (NOW - fresh_secs) stale_age = (NOW - stale_secs) ## by number if (! LIMIT) { # If LIMIT == -1, ignore time limit as well. LIMIT = envor("SFEED_LIMIT", 20) } # Alternate URLs for siloed content if (! YOUTUBE_ALT_URL) { YOUTUBE_ALT_URL = envor("SFEED_YOUTUBE_ALT_URL", "https://piped.kavin.rocks") } if (! TWITTER_ALT_URL) { TWITTER_ALT_URL = envor("SFEED_TWITTER_ALT_URL", "https://nitter.net") } if (! REDDIT_ALT_URL) { REDDIT_ALT_URL = envor("SFEED_REDDIT_ALT_URL", "https://libreddit.spike.codes") } # Awk and convenience constants FS = "\t" STDERR = "/dev/stderr" } ## Print HTML header BEGIN { fortunecmd = "fortune" fortunecmd | getline LOGO_TITLE close(fortunecmd) sub(/"/, "", LOGO_TITLE) datecmd = "date -u +'" DATEFMT "'" datecmd | getline UPDATE_TIME close(datecmd) print "" print "" # print "" print "" print "" print "" print "" print "" TITLE "" print "" print "" print "" print "" print "" print "" print "" print "" #
print "
" print "

" printf "" print TITLE "

" print "

last updated at

" print "
" #