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

New notebook extension: code snippets #826

Merged
merged 5 commits into from
Jan 2, 2017
Merged

Conversation

adrn
Copy link
Contributor

@adrn adrn commented Dec 31, 2016

This PR adds a new notebook extension for inserting code snippet cells into the current notebook. When enabled, the extension inserts a drop-down menu into the toolbar with a list of named code snippets specified by the user in nbextensions/snippets/snippets.json. The extension ships with an example snippet.

This is based off of an old extension of mine.

@jcb91
Copy link
Member

jcb91 commented Dec 31, 2016

nice :) reminds me of https://github.com/moble/jupyter_boilerplate, which I've always thought we should add, but never got round to asking @moble about it

@jcb91 jcb91 merged commit 8946d07 into ipython-contrib:master Jan 2, 2017
function load_extension() {
config.load(); // trigger loading config parameters

$.getJSON("/nbextensions/snippets/snippets.json", function(data) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, should have picked this up before, but this path will fail on anyn server not using the default base_url of /, for example on jupyterhub. A better solution would be to use a relative path ./snippets.json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the $.getJSON callback relies on the config.loaded already having added the select, so it might be better to chain them directly. I should have mentioned these before merging, really, sorry!

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