Render notebooks within Discourse when linked to GitHub

Hi,

Over on the Discourse Meta forum there is a discussion around rendering Jupyter Notebooks when they are linked to on GitHub:

As you can see, for the time being, when a GitHub link is provided the current one-box in Discourse displays the JSON:

Might there be an option to have a Jupyter Discourse plugin?

Cheers,
Simon

Looks like the way MyBinder launches render the preview using nbviewer would be a good guide good for this. This below is the pertinent code from the source of the page you get if you go to https://github.com/binder-examples/conda and hit ‘launch binder’ and then scroll down on the page:

<div id="nbviewer-preview">
  <iframe src="https://nbviewer.jupyter.org/github/binder-examples/conda_environment/blob/HEAD/index.ipynb"></iframe>
</div>

You’ll see that URL (https://nbviewer.jupyter.org/github/binder-examples/conda_environment/blob/HEAD/index.ipynb) just points nbviewer’s renderer at the GitHub source for the notebook json code. The nbviewer render experience is more full-featured in several ways than the one in use by GitHub, even though GitHub’s support has continued to improve even as recent as last November.

That corresponding iframe will show up on the launch page right below the text that says “Here’s a non-interactive preview on nbviewer while we start a server for you. Your binder will open automatically when it is ready.” The top part of that iframe is featured in the bottom of the following image.

Launches were happening too fast for me to get a great screenshot of the notebook iframe fully.
I got a bad shot of a middle of it, too:

Applying that…

It looks like the trello example is using iframes and so I think it would be just a matter of plugging into that as a guide to point to the nbviewer render?

1 Like