c.cgi - 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
       ---
       c.cgi
       ---
            1 #!/bin/sh
            2 
            3 . ../common/config.sh
            4 
            5 case "$2" in
            6 */*)
            7         subreddit="${2%%/*}"
            8         id="${2##*/}"
            9         ;;
           10 esac
           11 
           12 ua=""
           13 url="https://www.reddit.com/r/${subreddit}/comments/${id}/.json"
           14 
           15 curl -A "${ua}" -Lgs -- "${url}" |
           16 jq -r '
           17 ( .[0] | .data.children[] | .data |
           18         "",
           19         "\(.subreddit_name_prefixed) - \(.title)",
           20         "\(.author)   \(.created_utc | strftime("%F %H:%M"))",
           21         "Score:    \(.score)",
           22         "Comments: \(.num_comments)",
           23         "",
           24         if .selftext != "" then
           25                 .selftext,
           26                 ""
           27         else
           28                 empty
           29         end ),
           30 ( .[1] | .. | select(.kind? == "t1") | .data |
           31         "\(.author)   \(.score)   \(.created_utc | strftime("%F %H:%M"))",
           32         .body,
           33         "",
           34         "" )
           35 ' | sed \
           36     -e 's/\>/>/g' \
           37     -e 's/\&lt;/</g' \
           38     -e 's/\&amp;/\&/g'