[Slim-Checkins] r12820 - in /trunk/server: HTML/EN/xmlbrowser.html Slim/Buttons/XMLBrowser.pm Slim/Web/XMLBrowser.pm
andy at svn.slimdevices.com
andy at svn.slimdevices.com
Fri Aug 31 11:53:48 PDT 2007
Author: andy
Date: Fri Aug 31 11:53:47 2007
New Revision: 12820
URL: http://svn.slimdevices.com?rev=12820&view=rev
Log:
Updates to CLI and web XMLBrowser code to fix handling for some new attributes such as play, playlist, image, type=text
Modified:
trunk/server/HTML/EN/xmlbrowser.html
trunk/server/Slim/Buttons/XMLBrowser.pm
trunk/server/Slim/Web/XMLBrowser.pm
Modified: trunk/server/HTML/EN/xmlbrowser.html
URL: http://svn.slimdevices.com/trunk/server/HTML/EN/xmlbrowser.html?rev=12820&r1=12819&r2=12820&view=diff
==============================================================================
--- trunk/server/HTML/EN/xmlbrowser.html (original)
+++ trunk/server/HTML/EN/xmlbrowser.html Fri Aug 31 11:53:47 2007
@@ -170,6 +170,12 @@
[% END %]
[%- WRAPPER contentcontainer %]
+ [% IF image %]
+ <ul>
+ <img src="[% image %]" />
+ </ul>
+ [% END %]
+
[% IF itemsHaveAudio %]
[%- BLOCK allcontrol -%]
[% WRAPPER playlink %]href="index.html?[% searchquery %]action=playall&index=[% currentIndex %]&player=[% player | uri %]"[% END %]
@@ -183,7 +189,7 @@
[%- FOREACH item = items %]
[%- BLOCK gencontrol -%]
- [% IF item.type == 'audio' || item.type == 'playlist' || item.enclosure %]
+ [% IF item.type == 'audio' || item.type == 'playlist' || item.enclosure || item.play %]
[% WRAPPER playlink %]href="index.html?[% searchquery %]action=play[% IF item.type == 'playlist' %]all[% END %]&index=[% index _ (start + loop.index) %]&player=[% player | uri %]"[% END %]
[% WRAPPER addlink %]href="index.html?[% searchquery %]action=add[% IF item.type == 'playlist' %]all[% END %]&index=[% index _ (start + loop.index) %]&player=[% player | uri %]"[% END %]
[% ELSE %]
@@ -196,7 +202,13 @@
onMouseOut="hideElements(['controls[% index _ (start + loop.index) %]'])">
[% END %]
[%- WRAPPER contentitem leftcontrols = 'gencontrol' rightcontrols = 'favoritescontrol' %]
- <a href="index.html?[% searchquery %]index=[% index _ (start + loop.index) %]&player=[% player | uri %]">[% item.name || item.title %]</a>
+ [% IF item.type != 'text' %]
+ <a href="index.html?[% searchquery %]index=[% index _ (start + loop.index) %]&player=[% player | uri %]">
+ [% END %]
+ [% item.name || item.title %]
+ [% IF item.type != 'text' %]
+ </a>
+ [% END %]
[%- END %]
[% IF useAJAX %]</span>[% END %]
[%- odd = (not odd) %]
Modified: trunk/server/Slim/Buttons/XMLBrowser.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/XMLBrowser.pm?rev=12820&r1=12819&r2=12820&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/XMLBrowser.pm (original)
+++ trunk/server/Slim/Buttons/XMLBrowser.pm Fri Aug 31 11:53:47 2007
@@ -769,7 +769,7 @@
return $item->{'play'};
}
elsif ( $item->{'type'} && $item->{'type'} =~ /^(?:audio|playlist)$/ ) {
- return $item->{'url'};
+ return $item->{'playlist'} || $item->{'url'};
}
elsif ( $item->{'enclosure'} && ( $item->{'enclosure'}->{'type'} =~ /audio/ ) ) {
return $item->{'enclosure'}->{'url'};
@@ -1256,20 +1256,33 @@
# print Data::Dumper::Dumper($subFeed);
my @crumbIndex = ();
- if ( scalar @index > 0 ) {
+ if ( my $levels = scalar @index ) {
# descend to the selected item
+ my $depth = 0;
for my $i ( @index ) {
-
$log->debug("Considering item $i");
+ $depth++;
+
$subFeed = $subFeed->{'items'}->[$i];
push @crumbIndex, $i;
+ # Change URL if there is a play attribute
if ( $isPlaylistCmd && $subFeed->{play} ) {
$subFeed->{url} = $subFeed->{play};
$subFeed->{type} = 'audio';
+ }
+
+ # Change URL if there is a playlist attribute and it's the last item
+ if (
+ $subFeed->{playlist}
+ && $depth == $levels
+ && $isPlaylistCmd
+ ) {
+ $subFeed->{type} = 'playlist';
+ $subFeed->{url} = $subFeed->{playlist};
}
# If the feed is another URL, fetch it and insert it into the
@@ -1423,6 +1436,11 @@
if ( my $enc = $subFeed->{'enclosure'} ) {
$url = $enc->{'url'};
}
+
+ # Items with a 'play' attribute will use this for playback
+ if ( my $play = $subFeed->{'play'} ) {
+ $url = $play;
+ }
if ( $url ) {
@@ -1446,6 +1464,10 @@
elsif ( $item->{'enclosure'} && $item->{'enclosure'}->{'url'} ) {
push @urls, $item->{'enclosure'}->{'url'};
Slim::Music::Info::setTitle( $item->{'url'}, $item->{'name'} || $item->{'title'} );
+ }
+ elsif ( $item->{'play'} ) {
+ push @urls, $item->{'play'};
+ Slim::Music::Info::setTitle( $item->{'play'}, $item->{'name'} || $item->{'title'} );
}
}
@@ -1662,12 +1684,17 @@
if ($params->{'parentURL'} ne 'NONE') {
# parent url of 'NONE' should not be recached as we are being passed a preparsed hash
# re-cache the parsed XML to include the sub-feed
- my $cache = Slim::Utils::Cache->new();
- my $expires = $feed->{'cachetime'} || $Slim::Formats::XML::XML_CACHE_TIME;
-
- $log->info("Re-caching parsed XML for $expires seconds.");
-
- $cache->set( $params->{'parentURL'} . '_parsedXML', $parent, $expires );
+ if ( Slim::Utils::Misc::shouldCacheURL( $params->{'parentURL'} ) ) {
+ my $cache = Slim::Utils::Cache->new();
+ my $expires = $feed->{'cachetime'} || $Slim::Formats::XML::XML_CACHE_TIME;
+
+ $log->info("Re-caching parsed XML for $expires seconds.");
+
+ $cache->set( $params->{'parentURL'} . '_parsedXML', $parent, $expires );
+ }
+ else {
+ $log->info( 'Not caching parsed XML for ' . $params->{'parentURL'} );
+ }
}
_cliQuery_done( $parent, $params );
Modified: trunk/server/Slim/Web/XMLBrowser.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Web/XMLBrowser.pm?rev=12820&r1=12819&r2=12820&view=diff
==============================================================================
--- trunk/server/Slim/Web/XMLBrowser.pm (original)
+++ trunk/server/Slim/Web/XMLBrowser.pm Fri Aug 31 11:53:47 2007
@@ -99,7 +99,7 @@
sub handleFeed {
my ( $feed, $params ) = @_;
my ( $client, $stash, $callback, $httpClient, $response ) = @{ $params->{'args'} };
-
+
$stash->{'pagetitle'} = $feed->{'title'} || string($params->{'title'});
my $template = 'xmlbrowser.html';
@@ -128,14 +128,17 @@
$favsItem = pop @index;
}
- if ( scalar @index ) {
+ if ( my $levels = scalar @index ) {
# index links for each crumb item
my @crumbIndex = ();
# descend to the selected item
+ my $depth = 0;
my $subFeed = $feed;
for my $i ( @index ) {
+ $depth++;
+
$subFeed = $subFeed->{'items'}->[$i];
push @crumbIndex, $i;
@@ -143,6 +146,21 @@
'name' => $subFeed->{'name'} || $subFeed->{'title'},
'index' => join '.', @crumbIndex,
};
+
+ # Change type to audio if it's an action request and we have a play attribute
+ if ( $subFeed->{'play'} && $stash->{'action'} =~ /^(?:play|add)$/ ) {
+ $subFeed->{'type'} = 'audio';
+ }
+
+ # Change URL if there is a playlist attribute and it's the last item
+ if (
+ $subFeed->{'playlist'}
+ && $depth == $levels
+ && $stash->{'action'} =~ /^(?:playall|addall)$/
+ ) {
+ $subFeed->{'type'} = 'playlist';
+ $subFeed->{'url'} = $subFeed->{'playlist'};
+ }
# If the feed is another URL, fetch it and insert it into the
# current cached feed
@@ -188,11 +206,12 @@
'index' => join '.', @index,
};
}
-
+
$stash->{'pagetitle'} = $subFeed->{'name'};
$stash->{'crumb'} = \@crumb;
$stash->{'items'} = $subFeed->{'items'};
$stash->{'index'} = join( '.', @index ) . '.';
+ $stash->{'image'} = $subFeed->{'image'};
}
else {
$stash->{'pagetitle'} = $feed->{'title'} || string($params->{'title'});
@@ -222,6 +241,11 @@
$url = $enc->{'url'};
}
+ # Items with a 'play' attribute will use this for playback
+ if ( my $play = $stash->{'streaminfo'}->{'item'}->{'play'} ) {
+ $url = $play;
+ }
+
if ( $url ) {
$log->info("Playing/adding $url");
@@ -255,6 +279,10 @@
push @urls, $item->{'enclosure'}->{'url'};
Slim::Music::Info::setTitle( $item->{'url'}, $item->{'name'} || $item->{'title'} );
}
+ elsif ( $item->{'play'} ) {
+ push @urls, $item->{'play'};
+ Slim::Music::Info::setTitle( $item->{'play'}, $item->{'name'} || $item->{'title'} );
+ }
}
if ( @urls ) {
@@ -278,7 +306,7 @@
# Check if any of our items contain audio, so we can display an
# 'All Songs' link
for my $item ( @{ $stash->{'items'} } ) {
- if ( ( $item->{'type'} && $item->{'type'} eq 'audio' ) || $item->{'enclosure'} ) {
+ if ( ( $item->{'type'} && $item->{'type'} eq 'audio' ) || $item->{'enclosure'} || $item->{'play'} ) {
$stash->{'itemsHaveAudio'} = 1;
$stash->{'currentIndex'} = join '.', @index;
last;
@@ -323,15 +351,15 @@
if (defined $favsItem && $items[$favsItem - $start]) {
my $item = $items[$favsItem - $start];
if ($stash->{'action'} eq 'favadd') {
- $favs->add($item->{'url'}, $item->{'name'}, $item->{'type'}, $item->{'parser'});
+ $favs->add( $item->{'play'} || $item->{'url'}, $item->{'name'}, $item->{'type'}, $item->{'parser'} );
} elsif ($stash->{'action'} eq 'favdel') {
- $favs->deleteUrl($item->{'url'});
+ $favs->deleteUrl( $item->{'play'} || $item->{'url'} );
}
}
for my $item (@items) {
if ($item->{'url'}) {
- $item->{'favorites'} = $favs->hasUrl($item->{'url'}) ? 2 : 1;
+ $item->{'favorites'} = $favs->hasUrl( $item->{'play'} || $item->{'url'} ) ? 2 : 1;
}
}
}
@@ -383,6 +411,11 @@
} else {
# otherwise insert items as subfeed
$subFeed->{'items'} = $feed->{'items'};
+
+ # Update the title value in case it's different from the previous menu
+ if ( $feed->{'title'} ) {
+ $subFeed->{'name'} = $feed->{'title'};
+ }
}
# set flag to avoid fetching this url again
@@ -398,12 +431,17 @@
elsif ($params->{'parentURL'} ne 'NONE') {
# parentURL of 'NONE' indicates we were called with preparsed hash which should not be cached
# re-cache the parsed XML to include the sub-feed
- my $cache = Slim::Utils::Cache->new();
- my $expires = $feed->{'cachetime'} || $Slim::Formats::XML::XML_CACHE_TIME;
-
- $log->info("Re-caching parsed XML for $expires seconds.");
-
- $cache->set( $params->{'parentURL'} . '_parsedXML', $parent, $expires );
+ if ( Slim::Utils::Misc::shouldCacheURL( $params->{'parentURL'} ) ) {
+ my $cache = Slim::Utils::Cache->new();
+ my $expires = $feed->{'cachetime'} || $Slim::Formats::XML::XML_CACHE_TIME;
+
+ $log->info("Re-caching parsed XML for $expires seconds.");
+
+ $cache->set( $params->{'parentURL'} . '_parsedXML', $parent, $expires );
+ }
+ else {
+ $log->info( 'Not caching parsed XML for ' . $params->{'parentURL'} );
+ }
}
handleFeed( $parent, $params );
More information about the checkins
mailing list