Add support for status replies too - 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 a36d14bf67d0a62b280d672583e4407f259f184e
(DIR) parent fd54e4bc8d5ae69eb8ccdde0f48eb5250b357601
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Sun, 16 Dec 2018 14:19:15
Add support for status replies too
Diffstat:
twitter/tweets.dcgi | 41 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 36 insertions(+), 5 deletions(-)
---
diff -r fd54e4bc8d5a -r a36d14bf67d0 twitter/tweets.dcgi
--- a/twitter/tweets.dcgi Sun Dec 16 11:49:30 2018 +0100
+++ b/twitter/tweets.dcgi Sun Dec 16 14:19:15 2018 +0100
@@ -6,15 +6,21 @@
case "$2" in
+*/status/*)
+ IFS=/ set -- "$2"
+ set -- $*
+ username="$1"
+ id="$3"
+ ;;
*/*)
IFS=/ set -- "$2"
set -- $*
username="$1"
- maxid="$2"
+ id="$2"
;;
*)
username="$2"
- maxid=""
+ id=""
;;
esac
@@ -47,6 +53,27 @@
#
+# Given a username and an id of a status, tscrape the replies
+#
+status()
+{
+ username=$1
+ name=""
+ id=$2
+
+ url="${base}/${username}/status/${id}"
+
+ {
+ echo "<div class=\"user-actions\"";
+ echo " data-screen-name=\"${username}\"";
+ echo " data-name=\"${name}\">";
+ echo "<li class=\"js-stream-item\">";
+ curl -Lgs -- "${url}" ;
+ } | tscrape
+}
+
+
+#
# Format the tscrape output in gph
#
tscrape_gph()
@@ -76,9 +103,9 @@
strftime("%Y-%m-%d %H:%M", t["timestamp"]))
gsub("\\|", "\\|", desc)
- printf("[h|%s|URL:%s/%s/status/%s|server|port]\n",
+ printf("[1|%s|%s?%s/status/%s|server|port]\n",
desc,
- base,
+ cgi,
t["item_username"],
id)
print_tweettext(t["text"])
@@ -109,4 +136,8 @@
echo ""
echo "Twitter"
echo ""
-timeline "${username}" "${maxid}" | tscrape_gph
+if [ "$2" = "status" ]; then
+ status "${username}" "${id}"
+else
+ timeline "${username}" "${id}"
+fi | tscrape_gph