Refactor the logic to use awk to format the gph - 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 c9557c76c6673dc4920e8d2b1ea438bb25a4ebfa
 (DIR) parent a3b1152cd2bfbfe6b2baf8f042253e6f0e0446cd
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Wed,  2 Jan 2019 01:39:13 
       
       Refactor the logic to use awk to format the gph
       
       Instead of directly printing via jq, produce a TSV of the several
       entries and process them via awk and par to format the description.
       
       Diffstat:
        mediasetplay/category.dcgi |  38 ++++++++++++++++++++++++++++++++++----
        1 files changed, 34 insertions(+), 4 deletions(-)
       ---
       diff -r a3b1152cd2bf -r c9557c76c667 mediasetplay/category.dcgi
       --- a/mediasetplay/category.dcgi        Wed Jan 02 01:15:50 2019 +0100
       +++ b/mediasetplay/category.dcgi        Wed Jan 02 01:39:13 2019 +0100
       @@ -20,12 +20,42 @@
        curl -Lgs "${url}" |
        jq -r '
               ( .entries[] |
       -               "[h|\(.title | gsub("\\|"; "\\|"))|URL:https:\(."mediasetprogram$videoPageUrl")|server|port]",
       -               "t\(.description)",
       -               "t" ),
       +               .title + "\t" +
       +               "https:\(."mediasetprogram$videoPageUrl")" + "\t" +
       +               .description
       +       ),
               if .entryCount == .itemsPerPage then
       -               "[1|Next|'"${CGI}?${category}/"'" + ((.startIndex + .entryCount) | tostring) + "|server|port]"
       +               "Next" + "\t" + "'"${CGI}?${category}/"'" + ((.startIndex + .entryCount) | tostring)
               else
                       empty
               end
       +' |
       +awk -F "\t" '
       +
       +function print_description(text)
       +{
       +       cmd = "par -d 0 -B=. -w 72"
       +       cmd = cmd " | sed -e \"s/^/t/\""
       +
       +       print text | cmd
       +       close(cmd)
       +}
       +
       +# entries
       +NF == 3 {
       +       title = $1
       +       url = $2
       +       description = $3
       +
       +       gsub("\\|", "\\|", title)
       +
       +       printf("[h|%s|URL:%s|server|port]\n", title, url)
       +       print_description(description)
       +       printf("t\n")
       +}
       +
       +# pagination
       +NF == 2 {
       +       printf("[1|%s|%s|server|port]\n", $1, $2)
       +}
        '