From 3cb7df56e0204bb8b0799a8317ef5a5f38802c7b Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 26 Nov 2021 12:10:05 +0100 Subject: import sfeed_curses Import sfeed_curses into sfeed. The files are based of the commit 8e151ce48b503ad0ff0e24cb1be3bc93d6fbd895 --- sfeed_content | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 sfeed_content (limited to 'sfeed_content') diff --git a/sfeed_content b/sfeed_content new file mode 100755 index 0000000..2d0ee23 --- /dev/null +++ b/sfeed_content @@ -0,0 +1,53 @@ +#!/bin/sh +# Content viewer for sfeed(5) lines. + +# The locale is set to "C" for performance. The input is always UTF-8. +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 = "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 = "\n"; + } + print base unescape($4) | htmlconv; + close(htmlconv); + } else { + print unescape($4); + } +}' "$@" | \ +${PAGER:-less -R} -- cgit v1.2.3