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:

http://beta.mybinder.org/v2/gh/binder-examples/requirements/master

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:

http://beta.mybinder.org/v2/gh/use_referrer

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 https://github.com/binder-examples/latex/tree/yuvipanda-patch-1 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 https://github.com/jupyterhub/binderhub/issues/880 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 https://addons.mozilla.org/en-US/firefox/addon/open-with-binder/ 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 https://binder-redirector.example.org, that website extracts the referrer and converts it into a full mybinder.org 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: https://blog.mozilla.org/security/2018/01/31/preventing-data-leaks-by-stripping-path-information-in-http-referrers/

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ā€¦