Add support for pagination (next/prev pages) - 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 5bd3e98e0ce1556c5a9dd1bcf5b18c9d3bb79983
(DIR) parent cb6b16c1ac5ac018ff8acfe8505ade3fff0e02b6
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Mon, 17 Dec 2018 00:11:35
Add support for pagination (next/prev pages)
Diffstat:
mastodon/mastodon.dcgi | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff -r cb6b16c1ac5a -r 5bd3e98e0ce1 mastodon/mastodon.dcgi
--- a/mastodon/mastodon.dcgi Mon Dec 17 00:00:48 2018 +0100
+++ b/mastodon/mastodon.dcgi Mon Dec 17 00:11:35 2018 +0100
@@ -42,6 +42,17 @@
print_tootcontent(t["content"])
}
+ /^<link href=/ {
+ if (match($0, /<link href=.+ rel=.next.>$/)) {
+ next_link = substr($0, RSTART + 12, RLENGTH - 25)
+ }
+
+ if (match($0, /<link href=.+ rel=.prev.>$/)) {
+ prev_link = substr($0, RSTART + 12, RLENGTH - 25)
+ }
+
+ }
+
{
if (match($0, /class="status__relative-time/)) {
match($0, />[^<]+<\/time>$/)
@@ -75,6 +86,20 @@
toot["content"] = ""
}
}
+
+ END {
+ print "t"
+
+ if (next_link) {
+ printf("[1|>> Next|%s?%s|server|port]\n",
+ cgi, next_link)
+ }
+
+ if (prev_link) {
+ printf("[1|<< Prev|%s?%s|server|port]\n",
+ cgi, prev_link)
+ }
+ }
'
}