Add a section_to_subtitle() function similar to theatlantic one - 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 53af7c9fe19b3a80f4a760a801645ac67dac3884
(DIR) parent 8a9fc8de4f7155ba774ae7af73ace7cb9fdc3985
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Fri, 7 Sep 2018 22:16:34
Add a section_to_subtitle() function similar to theatlantic one
Not all section were added... add a TODO about that!
Diffstat:
theguardian/feed.dcgi | 45 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 41 insertions(+), 4 deletions(-)
---
diff -r 8a9fc8de4f71 -r 53af7c9fe19b theguardian/feed.dcgi
--- a/theguardian/feed.dcgi Fri Sep 07 10:22:55 2018 +0200
+++ b/theguardian/feed.dcgi Fri Sep 07 22:16:34 2018 +0200
@@ -6,13 +6,50 @@
FEED_DATE=yes
ARTICLE_CGI="/cgi/theguardian/article.cgi"
+section_to_subtitle()
+{
+ section="$1"
+
+ case "${section}" in
+ # Main sections
+ international) subtitle="World news" ;;
+ uk/commentisfree) subtitle="Opinion" ;;
+ uk/sport) subtitle="Sport" ;;
+ uk/culture) subtitle="Culture" ;;
+ uk/lifeandstyle) subtitle="Lifestyle" ;;
+
+ # News
+ world) subtitle="World news" ;;
+ uk-news) subtitle="UK news" ;;
+ science) subtitle="Science" ;;
+ cities) subtitle="Cities" ;;
+ global-development) subtitle="Global development" ;;
+ football) subtitle="Football" ;;
+ uk/technology) subtitle="Tech" ;;
+ uk/business) subtitle="Business" ;;
+ uk/environment) subtitle="Environment" ;;
+
+ # TODO:
+ # Opinion
+ # Sport
+ # Culture
+ # Lifestyle
+
+ *) subtitle="" ;;
+ esac
+
+ echo "${subtitle}"
+}
+
section="$2"
-#
-# TODO: Should we try to validate section?
-#
+subtitle=$(section_to_subtitle "${section}")
+if [ -z "${subtitle}" ]; then
+ echo "[3|Invalid section|Err|server|port]"
+ exit 1
+fi
echo ""
-echo "The Guardian"
+echo "The Guardian - ${subtitle}"
echo ""
url="https://www.theguardian.com/${section}/rss"