Add a feed DCGI for theatlantic.com - gophercgis - Collection of gopher CGI/DCGI for geomyidae
(HTM) hg clone https://bitbucket.org/iamleot/gophercgis
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) changeset af699209ba08b4fd020f913149c4bb5e7a41d56b
(DIR) parent 339fa69fe9b4346b793f1807dcc76644ec76dadf
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Tue, 28 Aug 2018 00:08:57
Add a feed DCGI for theatlantic.com
Diffstat:
theatlantic/feed.dcgi | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
---
diff -r 339fa69fe9b4 -r af699209ba08 theatlantic/feed.dcgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/theatlantic/feed.dcgi Tue Aug 28 00:08:57 2018 +0200
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+
+ARTICLE_CGI="/cgi/theatlantic/article.cgi"
+
+
+section="$2"
+case "${section}" in
+politics|business|entertainment|international|technology|national|health| \
+video|education|family|science|letters|news|press-releases|newsletters| \
+membership)
+ ;;
+*)
+ # TODO: handle more sections
+ exit 1
+ ;;
+esac
+
+echo ""
+echo "The Atlantic"
+echo ""
+
+url="https://www.theatlantic.com/feed/channel/${section}/"
+/usr/pkg/bin/curl -gs "${url}" |
+{ /usr/pkg/bin/xmllint --format - 2>/dev/null ; } |
+awk '
+/<feed/,/<rights>/ {
+ next # ignore all non-entry-s
+}
+
+/<title/ {
+ gsub("<title type=\"html\">", "")
+ gsub("</title>", "")
+ gsub(/^[[:space:]]+/, "")
+ gsub(/[[:space:]]+$/, "")
+ title = $0
+}
+
+/<link/ {
+ gsub("<link href=\"", "")
+ gsub("\" rel=\"alternate\"/>", "")
+ gsub(/^[[:space:]]+/, "")
+ gsub(/[[:space:]]+$/, "")
+ link = $0
+}
+
+title && link {
+ gsub("\\|", "\\|", title)
+ gsub("\\|", "\\|", link)
+
+ printf("[0|%s|'"${ARTICLE_CGI}?"'%s|server|port]\n", title, link)
+
+ title = link = ""
+}
+'
+
+echo ""