Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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; }

In reply to Re: newsreader threading (boo) by boo_radley
in thread newsreader threading by ask

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-18 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found