content-view 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. # RSS/Atom content viewer.
  3. #
  4. # Dependencies:
  5. # - awk, sh, etc.
  6. # - lynx or webdump or HTML converting to plain-text.
  7. export LESSCHARSET=utf-8
  8. # content()
  9. content() {
  10. awk -F '\t' '
  11. function unescape(s) {
  12. gsub("\\\\t", "\t", s);
  13. gsub("\\\\n", "\n", s);
  14. gsub("\\\\\\\\", "\\", s);
  15. return s;
  16. }
  17. {
  18. print unescape($4);
  19. exit;
  20. }'
  21. }
  22. tmp=$(mktemp 'sfeed_curses_XXXXXXXXXX')
  23. trap "rm $tmp" EXIT
  24. cat > "$tmp"
  25. #baseurl={ awk -F '\t' '{print $3}'
  26. (awk -F '\t' '
  27. {
  28. print "Title: " $2;
  29. if (length($7))
  30. print "Author: " $7;
  31. if (length($3))
  32. print "Link: " $3;
  33. if (length($8))
  34. print "Enclosure: " $8;
  35. print "";
  36. exit;
  37. }' < "$tmp"
  38. contenttype=$(awk -F '\t' '{ print $5; exit }' < "$tmp")
  39. if test x"$contenttype" = x"plain"; then
  40. content < "$tmp"
  41. else
  42. (echo "<span>"; content < "$tmp";echo "</span>") | \
  43. lynx -stdin -dump -underline_links -image_links -assume_charset=utf-8 -assume_local_charset=utf-8 -display_charset=utf-8 -assume_unrec_charset=utf-8
  44. fi
  45. ) | \
  46. less -R