diff options
author | Yorhel <git@yorhel.nl> | 2015-09-07 13:58:01 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-09-07 13:58:01 +0200 |
commit | f51c7276fc65c2d1d46d3c8f915fb1e1412693e8 (patch) | |
tree | 6d5b2beaf8d913303f586dac28dd57d45bd41e6c /lib/VNDB/Handler | |
parent | f6dcfd8fcf094bd0872fb491135c58ce50f0674b (diff) |
Handler::Discussions: Use ts_headline() to format search results
And also fix strip_bb_tags() to be case-insensitive and fix a bug in
converting the query into a tsquery.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r-- | lib/VNDB/Handler/Discussions.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm index 27548baf..0362dce3 100644 --- a/lib/VNDB/Handler/Discussions.pm +++ b/lib/VNDB/Handler/Discussions.pm @@ -415,7 +415,7 @@ sub search { # TODO: Allow or-matching too. But what syntax? (my $ts = $frm->{bq}) =~ y{+|&:*()="';!?$%^\\[]{}<>~` }{ }s; $ts =~ s/ / & /g; - $ts =~ y/-/!/; + $ts =~ s/(^| )-([^ ]+)/ !$1 /; ($l, $np) = $self->dbPostGet( keys %boards ? ( type => [keys %boards] ) : (), search => $ts, @@ -424,6 +424,13 @@ sub search { hide => 1, what => 'thread user', sort => 'date', reverse => 1, + headline => { + # HACK: The bbcodes are stripped from the original messages when + # creating the headline, so they are guaranteed not to show up in the + # message. This means we can re-use them for highlighting without + # worrying that they conflict with the message contents. + MaxFragments => 2, MinWords => 15, MaxWords => 40, StartSel => '[raw]', StopSel => '[/raw]', FragmentDelimiter => '[code]', + }, ); } @@ -460,9 +467,12 @@ sub search { div class => 'title'; a href => $link, $l->{title}; end; - # TODO: ts_headline() or something like it. + my $h = xml_escape $l->{headline}; + $h =~ s/\[raw\]/<b class="standout">/g; + $h =~ s/\[\/raw\]/<\/b>/g; + $h =~ s/\[code\]/<b class="grayedout">...<\/b><br \/>/g; div class => 'thread'; - lit bb2html($l->{msg}, 300); + lit $h; end; end; end; |