Use w3m to format the content - 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 4c6456d3df0b10356c6650b7c4717f11a25c7984
(DIR) parent 53e823eeeb47d72dd8af481c5ff4d78046874224
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Tue, 11 Sep 2018 13:10:53
Use w3m to format the content
Diffstat:
common/feed.sh | 40 ++++++++++++++++++++++++++++++++++------
1 files changed, 34 insertions(+), 6 deletions(-)
---
diff -r 53e823eeeb47 -r 4c6456d3df0b common/feed.sh
--- a/common/feed.sh Mon Sep 10 15:08:03 2018 +0200
+++ b/common/feed.sh Tue Sep 11 13:10:53 2018 +0200
@@ -13,6 +13,36 @@
-v feed_content="${FEED_CONTENT}" \
-v cgi="${ARTICLE_CGI}" \
-F '\t' '
+ function print_content(c, c_type)
+ {
+ gsub("\\\\n", "\n", c)
+ gsub("\\\\t", " ", c)
+ gsub("\\\\\\\\", "\\", c)
+
+ # Nonexistent proxy to block HTTP requests
+ cmd = "http_proxy=\"http://localhost:31283128\""
+
+ # UTF-8
+ cmd = cmd " LANG=en_US.UTF-8"
+
+ if (c_type == "html") {
+ cmd = cmd " /usr/pkg/bin/w3m -T text/html"
+ } else {
+ cmd = cmd " /usr/pkg/bin/w3m -T text/plain"
+ }
+ cmd = cmd " -config /dev/null"
+ cmd = cmd " -dump -no-cookie -cols 72"
+ cmd = cmd " -o display_link=false"
+ cmd = cmd " -o display_link_number=false"
+ cmd = cmd " -o display_image=false"
+ cmd = cmd " -o pseudo_inlines=false"
+
+ cmd = cmd " | sed -e \"s/^/t/\""
+
+ print c | cmd
+ close(cmd)
+ }
+
{
timestamp = $1
title = $2
@@ -42,12 +72,10 @@
}
if (feed_content && content) {
- gsub("^", "t", content)
- gsub("\\\\n", "\nt", content)
- gsub("\\\\t", " ", content)
- gsub("\\\\\\\\", "\\", content)
-
- printf("%s\n\n", content)
+ print ""
+ print_content(content, content_type)
+ print ""
+ print ""
}
}
'