Binderhub button - 'pull from referrer'

Github template repos could be hugely exciting, I think, as a way of supporting the sharing of base Binder environments, but one thing that could be irritating, and get overlooked, is the tweaking of Binder button paths in README files.

At the moment the Binder button link URL take the form of an explicit link to MyBinder with the path to the repo:

If you clone a repo, or generate a repo from a template repo, that path is carried along as the button link.

What would be nice would be to be able to specify a link of the form:

or similar from which the landing page can extract the referrer URL (IIRC, Javascript has s/thing like document.referrer ?) and use that URL to launch the Binder.

I guess federated Binder complicates this a little, because there is going to be forwarding from the landing page to the actual Binder server; so in that case, perhaps a second way of handling the original referrer also needs to be supported for the federated case, perhaps by rewriting the URL into the actual server URL in the normal way.

By the by, I also note that if you copy a branch URL from Github (eg into MyBinder and try to launch the repo, it throws an error, where you might optimistically expect the /tree/BRANCH to be automatically parsed from the Github repo URL form element into the Branch form element. (Would a naive user know how to do that conversion themselves?) If a Binder button was in a branch README, and the referrer button/link call was supported, that would raise this error.

This is an interesting idea and we should think about it when we work on a new UI for BinderHub. I created to collect ideas and mock ups for this. One thing I am pretty sure we will do is have one big input field where you paste a link and it “figures it out”. You could pre-fill it with the referrer or have an auto launch end point like you suggest.

(OT: I was wondering if we should have a second input field for “scratch pad mode” which uses a popular base binder and pulls in the repo. Or if that would be too confusing to people?)

In the meantime you should definitely check out which doesn’t help with badges but does make ones individuals life much easier. Just click the button and the extension creates the correct link and visits it.

Why not make this the only way of processing the referrer instead of handling the two cases separately? The advantage of this second method is the conversion service is completely independent of mybinder so you could demo it now! E.g. your readme links to, that website extracts the referrer and converts it into a full request.

1 Like

@psychemedia I was bored so made a proof of concept, currently only supports Gists and GitHub repos.

Click on the link in the README on

Note this is on the demo branch of that repo. Source for the website is in the master branch though it’s all client-side so you can also just view-source :slight_smile:

1 Like

If you’re using Firefox this doesn’t work in private browsing mode as the referrer path is stripped:

Nice work! Do you want to make PR to add this to BinderHub?

I think because of how the redirecting is done for the federation the referrer will (often) be preserved.

I’ll play around a bit more with the demo, but I’ll open a PR when ready.

1 Like

Nice… that could make life so much easier!

I owe you a(nother) pint / coffee…