Reddit dans le terminal - retour accueil
git clone git://bebou.netlib.re/reddit-curses
Log | Files | Refs | README |
commit 97cddc7589ad42f403eb9737bc1e1e8a8419d32b parent eefb37187fbef123760ef01f3957a81abd2a47e3 Auterice: Arthur Pons <arthur.pons@unistra.fr> Date: Sat, 9 Mar 2024 15:49:53 +0100 On ajoute un sfeed_content modifié Pour afficher les commentaires reddit Diffstat:
A | sfeed_content | | | 69 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 69 insertions(+), 0 deletions(-)
diff --git a/sfeed_content b/sfeed_content @@ -0,0 +1,69 @@ +#!/bin/sh +# Content viewer for sfeed(5) lines. + +# The locale is set to "C" for performance. The input is always UTF-8. + +temp=$(mktemp); trap "rm -rf $temp" EXIT +cat > $temp + +cat $temp | +if $(grep -q "id : t3_" $temp) +then + comlink=$(grep -Eo 't3_.{7}' $temp) + reddio print -i 4 -c always -l 50 -s top comments/$comlink | + sed -E 's,^\[,\x1b[92m[,' | + fmt -s | + less -R +else + LC_ALL=C awk -F '\t' ' + function unescape(s) { + # use the character "\x01" as a temporary replacement for "\". + gsub("\\\\\\\\", "\x01", s); + gsub("\\\\n", "\n", s); + gsub("\\\\t", "\t", s); + gsub("\x01", "\\", s); # restore "\x01" to "\". + return s; + } + BEGIN { + htmlconv = ENVIRON["SFEED_HTMLCONV"]; + if (!length(htmlconv)) + htmlconv = "lynx -stdin -dump " \ + "-underline_links -image_links " \ + "-display_charset=\"utf-8\" -assume_charset=\"utf-8\" "; + } + { + if (previtem) + print "\f"; + previtem = 1; + + print "Title: " $2; + if (length($7)) + print "Author: " $7; + if (length($9)) { + categories = $9; + gsub("\\|", ", ", categories); + print "Category: " categories; + } + if (length($3)) + print "Link: " $3; + if (length($8)) + print "Enclosure: " $8; + if (!length($4)) + next; + print ""; + if ($5 == "html") { + # use the link of the item as the base URL for relative URLs in + # HTML content. + base = $3; + if (length(base)) { + gsub("\"", "%22", base); # encode quotes. + base = "<base href=\"" base "\"/>\n"; + } + print base unescape($4) | htmlconv; + close(htmlconv); + } else { + print unescape($4); + } + }' "$@" | \ + ${PAGER:-less -R} +fi