Add support for (back) pagination - 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 1190beed612e9034835feb498d889280e81aa407
(DIR) parent 42f5cfb9373032ff8b311e4e9ae56b1c83a6c969
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 27 Aug 2018 00:30:05
Add support for (back) pagination
Diffstat:
internazionale/sections.dcgi | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff -r 42f5cfb93730 -r 1190beed612e internazionale/sections.dcgi
--- a/internazionale/sections.dcgi Sun Aug 26 23:51:10 2018 +0200
+++ b/internazionale/sections.dcgi Mon Aug 27 00:30:05 2018 +0200
@@ -2,31 +2,40 @@
ARTICLE_CGI="/cgi/internazionale/article.cgi"
+CGI="/cgi/internazionale/sections.dcgi"
-section="$2"
+section="${2%%/*}"
case "${section}" in
ultimi-articoli | reportage | opinioni | savagelove )
- url="https://data.internazionale.it/stream_data/items/${section}/0/0/$(date +'%Y-%m-%d_%H-%M-%S').json"
;;
*)
exit 1
;;
esac
+if [ "${2}" != "${2##*/}" ]; then
+ date="${2##*/}"
+else
+ date="$(date +'%Y-%m-%d_%H-%M-%S')"
+fi
+
echo ""
echo "Internazionale"
echo ""
+url="https://data.internazionale.it/stream_data/items/${section}/0/0/${date}.json"
/usr/bin/ftp -V -o - "${url}" |
/usr/pkg/bin/jq -r '
-.items[] | (
+( .items[] | (
"[0|" +
"\(.title | gsub("\\|"; "\\|") )" + "|" +
"'"${ARTICLE_CGI}?"'" + "https://www.internazionale.it" +
"\(.url | gsub("\\|"; "\\|") )" + "|" +
"server|port]"
-)
+)),
+"t",
+"[1|<< Older articles|'"${CGI}?${section}/"'\(.datetime | gsub(" "; "_"))|server|port]"
'
echo ""