PDA

View Full Version : allowing plugins to be linked from browsedb



Triode
2008-12-22, 10:41
Does anyone have a problem with the following simple patch going into
7.3.2 - the idea is to allow plugins to register a handler such as:

Slim::Web::Pages->addPageLinks("songinfo", { 'PLUGIN_FINDART_EDIT' =>
"plugins/FindArt/index.html" });

This allows a plugin to put a link to it on the songinfo browse page so it
can be called with the album or track id being browsed.


Index: Slim/Web/Pages/BrowseDB.pm
================================================== =================
--- Slim/Web/Pages/BrowseDB.pm (revision 24389)
+++ Slim/Web/Pages/BrowseDB.pm (working copy)
@@ -507,6 +507,7 @@
$params->{'levelName'} = lc($levelName);
$params->{'attributes'} = _attributesToKeyValuePair(\%attrs);
$params->{'icons'} = $Slim::Web::Pages::additionalLinks{icons};
+ $params->{'albumlinks'} =
$Slim::Web::Pages::additionalLinks{songinfo};


# Don't show stats when only showing playlists - extra queries that
aren't needed.
@@ -600,6 +601,9 @@

# Include track cover image
$params->{image} = $menu->{cover};
+
+ # Allow addtional information links
+ $params->{'tracklinks'} =
$Slim::Web::Pages::additionalLinks{songinfo};

Slim::Web::XMLBrowser->handleWebIndex( {
client => $client,
Index: HTML/EN/cmdwrappers
================================================== =================
--- HTML/EN/cmdwrappers (revision 24389)
+++ HTML/EN/cmdwrappers (working copy)
@@ -321,9 +321,11 @@

[% BLOCK songInfoItem %]
<div id="[% title %]">
+ [% IF title %]
<span class="songInfoTitle">
- [% IF title; title | string; "COLON" | string; END
%]
+ [% title | string; "COLON" | string %]
</span>
+ [% END %]
<span class="songInfoText">[% item %]</span>
</div>
[% END %]
Index: HTML/EN/songinfo_header.html
================================================== =================
--- HTML/EN/songinfo_header.html (revision 24389)
+++ HTML/EN/songinfo_header.html (working copy)
@@ -98,6 +98,16 @@
[% IF itemobj.album.replay_gain.defined %]
[% item = itemobj.album.replay_gain |
format('%2.2f') |html; title = "ALBUMREPLAYGAIN"; PROCESS songInfoItem %]
[% END %]
+
+ [% FOREACH link = albumlinks.keys %]
+ [% item = BLOCK %]<a href="[% albumlinks.$link
%]album.id=[% itemobj.album.id %]" [% UNLESS notarget %]target="browser"[%
END %]>[% link | string %]</a>[% END %]
+ [% PROCESS songInfoItem title = undef %]
+ [% END %]
+
+ [% FOREACH link = tracklinks.keys %]
+ [% item = BLOCK %]<a href="[% tracklinks.$link
%]id=[% itemobj.id %]" [% UNLESS notarget %]target="browser"[% END %]>[%
link | string %]</a>[% END %]
+ [% PROCESS songInfoItem title = undef %]
+ [% END %]
</div>

</div>

pippin
2008-12-22, 11:29
Didn't I just learn that TrackInfo does that???

Triode
2008-12-22, 12:20
> Didn't I just learn that TrackInfo does that???

Not that I can see - where do you think it can be done already? I need to
pass the album.id or track.id of the browsed entry to the plugin link -
can't see a way of doing that?

pippin
2008-12-22, 12:44
Michael Herger's plugins do it:
http://forums.slimdevices.com/showthread.php?t=55267&highlight=trackinfo&page=2

I tried to propose something similar but then learned it does already work.
Don't ask me how, this whole Perl stuff is not for me.

Triode
2008-12-22, 12:58
> Michael Herger's plugins do it:
> http://forums.slimdevices.com/showthread.php?t=55267&highlight=trackinfo&page=2
>
> I tried to propose something similar but then learned it does already
> work.
> Don't ask me how, this whole Perl stuff is not for me.

Ah yes - but thats only the trackinfo page, I really want to be able to add
a link to the album page too, so didn't see that.

The application is to link into Bryan's cover art downloader, so it seems
more natural to have it at the album level. The alternative was to hijack
clicking on the artwork itself - this would be less generic, but is perhaps
all that is necessary.

Perhaps Michael can comment when he looks in.

kdf
2008-12-22, 13:08
Trackinfo, I believe, inserts controls on browsedb pages by acting as a mixer, piggybacking on the API in place to handle MusicIP. It could be possible to use this same technique, then set up the template to only show a control on album and trackinfo levels.

-kdf

Triode
2008-12-22, 16:09
> Trackinfo, I believe, inserts controls on browsedb pages by acting as a
> mixer, piggybacking on the API in place to handle MusicIP. It could
> be possible to use this same technique, then set up the template to
> only show a control on album and trackinfo levels.
>

Looks like the latest trackinfo uses its own API and not MusicIP. I can
definately get my code called for every browse action with the MusicIP one,
but I don't see how to add entries to the resulting html unless they hijack
links intended for musicIP.

