Feature request: support for Spotify URIs

13 views
Skip to first unread message

Szabolcs

unread,
Apr 13, 2009, 4:36:41 PM4/13/09
to TiddlyWiki

TiddlyWiki already has an easy way of including http:// and file://
links. I'd really love it if support were added for Spotify links.

Spotify is a music service that lets you listen to tracks from their
library with their desktop application. They have their own URI
scheme for linking to playlists, tracks, etc., so people can share
links to music easily. These Spotify links can simply be included in
a <a href="...">...</a>, just like http:// links. See examples here:
http://www.spotify.com/blog/

Here are a few examples of what these links look like:

spotify:user:passat_ecofuel:playlist:3bCdgV61L2bsPqntSf66cE
spotify:artist:5zjaF8JUdylMWrA7AVo3hJ
spotify:album:6m0NiddbaJOMalKjHRlrZX
spotify:track:4303mcjazJ1XBqpUxSYU07

There are already several programs (IM clients, IRC clients) that
added support for these URIs. I'd love it if TiddlyWiki also
supported them because then I could use it to bookmark and organize
the music I like.

At the moment, [[SomeArtist|spotify:artist:5zjaF8JUdylMWrA7AVo3hJ]]
doesn't work like [[SomeLink|http://google.com/]] does.

Eric Shulman

unread,
Apr 13, 2009, 5:01:49 PM4/13/09
to TiddlyWiki
> TiddlyWiki already has an easy way of including http:// and file://
> links.  I'd really love it if support were added for Spotify links.

> Here are a few examples of what these links look like:
> spotify:user:passat_ecofuel:playlist:3bCdgV61L2bsPqntSf66cE
> spotify:artist:5zjaF8JUdylMWrA7AVo3hJ
> spotify:album:6m0NiddbaJOMalKjHRlrZX
> spotify:track:4303mcjazJ1XBqpUxSYU07

> At the moment, [[SomeArtist|spotify:artist:5zjaF8JUdylMWrA7AVo3hJ]]
> doesn't work like [[SomeLink|http://google.com/]] does.

Try this: create a tiddler tagged with 'systemConfig' containing the
following single line of javascript:
-------------------
config.textPrimitives.urlPattern = "(?:spotify|file|http|https|mailto|
ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
-------------------
after saving and reloading, "PrettyLinks" using "spotify:" as the
protocol should then be recognized as external URLs, like this:
[[text to show|spotify:...]]


enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios





FND

unread,
Apr 13, 2009, 5:13:41 PM4/13/09
to Tiddl...@googlegroups.com
> -------------------
> config.textPrimitives.urlPattern = "(?:spotify|file|http|https|mailto|
> ftp|irc|news|data):[^\\s'\"]+(?:/|\\b)";
> -------------------
> after saving and reloading, "PrettyLinks" using "spotify:" as the
> protocol should then be recognized as external URLs

Interestingly, that doesn't make Spotify URIs be picked up automatically
(without the use of PrettyLinks) - I haven't looked into this yet, but I
assume it's a load-order issue.

The following adds an additional formatter for that purpose:
---------------
/***
spotify:foo
[[bar|spotify:bar]]
***/
//{{{
config.textPrimitives.urlPattern = config.textPrimitives.urlPattern.
replace("data", "data|spotify");

config.formatters.push({
name: "spotifyLink",
match: "spotify:.+",
handler: function(w) {
w.outputText(createExternalLink(w.output,w.matchText),
w.matchStart,w.nextMatch);
}
});
//}}}
---------------
(There should be a more elegant solution though, e.g. reusing the
urlLink formatter - I might look into that another day).


-- F.

Szabolcs

unread,
Apr 13, 2009, 5:14:27 PM4/13/09
to TiddlyWiki
Thanks Eric, it works wonderfully! :-)

Szabolcs

unread,
Apr 13, 2009, 5:24:19 PM4/13/09
to TiddlyWiki
There's one more tiny thing though. Outside links in TiddlyWiki are
opened in new tabs (for pretty obvious reasons). But this is a
disadvantage for "spotify:" links, as the new tab will be just an
empty one anyway (and I have to close it manually). Would it be
possible to open Spotify links in the same tab? Unlike with http://
links, this would not make the browser navigate away from that page.

Of course the most important thing is that it works now. :-) This
would just be a bonus over that.

FND

unread,
Apr 13, 2009, 5:24:51 PM4/13/09
to Tiddl...@googlegroups.com
> I assume it's a load-order issue
> [...]

> There should be a more elegant solution

There is; simply re-evaluating the existing formatter's match pattern:
---------------
/***
spotify:foo
[[foo|spotify:foo]]
***/
//{{{
(function() {

config.textPrimitives.urlPattern = config.textPrimitives.urlPattern.
replace("data", "data|spotify");

var f = config.formatters.findByField("name", "urlLink");
config.formatters[f].match = config.textPrimitives.urlPattern;

})();
//}}}
---------------

However, I'm not entirely happy with that yet, as it should be easier to
extend the list of supported protocols.
That might be an issue for the dev group though...


-- F.

Szabolcs

unread,
Apr 13, 2009, 6:29:17 PM4/13/09
to TiddlyWiki


On Apr 14, 12:24 am, Szabolcs <szhor...@gmail.com> wrote:
>
> There's one more tiny thing though.  Outside links in TiddlyWiki are
> opened in new tabs (for pretty obvious reasons).  But this is a
> disadvantage for "spotify:" links, as the new tab will be just an
> empty one anyway (and I have to close it manually).  Would it be
> possible to open Spotify links in the same tab?  Unlike with http://
> links, this would not make the browser navigate away from that page.
>

Sorry about that, I found the option to disable opening links in a new
tab.
Reply all
Reply to author
Forward
0 new messages