[IPython-dev] custom mime types in the notebook

MinRK benjaminrk at gmail.com
Sat Jul 12 12:23:54 EDT 2014


I can't speak for every IPython dev, but I agree that approach 1 is
theoretically cleaner. However, approach 2 is a lot easier to get working
and can be used to get the nicer representation on nbviewer, which approach
1 cannot.

I can't say which I prefer, but I can say which I tend to do, and that's
#2. But doing something is different from endorsing it :)

-MinRK


On Fri, Jul 11, 2014 at 11:50 AM, Cyrille Rossant <cyrille.rossant at gmail.com
> wrote:

> >> What's the best way to do it? Should I create a custom mime type
> >> "application/myapp", and extend the notebook to use the JS app for
> >> that mime type (if that's even possible)?
> >
> > I think this opens up a can of worms (certainly relative to the approach
> > above).   Going this route, you start to introduce dependencies on how
> the
> > notebook is served, and you make the notebook itself less portable.
>
> Thanks. Could you elaborate on why this approach would make the
> notebook less portable?
>
> Let's take an example. Imagine I want to display 3D models in a
> notebook using a JS library (like three.js).
>
> Approach 1:
>
> * My cell's output contains data in several mime types: PNG with a
> screenshot, and OBJ (for example) with the full 3D model. It seems to
> me that the nbformat is designed for this (multiple MIME types
> representing the same logical data).
>
> * If the client understands the OBJ mime type, it displays it using
> three.js.
>
> * Otherwise, it just displays the PNG screenshot.
>
> Approach 2 would be to embed the entire Javascript code in the output
> + <script include jslibraries> (like you suggest, and like mpld3 does,
> unless I'm mistaken)
>
> I guess my questions are:
>
> * Which of those two approaches is recommended by IPython devs?
> * Is the notebook designed for approach 1 use-case or not?
>
> It seems to me that approach 1 is cleaner while approach 2 looks like
> a hack, but that's just my opinion.
>
> Best,
> Cyrille
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140712/cd878821/attachment.html>


More information about the IPython-dev mailing list