Index: /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm
===================================================================
--- /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm (revision 12732)
+++ /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm (working copy)
@@ -5,8 +5,6 @@
# This is a class that allows us to query the database with "raw" results -
# don't turn them into objects for speed. For the Web UI, we can then return
# the results as XMLish data stream, to be dynamically displayed in a
-#
-# Todo - call filltemplate stuff instead? May be too slow.
use strict;
@@ -26,6 +24,7 @@
my $query = shift;
my $rsList = shift;
my $player = shift;
+ my $params = shift;
my @xml = (
'',
@@ -31,32 +30,21 @@
'',
'
',
);
+
+ $params->{'itemsPerPage'} = MAXRESULTS;
for my $rs (@$rsList) {
- my $type = lc($rs->result_source->source_name);
my $total = $rs->count;
- my $count = 0;
- my @output = ();
-
- while (my $item = $rs->next) {
-
- if ($count <= MAXRESULTS) {
-
- my $rowType = $count % 2 ? 'even' : 'odd';
+ my $type = lc($rs->result_source->source_name);
- push @output, renderItem($rowType, $type, $item, $player);
- }
+ Slim::Web::Pages::Search::fillInSearchResults($params, $rs, []);
- $count++;
- }
+ push @xml, map {
+ $params->{item} = $_;
+ ${Slim::Web::HTTP::filltemplatefile("browsedbitems_list.html", $params)};
+ } @{ $params->{browse_items} };
- push @xml, sprintf("
",
- Slim::Utils::Strings::string(uc($type . 'SMATCHING')),
- Slim::Utils::Unicode::utf8decode($query)
- );
-
- push @xml, @output if $count;
if ($total && $total > MAXRESULTS) {
push @xml,
@@ -64,6 +52,8 @@
$query, $type, $player, Slim::Utils::Strings::string('MORE_MATCHES')
);
}
+
+ $params->{browse_items} = undef;
}
push @xml, "
\n";
@@ -71,6 +61,7 @@
return \join('', @xml);
}
+
sub outputAsXML {
my $class = shift;
my $query = shift;
@@ -91,8 +82,6 @@
while (my $item = $rs->next) {
- my $rowType = $count % 2 ? 'even' : 'odd';
-
if ($count <= MAXRESULTS) {
push @output, sprintf('
%s', $item->id, $item->name);
@@ -120,98 +109,6 @@
return \join('', @xml);
}
-
-sub renderItem {
- my ($rowType, $type, $item, $player) = @_;
-
- my $id = $item->id,
- my @xml = ();
- my $name = '';
- my $showExtra = '';
-
- # Track case, followed by album & artist.
- if (blessed($item) eq 'Slim::Schema::Track') {
-
- $name = Slim::Music::Info::standardTitle(undef, $item) || '';
-
- # Starting work on the standard track list format, but its a work in progress.
- my $webFormat = $prefs->get('titleFormat')->[ $prefs->get('titleFormatWeb') ] || '';
-
- # This is rather redundant from Pages.pm
- if ($webFormat !~ /ARTIST/ && $item->can('artist') && $item->artist) {
-
- $showExtra .= sprintf(
- ' %s
%s',
- string('BY'), $item->artist->id, $player, $item->artist->name,
- );
- }
-
- if ($webFormat !~ /ALBUM/ && $item->can('album') && $item->album) {
-
- $showExtra .= sprintf(
- ' %s
%s',
- string('FROM'), $item->album->id, $player, $item->album->title,
- );
- }
-
- } elsif (blessed($item) eq 'Slim::Schema::Album') {
-
- $name = $item->name;
-
- # This is rather redundant from the Album displayAsHTML Schema
- if ($prefs->get('showYear') && $item->can('year') && $item->year) {
-
- $showExtra .= sprintf(
- ' %s
%s%s ',
- '(', $item->year, $player, $item->year, ')',
- );
- }
-
- # This is rather redundant from the Album displayAsHTML Schema
- if ($prefs->get('showArtist') && $item->can('artists') && $item->artists) {
- my @artists = $item->artists;
-
- $showExtra .= sprintf(
- ' %s
%s',
- string('BY'), $artists[0]->id, $player, $artists[0]->name,
- );
- }
-
- } else {
-
- $name = $item->name;
- }
-
- # We need to handle the different urls that are needed for different result types
- my $url;
-
- if ($type eq 'track') {
-
- $url = "songinfo.html?item=$id";
-
- } elsif ($type eq 'album') {
-
- $url = "browsedb.html?hierarchy=album,track&level=1&album.id=$id";
-
- } elsif ($type eq 'contributor') {
-
- $url = "browsedb.html?hierarchy=contributor,album,track&level=1&contributor.id=$id&contributor.role=ALL";
- }
-
- push @xml,"\n
\n
-
$name$showExtra";
-
- push @xml,"
\n
\n
\n";
-
- return join('', @xml);
-}
1;
__END__
Index: /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm
===================================================================
--- /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm (revision 12732)
+++ /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm (working copy)
@@ -94,7 +94,7 @@
# do it live - and send back the div
# this should be replaced with a call to filltemplatefile()
- return Slim::Web::Pages::LiveSearch->outputAsXHTML($query, \@rsList, $player);
+ return Slim::Web::Pages::LiveSearch->outputAsXHTML($query, \@rsList, $player, $params);
}
}
@@ -364,7 +364,7 @@
if ($type eq 'contributor') {
- $form{'attributes'} .= '&contributor.role=ALL';
+ $form{'attributes'} .= '&contributor.role=ALL';
$form{'hierarchy'} = 'contributor,album,track';
} elsif ($type eq 'album') {