Alright, it was a struggle debugging javascript (i feel sorry for the people that have to code in it for a living), but finally I am done with the hook between the graph editor and sage notebook. Here is the first prototype:
1) get http://www.math.uiuc.edu/~rkirov2/sage/graph_editor.zip 2) exact all files in %sage_dir%/local/notebook/javascript/ graph_editor/ (create that folder it wont be there) 3)open a notebook and run load %sage_dir%/local/notebook/javascript/graph_editor/jquery.py (replacing sage_dir with your sage directory) or just copy/paste the file in question 4)try g=graphs.PetersenGraph() graph_editor(g) A few known bugs(limitations): - update button only updates the cell text, its up to you to hit "evaluate" to send the new data to the server (can't do much about it, since i dont want to mess with the server-side code). - update puts graph named g by default. - the remove edge by draggin only works in the iframe box I agree with Jason that with the power of js these days, we can make many cool plug-ins for SAGE (like the graph editor;) ). However, practice it was quite a struggle to get this to work (it took me almost as long to make it work with SAGE as to write the thing). We have to decide how would plug-ins work: 1)Make a basic API for plug-ins to communicate directly with SAGE server in some generic form (i think JSON is a standard for that although i never used it). Currently, the server is made to talk only to a cell because it spits out things like cell id and such. ~or~ 2)Force all plug-ins go through updating cells first (like the graph_editor does now for lack of alternative) by jquery trickery. I dont like that this ties any client implementation with the notebook, which is already quite heavy machinary (i stared at js.py for quite some time). But then again this is already working, so no rewrite needed. Also, does anyone know a more graceful way of passing variables to an iframe other than the current href="graph_editor?g=.....data..." ? Rado PS. LeSmithe, if you have time try to add the cool jqueryui thing with detaches the iframes. Note that there is no need to explicitly refer to the id of the cell where it was contained, since I used relative jquery selectors. I feel i finally understand jquery's tricky functions (ooh that reminds me jquery in SAGE is old, 1.3 has a new tag closest() which is kinda cool). On Jul 3, 11:59 pm, Pat LeSmithe <[email protected]> wrote: > Jason Grout wrote: > > I envision the sage code cells having javascript plugins. A plugin > > would be a javascript object or something that, given a piece of sage > > code, could return an html "widget" that represents that sage code in > > some nice, possibly interactive way, and could be queried for a string > > of Sage code that represents the current state of the widget. > > Thanks to everyone for their comments, ideas, and contributions, whether > they're either already here or forthcoming! > > A quick note: I've posted a newer version at > > http://trac.sagemath.org/sage_trac/ticket/6460 > > It should now work in Firefox 3/3.5 and sundry other browsers. But most > of the other the changes are cosmetic. I'm sure Jason is working on his > uber-cells... > > By the way, does anyone have experience with the desktop package Tulip: > > http://www.labri.fr/perso/auber/projects/tulip/ > > ? Its focus appears to be 2D/3D interactive manipulation and > visualization of large graphs: > > http://www.labri.fr/perso/auber/projects/tulip/samples.php --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
