/[webpac2]/trunk/vhost/webpac2.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/vhost/webpac2.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1133 by dpavlin, Tue Apr 21 23:17:19 2009 UTC revision 1137 by dpavlin, Tue Apr 21 23:17:23 2009 UTC
# Line 12  use Search::Estraier; Line 12  use Search::Estraier;
12  print header;  print header;
13    
14  sub dump_yaml {  sub dump_yaml {
15          print qq|<pre>|, YAML::Dump( @_ ), qq|</pre>|;          my $name = shift;
16            print qq|<pre># $name\n|, YAML::Dump( @_ ), qq|</pre>|;
17  }  }
18    
19  my $path = $ENV{PATH_INFO};  my $path = $ENV{PATH_INFO} || 'ecas';
20  my $dir = $0;  my $dir = $0;
21  $dir =~ s{/[^/]+.cgi}{};  $dir =~ s{/[^/]+.cgi}{};
22    
# Line 24  my $config = YAML::LoadFile( "$dir/$path Line 25  my $config = YAML::LoadFile( "$dir/$path
25  my $database = (keys %{ $config->{databases} })[0];  my $database = (keys %{ $config->{databases} })[0];
26  die "$database not in $path" unless $path =~ m{\Q$database\E};  die "$database not in $path" unless $path =~ m{\Q$database\E};
27    
28    my $html_markup = "$dir/$path/html.pm";
29    my $html_markup_skip;
30    if ( -e $html_markup ) {
31            require $html_markup;
32            $html_markup = $database . '::html';
33    } else {
34            undef $html_markup;
35    }
36    
37  my $estraier = YAML::LoadFile( "$dir/../var/estraier/$database.yaml" );  my $estraier = YAML::LoadFile( "$dir/../var/estraier/$database.yaml" );
38    
39  my $db = $config->{databases}->{$database};  my $db = $config->{databases}->{$database};
# Line 51  print  end_form; Line 61  print  end_form;
61    
62  if ( my $search = param('search') ) {  if ( my $search = param('search') ) {
63    
64          print qq|<div id="results">search: $search|;          print qq|<div id="results">|;
65    
66          my $node = Search::Estraier::Node->new(          my $node = Search::Estraier::Node->new(
67                  url => $config->{hyperestraier}->{masterurl} . '/node/' . $database,                  url => $config->{hyperestraier}->{masterurl} . '/node/' . $database,
# Line 64  if ( my $search = param('search') ) { Line 74  if ( my $search = param('search') ) {
74    
75          if ( ! $nres ) {          if ( ! $nres ) {
76                  my $no_results = "No results for search '%s'";                  my $no_results = "No results for search '%s'";
77                  printf qq|<div class="error">$no_results</a>|, $search;                  printf qq|<div class="error">$no_results</div>|, $search;
78          } else {          } else {
79                  print qq|<ul>|;                  my $results = "Got %d results for search '%s'";
80                    printf qq|<div class="message">$results</div>|, $nres->hits, $search;
81    
82                    print qq|<ol>|;
83    
84                  foreach my $i ( 1 .. $nres->doc_num ) {                  foreach my $i ( 1 .. $nres->doc_num ) {
85                          my $rdoc = $nres->get_doc( $i - 1 );                          my $rdoc = $nres->get_doc( $i - 1 );
86                          print qq|<li>|;                          print qq|<li>|;
87                          print qq|<div><label>$_</label><span class=$_>|, $rdoc->attr( $_ ), qq|</span></div>|                          foreach my $attr ( @attr ) {
88                                  foreach @attr;                                  my $v = $rdoc->attr( $attr );
89                                    if ( defined $v && $html_markup && ! $html_markup_skip->{$attr} ) {
90                                            eval "\$v = $html_markup->$attr( \$v );";
91                                            if ( $@ ) {
92                                                    warn "disable html markup for $attr: $@";
93                                                    $html_markup_skip->{$attr} = $@;
94                                            }
95                                    }
96                                    next unless defined $v;
97                                    print qq|<div><label>$attr</label><span class=$attr>$v</span></div>\n|;
98                            }
99                          print qq|</li>\n|;                          print qq|</li>\n|;
100                  }                  }
101                  print qq|</ul>|;                  print qq|</ol>|;
102          }          }
103          print qq|</div>|;          print qq|</div>|;
104  }  }
105    
106  dump_yaml( $estraier );  dump_yaml( 'estraier', $estraier );
107  dump_yaml( $db );  dump_yaml( 'db', $db );
108    dump_yaml( 'html_markup_skip', $html_markup_skip );
109    
110  print   end_html;  print   end_html;

Legend:
Removed from v.1133  
changed lines
  Added in v.1137

  ViewVC Help
Powered by ViewVC 1.1.26