Add ACM Queue CGI and DCGI for articles of last issue - 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 9c5c58307dd6991ff1fd086ec89e6cdf067236fa
(DIR) parent 5e979990c434ec5a842f58997dcecd336f9fda30
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Wed, 29 Aug 2018 00:04:44
Add ACM Queue CGI and DCGI for articles of last issue
Diffstat:
acmqueue/article.cgi | 26 ++++++++++++++++++++++++++
acmqueue/feed.dcgi | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff -r 5e979990c434 -r 9c5c58307dd6 acmqueue/article.cgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/acmqueue/article.cgi Wed Aug 29 00:04:44 2018 +0200
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+
+#
+# Render HTML as text
+#
+html_to_text()
+{
+ # Nonexistent proxy to block HTTP requests
+ export http_proxy="http://localhost:31283128"
+
+ browser="/usr/pkg/bin/w3m"
+
+ browser_options="-dump -T text/html -no-cookie -cols 72"
+ browser_options="${browser_options} -o display_link=false"
+ browser_options="${browser_options} -o display_link_number=false"
+ browser_options="${browser_options} -o display_image=false"
+
+ env LANG=en_US.UTF-8 ${browser} ${browser_options}
+}
+
+
+url=$2
+/usr/pkg/bin/curl -sL "${url}" |
+ sed -ne '/^<h1 class="hidetitle">/p' |
+ html_to_text
diff -r 5e979990c434 -r 9c5c58307dd6 acmqueue/feed.dcgi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/acmqueue/feed.dcgi Wed Aug 29 00:04:44 2018 +0200
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+
+ARTICLE_CGI="/cgi/acmqueue/article.cgi"
+
+
+echo ""
+echo "ACM Queue"
+echo ""
+
+url="https://queue.acm.org/rss/feeds/queuecontent.xml"
+/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)
+ gsub("&", "\\&", link)
+
+ printf("[0|%s|'"${ARTICLE_CGI}?"'%s|server|port]\n", title, link)
+
+ title = link = ""
+}
+'
+
+echo ""