Add a feed DCGI in order to list most recent stories via RSS feed - 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 95678d96a11538682aaeed4a12d6c3ccd87a2b68
(DIR) parent 2043a831781bdd70874b850c7df914c90ffb9e4c
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 26 Aug 2018 00:02:27
Add a feed DCGI in order to list most recent stories via RSS feed
Diffstat:
technologyreview/feed.dcgi | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff -r 2043a831781b -r 95678d96a115 technologyreview/feed.dcgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/technologyreview/feed.dcgi Sun Aug 26 00:02:27 2018 +0200
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+
+ARTICLE_CGI="/cgi/technologyreview/article.cgi"
+
+echo ""
+echo "MIT Technology Review"
+echo ""
+
+url="https://www.technologyreview.com/stories.rss"
+/usr/pkg/bin/curl -gs "${url}" |
+awk '
+/<rss/,/<item/ {
+ next # ignore all non-item-s
+}
+
+/<title/ {
+ gsub("</?title>", "")
+ gsub(/^[[:space:]]+/, "")
+ gsub(/[[:space:]]+$/, "")
+ title = $0
+}
+
+/<link/ {
+ gsub("</?link>", "")
+ 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 ""