Ask Your Question

Revision history [back]

This isn't a complete answer, but may get you or someone else started, depending on how hard you want to work:

As far as I can tell, there are basically two things you need to be able to do to display the output on a separate page. First, figure out how to load the JMol application on that page. I think this involves finding and loading a bunch of javascript files, and is probably described on the JMol Website. Second, figure out how to find the data file Sage produces to be plotted with JMol, and also load that into your webpage. To that end, I would suggest looking at the source code for your notebook page, and search for some lines like the following (I'd suggest searching for "jmol?" on the page):

<div class="cell_output_html_wrap" id="cell_output_html_112">
  <div><script>jmol_applet(500, "/home/admin/10/cells/112/sage0-size500.jmol?1290969964");</script></div>
</div>

The path specified is relative to the location of your sage notebook files. This is printed right after you start the notebook server -- the default is ".sage/sage_notebook" in your home directory:

sage: notebook()
The notebook files are stored in: sage_notebook.sagenb

Once you've found the relevant data file and copied it somewhere your page can load it, you might be finished by just using something like the <script> block above . . . except that I don't see jmol_applet as part of the JMol documentation -- the closest-looking function I've seen is jmolApplet. So if jmol_applet is defined in one of the other javascript libraries loaded in the sage notebook, then you'll have to load that library and all of its dependencies too, or figure out how to use one of the other JMol commands to load and display your data file. Looking again at the source of the notebook page with your 3d plot may give you a good idea of which javascript files to use.

Good luck, and please let us know if you make some progress on this, or find out a better way to do it!

click to hide/show revision 2
update for JMol applet

This isn't a complete answer, but may get you or someone else started, depending on how hard you want to work:

As far as I can tell, there are basically two things you need to be able to do to display the output on a separate page. First, figure out how to load the JMol application on that page. I think this involves finding and loading a bunch of javascript files, and is probably described on the JMol Website. Second, figure out how to find the data file Sage produces to be plotted with JMol, and also load that into your webpage. To that end, I would suggest looking at the source code for your notebook page, and search for some lines like the following (I'd suggest searching for "jmol?" on the page):

<div class="cell_output_html_wrap" id="cell_output_html_112">
  <div><script>jmol_applet(500, "/home/admin/10/cells/112/sage0-size500.jmol?1290969964");</script></div>
</div>

The path specified is relative to the location of your sage notebook files. This is printed right after you start the notebook server -- the default is ".sage/sage_notebook" in your home directory:

sage: notebook()
The notebook files are stored in: sage_notebook.sagenb

Once you've found the relevant data file and copied it somewhere your page can load it, you might be finished by just using something like the <script> block above . . . except that I don't see jmol_applet as part of the JMol documentation -- the closest-looking function I've seen is jmolApplet. So if jmol_applet is defined in one of the other javascript libraries loaded in the sage notebook, then you'll have to load that library and all of its dependencies too, or figure out how to use one of the other JMol commands to load and display your data file. Looking again at the source of the notebook page with your 3d plot may give you a good idea of which javascript files to use.

Good luck, and please let us know if you make some progress on this, or find out a better way to do it!


Update:

I just noticed that if you try to plot something from the command line, sage opens up a JMol java applet which has useful options and menus like File > Export > Export to Web Page. This saves the data in a place of your choosing, but you still have to point it to the JMol .jar files.