78 |
filters => { foo => sub { shift } }, |
filters => { foo => sub { shift } }, |
79 |
); |
); |
80 |
|
|
81 |
|
# default template from config.yaml |
82 |
$self->{template} ||= $c->config->{webpac}->{template}; |
$self->{template} ||= $c->config->{webpac}->{template}; |
83 |
|
|
84 |
$self->{iconv} = new Text::Iconv( |
$self->{iconv} = new Text::Iconv( |
98 |
} |
} |
99 |
|
|
100 |
sub search { |
sub search { |
101 |
my ( $self, $query ) = @_; |
my ( $self, $query, $template ) = @_; |
102 |
|
|
103 |
my $log = $self->{log}; |
my $log = $self->{log}; |
104 |
|
|
105 |
$log->debug("search model query: -->$query<--"); |
$log->debug("search model query: -->$query<--"); |
106 |
|
|
107 |
my $template_filename = $self->{template}; |
my $template_filename = $template || $self->{template}; |
108 |
|
|
109 |
my @results = $self->{est}->search( |
my @results = $self->{est}->search( |
110 |
query => $query, |
query => $query, |
120 |
|
|
121 |
my $mfn = $1 if ( $results[$i]->{'@uri'} =~ m#/(\d+)$#); |
my $mfn = $1 if ( $results[$i]->{'@uri'} =~ m#/(\d+)$#); |
122 |
|
|
123 |
# $log->debug("load_ds( $mfn )"); |
#$log->debug("load_ds( $mfn )"); |
124 |
|
|
125 |
my $ds = $self->{db}->load_ds( $mfn ) || next; |
my $ds = $self->{db}->load_ds( $mfn ) || $log->error("can't load_ds( $mfn )") && next; |
126 |
|
|
127 |
|
#$log->debug( "ds = " . Dumper( \@html_results ) ); |
128 |
|
|
129 |
my $html = $self->{out}->apply( |
my $html = $self->{out}->apply( |
130 |
template => $template_filename, |
template => $template_filename, |
131 |
data => $ds, |
data => $ds, |
137 |
|
|
138 |
} |
} |
139 |
|
|
140 |
|
#$log->debug( '@html_results = ' . Dumper( \@html_results ) ); |
141 |
|
|
142 |
return \@html_results; |
return \@html_results; |
143 |
} |
} |
144 |
|
|