Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic script / plugins #16

Open
szym opened this issue Feb 3, 2016 · 4 comments
Open

Dynamic script / plugins #16

szym opened this issue Feb 3, 2016 · 4 comments
Assignees

Comments

@szym
Copy link
Owner

szym commented Feb 3, 2016

A dynamic plugin system would make the server even more versatile.

Instead of having a fixed set of commands, the client could instruct the browser to execute any Javascript thus loading plotting libraries on demand. This way the client would be able to extend the command set and we'd be able to add functionality through lua+js packages without having to update the display server and its static assets.

@soumith
Copy link
Contributor

soumith commented Feb 3, 2016

i've been thinking about the same, as I try to integrate bokeh.js plotting that I implemented for ITorch.
Does it sound reasonable to add an "eval" endpoint that executes arbitrary javascript?

@szym
Copy link
Owner Author

szym commented Feb 3, 2016

I'm trying to decide on the approach. There's a few options here.

  • raw html, like in adding HTML pane #14
    pro: attached as child to the new Pane, so does not need any more context to add custom DOM
    con: cannot resize the Pane to fit (although document.currentScript.parent.parent might give you the pane element)
    con: requires wrapping script in <script> tags
    pro: easy way to add external scripts <script src=.../>
    con: to allow script sharing, need to write some boilerplate (if (typeof(window.bokeh) === 'undefined'))

  • raw string eval()
    pro: no need to wrap scripts
    con: external scripts require extra boilerplate:

    var el = document.createElement('script');
    el.src = 'http://external';
    document.body.appendChild(el);
    

    con: no Pane context, where to add DOM?

  • mixed API that would take care of the boilerplate:

    {   "command": "eval",
        "external": [ "http://external/xxx" ],
        "script": "function(pane) {...}" }
    

    pro: easy external scripts
    pro: allows external script sharing -- no need to load the same external source twice
    pro: explicit Pane context
    pro: no need to add <script> tags

Does it cover all the essential scenarios? Would this support bokeh.js integration?

@soumith
Copy link
Contributor

soumith commented Feb 3, 2016

script tags in raw html (point 1) do not get executed unless the script is in another file. I tried #14 in the hope of solving this but turns out i cant. eval is the only way one can execute javascript sent over the network (from my brief google searches), though you probably know better.

@soumith
Copy link
Contributor

soumith commented Feb 3, 2016

and yes, either of (1), (2) or (3) would solve the bokeh.js integration.

@szym szym self-assigned this Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants