Skip to content

[livemdpreview] add new nbextension!#1155

Merged
jcb91 merged 4 commits intoipython-contrib:masterfrom
jcb91:livemdpreview
Nov 15, 2017
Merged

[livemdpreview] add new nbextension!#1155
jcb91 merged 4 commits intoipython-contrib:masterfrom
jcb91:livemdpreview

Conversation

@jcb91
Copy link
Copy Markdown
Member

@jcb91 jcb91 commented Nov 4, 2017

idea prompted from jupyter/notebook#2882

@juhasch
Copy link
Copy Markdown
Member

juhasch commented Nov 4, 2017

Very nice 😄

One minor thing: The default for show_side_by_side is different in the yaml and in the js file.
I guess we should really try to read in the default values from the description file and not have it set twice.

@jcb91
Copy link
Copy Markdown
Member Author

jcb91 commented Nov 4, 2017

Ah, good spot @juhasch, thanks!

I guess we should really try to read in the default values from the description file and not have it set twice.

Haha yeah, it could be simpler! I think we'd need to be using JSON though 😉

@juhasch
Copy link
Copy Markdown
Member

juhasch commented Nov 4, 2017

If it works I will even swallow evil JSON 😏

@jcb91
Copy link
Copy Markdown
Member Author

jcb91 commented Nov 4, 2017

Haha, well, getting the defaults from json should be easy enough, something like

var utils = require('base/js/utils');
var pkg_json_url = require.toUrl('./package.json');
var params = {};

utils.promising_ajax(
    pkg_json_url, {processData : false, cache : false, type : "GET", dataType : "json"}
).then(function (pkg_json) {
    // e.g. if we use the config suggested in https://github.com/jupyter/notebook/issues/2824#issuecomment-334124949
    $.extend(true,
        params,
        pkg_json.org_jupyter_nbextension.parameters,
        Jupyter.notebook.config.data.mynbextensionname);
});

(to get defaults, update with notebook config)

@jcb91
Copy link
Copy Markdown
Member Author

jcb91 commented Nov 5, 2017

hmm, actually, I guess it's a bit more difficult, since there's also the stored parameter metadata. So you'd need something like

var default_params = {};
pkg_json.org_jupyter_nbextension.parameters.forEach(
    function (param) { default_params[param.name] = param.default; });

to handle that

@jcb91 jcb91 merged commit e620b12 into ipython-contrib:master Nov 15, 2017
@jcb91 jcb91 deleted the livemdpreview branch November 28, 2017 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants