Following Links in News Postings

It's easy really. First this assumes you are using rn, or one of it's derivatives like trn or whatever. Add the following line to your .rnmac file:
W	|readwebpost %C Mosaic\n
This will mean if you see a news article with a URL or HTML tags in it, you can just type W and it will automatically tell your (already running) Mosaic to jump to a htmlified version of the article you are reading. If you prefer to use lynx over Mosaic, change the above line to:
W	|readwebpost %C lynx\n
Then, all you need to do is include the program readwebpost in your path somewhere. (On Athena, this means in the directory ~/$bindir for each platform, or add mkgray). The program follows at the bottom of this page. Note, if you are not at MIT, you need to change the first line to the path for perl on your system.

What this program does is add html tags to the news article. It tries to do smart things, and usually it formats the article nicely, but every now and then it gets confused. Most important though, it renders any html in the article and makes links from all URLs. If you don't want it to try to do any fancy formatting, change the line in .rnmac to something like:

W	|readwebpost %C Mosaic plain\n
And it will only render any html tags included in the article already.

Matthew Gray <>

#!/afs/athena/contrib/perl/perl # Copyright 1994 by Matthew Gray <> # Feel free to use and redistribute this program, but do not sell it $mode = $ARGV[1]; $style = $ARGV[2]; @post = (<STDIN>); $post = join("\n", @post); if($style ne "plain"){ $post = ''; $inheader = 1; for (@post){ $line = ''; if($insig){ $post .= $_; next; } if(/Subject: (.+)/ && $inheader){ $title = $1; $post = "<title>$title</title>\n".$post; } if(/Path:/ && $inheader){ $_ = ''; } if(/.+ wr[io]te..?.?$/){ $line = "<dl>\n<dt>".$_."\n"; } if(substr($_,0,1) eq ">"){ $line = "<dl>\n" unless $inquote; $line .= "<dd>".$_."\n"; $inquote = 1; } elsif((substr($_,0,3) =~ ">") && (substr($_,0,2) !~ /[a-zA-Z]/)){ $line = "<dl>\n" unless $inquote; $line .= "<dd>".$_."\n"; $inquote = 1; } else{ $post.="</dl>" if $inquote; $inquote = 0; } if(/^\n$/){ $line = "<p>\n"; $inheader = 0; } if($inheader){ /([^:]+): (.+)/; if($1 eq "From" || $1 eq "Subject"){ s/([^:]+): (.+)/<strong>\1<\/strong>: <em>\2<\/em><br>/; } else{ $_.="<br>" if $_; } } if(substr($_,0,2) eq "--"){ $line = "<hr>\n"; $line .= substr($_,2) if (substr($_,2) =~ /[a-zA-Z]/); $line .= "<pre>"; $insig = 1; } $line = $_ unless $line; $post .= $line; } if($insig){ $post .= "</pre>"; } } else{ $post = "<title>NetNews post from $ARGV[0]</title><pre>$post</pre>"; } $post=~s,([^="])(http://(\S+)),\1<a href="\2">\2</a>,g; $post=~s,([^="])(ftp://(\S+)),\1<a href="\2">\2</a>,g; $post=~s,([^="])(file://(\S+)),\1<a href="\2">\2</a>,g; $post=~s,([^="])(gopher://(\S+)),\1<a href="\2">\2</a>,g; open(ART, ">/tmp/article.html"); print(ART $post); close(ART); if($mode eq "lynx"){ if($pid = fork()){ wait; # unlink("/tmp/article.html"); } else{ system("lynx /tmp/article.html < /dev/tty"); } } else{ $ps = (-e '/usr/ucb/ps') ? '/usr/ucb/ps ax':'ps ax'; $out = `$ps`; $out =~ /[ \t]*(\d+).+Mosaic.*/; $mospid = $1; open(TMP, ">/tmp/Mosaic.$mospid"); print(TMP "goto\n"); print(TMP "file://localhost/tmp/article.html\n"); close(TMP); kill 'USR1', $mospid; exit; }