If Michael reads this - what do you think is the easiest method - I want to
add a link on the album web page in browse db as per first post - can we use
any existing methods?

erland
2008-12-22, 16:14
> Michael Herger's plugins do it:
> http://forums.slimdevices.com/showthread.php?t=55267&highlight=trackinfo&page=2
>
> I tried to propose something similar but then learned it does already
> work.
> Don't ask me how, this whole Perl stuff is not for me.

Ah yes - but thats only the trackinfo page, I really want to be able to add
a link to the album page too, so didn't see that.

The application is to link into Bryan's cover art downloader, so it seems
more natural to have it at the album level. The alternative was to hijack
clicking on the artwork itself - this would be less generic, but is perhaps
all that is necessary.

When guestions have been asked that are similar to this, Andy's and Michael's answers always seems to be TrackInfo, but I don't think it is used anywhere besides in the Song Info page today. To be specific, it's used in xmlbrowser.html in the last big FOREACH statement.

However, Andy's and Michael's answers makes me believe that they have something planned for this. It would be really great if it was possible to register TrackInfo objects also on album pages, or to make it even more flexible make it possible to register them in headers of all browse pages. It would be useful to make it possible to have header items also on artists, years, genres and playlists.

A change like this would be more generic since it can be supported use also in the Controller interface and doesn't have to be web interface specific. However, I do think it will require changes in the registration process of TrackInfo. It probably have to be possible to specify in Slim::Menu::Base::registerInfoProvider if an item should appear on the album page, song info page or some other page header. At the moment all TrackInfo items appear on the song info page.

If you like to have a plugin link on the album page today, you can do it by register a mixer icon, see Slim::Plugin::MusicMagic::mixerlink for a sample of this. A mixer icon will appear as an icon, if you really want a text link I don't think there is a way to do it today. I've used mixer links in some of my plugins to add links to plugin pages in the album header, for example the TrackStat, Dynamic Playlist and Custom Browse plugins does this.

mherger
2009-01-05, 01:14
> Ah yes - but thats only the trackinfo page, I really want to be able to add a link to the album page too, so didn't see that.

Instead of the proposed web UI only addPageLink extension we should probably create an AlbumInfo menu similar to the trackinfo menu which could then potentially be used by all interfaces. Might in the long term also help with the MIP madness we have hardcoded in the browse modes for SqueezePlay.

--

Michael

erland
2009-01-05, 02:04
> Ah yes - but thats only the trackinfo page, I really want to be able to add a link to the album page too, so didn't see that.

Instead of the proposed web UI only addPageLink extension we should probably create an AlbumInfo menu similar to the trackinfo menu which could then potentially be used by all interfaces. Might in the long term also help with the MIP madness we have hardcoded in the browse modes for SqueezePlay.

Please make sure it is possible to do the same on Artist, Year, Genre, Playlist pages, don't limit it to albums it will just postpone the problem. It should be possible to add context menus/functions on all main Slim::Schema object types.

In the Custom Browse plugin browse menus I've headers on all object types already today. The Biography plugin is a great example where it would be useful on the Artist page.

Philip Meyer
2009-01-05, 02:25
>Please make sure it is possible to do the same on Artist, Year, Genre,
>Playlist pages, don't limit it to albums it will just postpone the
>problem. It should be possible to add context menus/functions on all
>main Slim::Schema object types.
>
>In the Custom Browse plugin browse menus I've headers on all object
>types already today. The Biography plugin is a great example where it
>would be useful on the Artist page.
>
I've been trying to add support in my Playlist Manager for adding songs to playlists from the Browse hierarchies too. Context menus on each classic player UI is what I would like. eg. navigate to an item (album, artist, genre, year, playlist) and be able to select "Add to playlist".

erland
2009-01-05, 02:42
I've been trying to add support in my Playlist Manager for adding songs to playlists from the Browse hierarchies too. Context menus on each classic player UI is what I would like. eg. navigate to an item (album, artist, genre, year, playlist) and be able to select "Add to playlist".

My preference would be:

Classic Player: Context Menu on item
SqueezePlay Controller: Context Menu on item
SqueezePlay Desktop: Context Menu on item + Icon/Link in page header (compare to mixer icons in current Album page in web interface)
Web Interface: Context Menu on item + Icon/Link in page header (compare to mixer icons in current Album page)

I know current SqueezePlay Desktop doesn't have any page headers at the moment but I figure this is going to happen as soon as Squeezeplay is more adapted for usage with a mouse (which is the primary control device on a computer).

Michael/Andy, depending on how the new schema is designed this might be related to it. Today the object types are predefined in Slim::Schema::* but if I understood Brandon correctly the new schema are going to be more configurable, if this involves custom object types we might need an even more generic solution. As an example, you might want different icons/links to appear on a Artist compared to a Composer or Conductor. Of course, we might also want to limit the possibilities so it doesn't get too complex.

I think the important thing here is to get the hooks in place so at least third party plugins can start to use them even though they aren't used much in standard SqueezeCenter functionality in the beginning.