Richard Suchenwirth 2005-02-14: After AOL told me they weren't supporting their bad NNTP news reader any more, I couldn't help but look around, read the nntp man page, and hack together this ultra-simple news reader, only for comp.lang.tcl.
In the listbox on top, you see the last 64 messages (descending, by number). Click on one to have it rendered in the text below. This is very minimal, but feel free to add your own bells and whistles :D
package require Tk package require nntp proc main argv { global n set host aioe.cjb.net pack [panedwindow .p -ori vert] -fill both -expand 1 .p add [frame .x] pack [scrollbar .x.y -command ".x.l yview"] -fill y -side right pack [listbox .x.l -yscrollc ".x.y set"] -fill both -expand 1 -side right set n [nntp::nntp $host] #$n authinfo $user $password ;#-- not needed for aioe.cjb.net foreach {num from to group} [$n group comp.lang.tcl] break for {set i $to} {$i>$to-64} {incr i -1} { set head [$n head $i] .x.l insert end [list $i [get Subject: $head] [get From: $head]] } bind .x.l <ButtonRelease-1> {fetch .f.t [selection get]} .p add [frame .f] pack [scrollbar .f.y -command ".f.t yview"] -fill y -side right pack [text .f.t -wrap word -yscrollc ".f.y set"\ -padx 5 -pady 3 -height 12 -font {Helvetica 9}] \ -fill both -expand 1 -side right foreach color {red blue} {.f.t tag configure $color -foreground $color} display .f.t [$n article $to] } proc fetch {w what} { display $w [$::n article [lindex $what 0]] } #-- Extract a field from an article proc get {what where} { foreach line $where { if [string match $what* $line] { return [string map [list $what ""] $line] } } } proc display {w article} { $w delete 1.0 end $w insert end [get Subject: $article]\n red $w insert end [get From: $article]\n blue set inbody 0 foreach line $article { if $inbody {$w insert end $line\n} if {$line eq ""} {set inbody 1} } } main $argv bind . <Escape> {exec wish $argv0 &; exit} bind . <F1> {console show}
RS 2005-04-01: updated to use a free server that provides comp.lang.tcl - thanks miguel for the hint!
rdt I like this little thing. I made a couple of minor changes in two lines (in my copy):
# in main: # foreach color {red blue} {.f.t tag configure $color -foreground $color ;# becomes: foreach color {red blue brown4} {.f.t tag configure $color -foreground $color
# in display: # if $inbody {$w insert end $line\n} ;# becomes: if $inbody {$w insert end $line\n [expr {([regexp {^>+} $line]) ? "brown4" : ""}]} }
escargo: I like this too. One of my modifications is small, but useful. I added a line to the fetch proc to mark the articles that I've read (red implies read).
proc fetch {w what} { .x.l itemconfigure [.x.l curselection] -foreground red display $w [$::n article [lindex $what 0]] }
RLH: Well why not a very simple way to post as well? : )
rdt: Well if you wish to add functionality, how about a popup listbox / entry for the "news group" ?