sfeed_content - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
(HTM) git clone git://git.codemadness.org/sfeed_curses
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
sfeed_content (1210B)
---
1 #!/bin/sh
2 # Content viewer for sfeed(5) lines.
3
4 # The locale is set to "C" for performance. The input is always UTF-8.
5 LC_ALL=C awk -F '\t' '
6 function unescape(s) {
7 # use the character "\x01" as a temporary replacement for "\".
8 gsub("\\\\\\\\", "\x01", s);
9 gsub("\\\\n", "\n", s);
10 gsub("\\\\t", "\t", s);
11 gsub("\x01", "\\", s); # restore "\x01" to "\".
12 return s;
13 }
14 BEGIN {
15 htmlconv = "lynx -stdin -dump " \
16 "-underline_links -image_links " \
17 "-display_charset=\"utf-8\" -assume_charset=\"utf-8\" ";
18 }
19 {
20 if (previtem)
21 print "\f";
22 previtem = 1;
23
24 print "Title: " $2;
25 if (length($7))
26 print "Author: " $7;
27 if (length($9)) {
28 categories = $9;
29 gsub("\\|", ", ", categories);
30 print "Category: " categories;
31 }
32 if (length($3))
33 print "Link: " $3;
34 if (length($8))
35 print "Enclosure: " $8;
36 if (!length($4))
37 next;
38 print "";
39 if ($5 == "html") {
40 # use the link of the item as the base URL for relative URLs in
41 # HTML content.
42 base = $3;
43 if (length(base)) {
44 gsub("\"", "%22", base); # encode quotes.
45 base = "<base href=\"" base "\"/>\n";
46 }
47 print base unescape($4) | htmlconv;
48 close(htmlconv);
49 } else {
50 print unescape($4);
51 }
52 }' "$@" | \
53 ${PAGER:-less -R}