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

[livemdpreview] add new nbextension! #1155

Merged
merged 4 commits into from
Nov 15, 2017
Merged

Conversation

jcb91
Copy link
Member

@jcb91 jcb91 commented Nov 4, 2017

idea prompted from jupyter/notebook#2882

@juhasch
Copy link
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
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
Member

juhasch commented Nov 4, 2017

If it works I will even swallow evil JSON 😏

@jcb91
Copy link
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
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.

None yet

2 participants