Fix status handling - 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 1fcd81f7437f77d77ca11a0377770af69b8b4094 (DIR) parent 51892ddc6fe734cdb206ed9062e036a318a0574b (HTM) Author: Leonardo Taccari <iamleot@gmail.com> Date: Wed, 19 Dec 2018 17:16:05 Fix status handling (*/status/* URL responses are in HTML so jq should not be unconditionally invoked!) Diffstat: twitter/tweets.dcgi | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-) --- diff -r 51892ddc6fe7 -r 1fcd81f7437f twitter/tweets.dcgi --- a/twitter/tweets.dcgi Mon Dec 17 23:55:12 2018 +0100 +++ b/twitter/tweets.dcgi Wed Dec 19 17:16:05 2018 +0100 @@ -38,20 +38,26 @@ # -# Fetch twitter URL and tscrape it. +# Add HTML header to make a response tscrape-able +# +header() +{ + echo "<div class=\"user-actions\"" + echo " data-screen-name=\"${username}\"" + echo " data-name=\"${name}\">" + echo "<li class=\"js-stream-item\">" +} + + +# +# Fetch a Twitter URL # fetch() { url=$1 + curl -Lgs -- "${url}" +} - { - echo "<div class=\"user-actions\""; - echo " data-screen-name=\"${username}\""; - echo " data-name=\"${name}\">"; - echo "<li class=\"js-stream-item\">"; - curl -Lgs -- "${url}" | jq -r '.items_html'; - } | tscrape -} # # Given a username and optional max id tscrape the next 20 tweets @@ -66,7 +72,10 @@ if [ "${maxid}" ]; then url="${url}&max_position=${maxid}" fi - fetch "${url}" + { + header; + fetch "${url}" | jq -r '.items_html'; + } | tscrape } @@ -80,7 +89,10 @@ id=$2 url="${base}/${username}/status/${id}" - fetch "${url}" + { + header; + fetch "${url}"; + } | tscrape }