quiver
quiver copied to clipboard
Exposing Quiver as an API
Hi @varkor!
I was wondering if there were plans to have quiver
's diagram construction and extraction to various formats as part of an externally query-able API? I'd love to write bindings for one.
Cheers!
At the moment, it is unfortunately quite difficult to set this up, because everything must be static to be hosted on GitHub Pages. I don't see a way to support this without changing how quiver is hosted.
@varkor what if all we need is a javascript call into Quiver for getting the base64 encoding and another call for setting, or we could set by directing the iframe to the new URL. But if we host Quiver ourselves in a Django template, then this API via javascript call will work.
@emilypi I need this feature too! It is in fact critical to my application that I be able to get and set the graph externally.
If you're willing to self-host quiver, then this would be possible, yes (most likely you could use the existing internal APIs without much hassle). I agree that it would be nice to have this feature without self-hosting, but at the moment, I don't see how to achieve this the current way quiver is set up.
I can share some code of how I accomplished the Javascript API for my personal project "Abstract Spacecraft". I even did it with Quiver completely copied into a folder under Django project's static/ directory. I then have a Django template with an iframe call to load quiver in it. The Django template in turn is then included (with special #IncludeDjangoTemplate-diagram_editor HTML tag id). The export script of Bootstrap Studio then includes the template using a Jinja2 include statement. And it works! I then hid all of the default Quiver buttons / panes using CSS display:none
. If you had to completely remove them it would require a lot of JS editing of ui.js or else things would be broken. Anyway, I have bootstrap buttons and a connect_quiver_gui.js
included into my BSS design. That file does JQuery statements to call functions that I coded inside of the UI class (ui.js of Quiver). There's things you have to do such as load the CSRF token into the iframe's parent window as a global JS variable, as well as the URL to the Django/Neo4j database save/load code. Those functions are essentially like an API. That is the way forward to solve your issues I think. Self-host Quiver (easy to do, download, run make, and copy into your project), and start hacking the ui.js / quiver.js code to create your API. I am available if you need help with this. I was also new to JS, but somehow managed to get things to work just by googling around and the SO stack exchange. @emilypi
@varkor All we need are some instructions on how to get the URL from the iframe and how to set it and reload Quiver if needed. We don't need much in the way of an API in other words. So please help us do this :)
We would like to use your version of Quiver, either hosted by us or by your web host, so that we can always keep it up-to-date with what you're developing and pushing to github.
@enjoysmath: I don't think you will be able to get the URL of an <iframe>
if quiver is hosted externally due to security constraints in JavaScript. However, if you are self-hosting quiver, then you should be able to query and set the URL with:
your_iframe.contentWindow.location.href
@emilypi: could you say a few more words about the use case you have in mind?