Add a feed DCGI for Guardian - 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 5e979990c434ec5a842f58997dcecd336f9fda30
 (DIR) parent e81f0327b4feecc17e1bc034fc7c462f6b9643d7
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Tue, 28 Aug 2018 00:39:02 
       
       Add a feed DCGI for Guardian
       
       Diffstat:
        theguardian/feed.dcgi |  47 +++++++++++++++++++++++++++++++++++++++++++++++
        1 files changed, 47 insertions(+), 0 deletions(-)
       ---
       diff -r e81f0327b4fe -r 5e979990c434 theguardian/feed.dcgi
       --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
       +++ b/theguardian/feed.dcgi     Tue Aug 28 00:39:02 2018 +0200
       @@ -0,0 +1,47 @@
       +#!/bin/sh
       +
       +
       +ARTICLE_CGI="/cgi/theguardian/article.cgi"
       +
       +
       +section="$2"
       +#
       +# TODO: Should we try to validate section?
       +#
       +
       +echo ""
       +echo "The Guardian"
       +echo ""
       +
       +url="https://www.theguardian.com/${section}/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 ""