From e76b691e78e273226cba9284cb8cd22a423319ed Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:23:25 -0500 Subject: bucky2 --- bucky2/cgi-bin/search | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100755 bucky2/cgi-bin/search (limited to 'bucky2/cgi-bin/search') diff --git a/bucky2/cgi-bin/search b/bucky2/cgi-bin/search new file mode 100755 index 0000000..15a89a6 --- /dev/null +++ b/bucky2/cgi-bin/search @@ -0,0 +1,184 @@ +#!/usr/bin/perl +use lib "../lib"; +use Bucky; +use Data::Dumper; + +my $session = new Bucky::Session; + +my $query = $session->param("q"); + +print <<__BODY__; +Content-type: text/html +Pragma: no-cache + + + + bucky [SEARCH: $query] + + + + + + + +
+ + +
+ +
+ + +
bucky's backwards binoculars
+ + + + + +
+
+
+ +home | post | +ftp | +inbox | +message | +profile | + +logout + + +
+
+
+__BODY__ + +print <<__SEARCH_FORM__; +
+ + + + + + + +__SEARCH_FORM__ + +if ($query) +{ +my $start = $session->param("start"); +my $limit = $session->param("limit"); + +my $search = new Bucky::Search; +my $results = $search->search($query, $start, $limit); + +my $terms = $results->{'terms'}; +my $r = 0; + +my $z_last_start = $results->{'start'} - $results->{'limit'} + 1; +my $z_start = $results->{'start'}; +my $z_limit = $results->{'limit'}; +my $z_upto = $z_last_start + $z_limit - 1; +my $z_total = $results->{'total'}; +my $z_next; + +if ($results->{'total'} == 0) + { + my $z_next = "
No Results!
"; + print ""; + } +else + { + $z_next = "displaying $z_last_start-$z_upto of $z_total results ..."; + if ($z_start < $z_total) + { + $z_next .= " next page >>"; + } + } +print "" if $z_next; +foreach my $result (@{$results->{'results'}}) + { + $r = $r ? 0 : 1; + my $thread = $results->{'threads'}->{ $result->{'thread'} }; + my $comment = $results->{'comments'}->{ $result->{'comment'} }; + my $file = $results->{'files'}->{ $result->{'file'} }; + + my $z_thread = $thread->{'id'}; + my $z_username = $thread->{'username'}; + my $z_title = $search->bold_terms( $thread->{'title'}, $terms); + my $z_comment = $search->bold_snippet( $comment->{'comment'}, $terms); + my $z_filename = $file->{'filename'}; + my $z_file = $search->bold_terms( $z_filename, $terms); + my $z_date = scalar localtime $thread->{'createdate'}; + my $z_strength = $result->{'strength'} . "x" . $result->{'count'}; + my $z_bigs = $result->{'count'} > ( scalar(@$terms) - 3 ) + ? "" : ""; + my $z_unbigs = $result->{'count'} > ( scalar(@$terms) - 3 ) + ? "" : ""; + my $z_img; + if ($file && $file->{'filename'} =~ /jpg/i) + { + my $filename = lc($file->{'filename'}); + $z_img = "" if $filename; + } + elsif ($thread->{'flagged'}) + { + my $file = $results->{'files'}->{ $thread->{'flagged'} }; + my $filename = lc($file->{'filename'}); + $z_img = "" if $filename; + } + my $z_color = "c"; + $z_color .= $r; + my $z_filelink = "$z_file" if $z_file; + + print <<__RESULT__; + + + + + +__RESULT__ +# print Dumper($result); + } +print "" if $z_next; +} + +print <<__FOOTER__; +
  +
+ + +
+ + + +
+
+
 
 $z_next 
 $z_next 
+$z_img + +$z_bigs$z_title$z_unbigs
+$z_strength   posted by $z_username | $z_date
+
$z_filelink $z_comment
+
 $z_next 
+
+ + + + + + + +
+ + + + + +__FOOTER__ +1; -- cgit v1.2.3-70-g09d2