Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: newsreader threading (boo)

by boo_radley (Parson)
on Nov 26, 2001 at 19:28 UTC ( #127552=note: print w/replies, xml ) Need Help??


in reply to newsreader threading

Here's an out of context snippet from a newsreader I wrote in wx (it's still not finished... ) that seems to thread as well as my regular newsreader. You can also see what my commenting looks like in the real world.

Skimming over JWZ's document, I have latched onto the "references" bit, ignoring the In-Reply-To altogether. If you're interested in the full source, please /msg me -- the caveat (and reason why it hasn't been posted before) is that the reader itself is rather incomplete -- it retrieves, sorts & displays them, but doesn't store messages or message pointers.

# sorting by oldest first seems to give the best chance for accurate m +essage threading. # I apologize for the nasty parens nesting scheme as well. foreach (sort { Date_Cmp ( $messages{$a}{"date"}, $messages{$b +}{"date"}) } keys %messages ) { my $ref = $messages{$_}{"references"}; print STDERR "Checking $_ for references -- $ref --\n"; # getrefs runs through all the messages in placed, # looking for references within the current message my $childof=get_refs($ref, \%placed); # # if the current message is a child of another, # nest it to that messages' node, otherwise place as a c +hild of # the newsgroup node. # # In either case, we add it to the list of messages we'v +e 'placed'. # 'placed' is a bad analogy, and should be replaced. if ($childof){ $placed{$_}=$this->AppendItem ($placed{$childof}, $_." + ".$messages{$_}{"subject"}); } else { $placed {$_}=$this->AppendItem ($item,$_." ".$messages +{$_}{"subject"}); } print STDERR "I have ". keys (%placed) . " items\n"; }

and the sub get_refs,

sub get_refs { my $msg_refs = shift; my $msg_list = shift; my @parent_refs =reverse split /\s+/, $msg_refs; foreach my $aref(@parent_refs) { print STDERR "\tChecking $msg_refs\n"; if (exists $$msg_list{$aref}){ print STDERR "$_ is child of $aref\n"; return $aref; } } return undef; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://127552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2022-05-23 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?