Giter VIP home page Giter VIP logo

Comments (32)

juhasch avatar juhasch commented on July 26, 2024

Does ist help if you add the following lines to `ipython_notebook_config.py' in your profile directory:

c = get_config()
c.NotebookApp.extra_static_paths = ['/home/allan/my_path_to_custom']

from jupyter_contrib_nbextensions.

AllanLRH avatar AllanLRH commented on July 26, 2024

Unfortunately not.
I tried in both Firefox and Chrome.

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

Try inside an incognito session in Chrome... or delete your cache and try again...

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

Maybe you are using a different profile ?
What ist the console output when you start the IPython notebook ?

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

I've come across the same problem, my path is like this:

C:\Users\zhangxaochen\.ipython\profile_default\static\custom>ls
custom.js  usability

and my notebook is using this same profile dir:

[NotebookApp] Using existing profile dir: u'C:\\Users\\zhangxaochen\\.ipython\\profile_default'

Hope someone could give me some tips.

Btw, the wiki seems a bit confusing since it doesn't say where to put custom.js

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

btw when I type http://127.0.0.1:8888/static/custom/custom.js in my browser, it's just saying 404: Not Found

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

What happens if you try this in the notebook:

import urllib2
import os

c=get_ipython()
profile_dir = c.kernel.profile_dir.location
notebook_dir = c.config.FileNotebookManager.notebook_dir
extra_static_paths = c.config.NotebookApp.extra_static_paths[:]
print("Profile directory: %s" % profile_dir)
print("Notebook directory: %s" % notebook_dir)
print("Extra static path: %s" % extra_static_paths)
print("IP: %s" % c.config.IPKernelApp.ip)

# search for custom.js in configured directories
extra_static_paths.append(profile_dir+'/static')
for ep in extra_static_paths:
    custom_js_path = os.path.normpath(ep + '/custom/custom.js')
    print('Testing path %s' % custom_js_path)
    try:
        f = open(custom_js_path,'r')
        l = f.readline()
        print('Found custom.js here: %s' % custom_js_path)
        f.close()
    except:
        pass

# Test for custom.js using standard url
try:
    f=urllib2.urlopen('http://127.0.0.1:8888/static/custom/custom.js')
    print("custom.js found")
except:
    print("no custom.js found")

This should print you the relevant directories and test if custom.js is being found

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@juhasch there is no c.kernel.profile_dir, so I changed it to c.profile_dir. Also, I get AttributeError: 'notebook_dir'. I'm using IPython 0.13.2, don't know how to solve such an error... btw, are you in IRC python chatting channel or SO chat or somewhere we could talk directly.

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

IPython 0.13.2?? Upgrade it!
I don't remember enough, but I don't know if 0.13.2 support loading custom.js...

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@damianavila thx~ it's working now.
My new question is: Since alt+c is a global shortcut on my machine, is it possible to rebind the shortcut Alt+C to some other shortcut key e.g., Alt+/?
I find var commentKey = { "Alt-C" : function(cm){toggleComments(cm)} }; in file comment-uncomment.js, but changing C to / does not help.

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

I believe the standard is CTRL+/ (can't type it on my keyboard). If you can live with this, you probably don't need an extension.

from jupyter_contrib_nbextensions.

AllanLRH avatar AllanLRH commented on July 26, 2024

@juhasch The console output when I start my Ipython notebook is:

2014-03-24 11:24:26.800 [NotebookApp] Using existing profile dir: u'/Users/allan/.ipython/profile_default'
2014-03-24 11:24:26.811 [NotebookApp] Using MathJax from CDN: http://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-03-24 11:24:26.831 [NotebookApp] Serving notebooks from local directory: /Users/allan
2014-03-24 11:24:26.832 [NotebookApp] The IPython Notebook is running at: http://127.0.0.1:8888/
2014-03-24 11:24:26.832 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

And when I click a notebook to open it:

2014-03-24 11:24:42.701 [NotebookApp] Connecting to: tcp://127.0.0.1:49330
2014-03-24 11:24:42.706 [NotebookApp] Kernel started: 2fc669ad-e3cb-4ee2-9efe-c0fc20a64679
2014-03-24 11:24:43.245 [NotebookApp] Connecting to: tcp://127.0.0.1:49327
2014-03-24 11:24:43.246 [NotebookApp] Connecting to: tcp://127.0.0.1:49329
2014-03-24 11:24:43.247 [NotebookApp] Connecting to: tcp://127.0.0.1:49328

I just updated to version 1.2 (from 1.1), which didn't fix the problem.
I also tried in incognito mode.

Some of the code you posted didn't work, so had to comment out a few lines, but here's the code and the output:

import urllib2
import os

c=get_ipython()
profile_dir = c.profile_dir.location
# notebook_dir = c.FileNotebookManager.notebook_dir  # doesn't work
# extra_static_paths = c.config.NotebookApp.extra_static_paths[:]  # doesn't work
print("Profile directory: %s" % profile_dir)
# print("Notebook directory: %s" % notebook_dir)  # doesn't work
# print("Extra static path: %s" % extra_static_paths)  # doesn't work
# print("IP: %s" % c.config.IPKernelApp.ip)  # doesn't work

# search for custom.js in configured directories
extra_static_paths.append(profile_dir+'/static')
for ep in extra_static_paths:
    custom_js_path = os.path.normpath(ep + '/custom/custom.js')
    print('Testing path %s' % custom_js_path)
    try:
        f = open(custom_js_path,'r')
        l = f.readline()
        print('Found custom.js here: %s' % custom_js_path)
        f.close()
    except:
        pass

# Test for custom.js using standard url
try:
    f=urllib2.urlopen('http://127.0.0.1:8888/static/custom/custom.js')
    print("custom.js found")
except:
    print("no custom.js found")
Profile directory: /Users/allan/.ipython/profile_default
Testing path /Users/allan/.ipython/profile_default/static/custom/custom/custom.js
Testing path /Users/allan/.ipython/profile_default/static/custom/custom.js
Found custom.js here: /Users/allan/.ipython/profile_default/static/custom/custom.js
custom.js found

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@juhasch wow! great! why is this not documented in the help menu?

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

AFAIK, it is documented...

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

I mean, in the Keyboard shortcuts popup page when pressing Ctrl-m h

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

@zhangxaochen: In IPython 2.0dev it is documented.
@AllanHansen: I think you have one custom too much in your path.
Here is what I have in my config file:
c.NotebookApp.extra_static_paths = ['n:\\.ipython\\static']
And my custom file is here:
n:\.ipython\static\custom\custom.js

from jupyter_contrib_nbextensions.

AllanLRH avatar AllanLRH commented on July 26, 2024

I moved the static folder from /Users/allan/.ipython/profile_default/static/ to /Users/allan/.ipython/static/, and added /Users/allan/.ipython/static/ to the c.NotebookApp.extra_static_paths in the Ipython notebook config file. It's still the standard file which is shown when I visit http://127.0.0.1:8888/static/custom/custom.js

I guess a working, albeit less optimal, solution is to edit the standard file (or replace it with a symlink)...?

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

@AllanHansen did you succeed? Can we close this one?

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

Closing, if you have problems again, just reopen it...

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

I reinstalled my win7 a few days ago, and also anaconda2.0.1 (python2.7.7 & ipython2.1.0). Now I can access http://localhost:8888/static/custom/custom.js, and http://localhost:8888/nbextensions/publishing/gist_it.js, but still could not get the exts working correctly.

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@damianavila how can I get the issue reopened? or do I need to open another issue?

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

Can you do a quick summary of you steps... I am not a win user, but I think @juhasch is a win user, so if this is win related, he probably can help you more, but let first hear your summary to dig into it, thanks!

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

I don't know what this extension is supposed to do.

If you are looking for an extension to upload notebooks as gists this might be better:
https://github.com/minrk/ipython_extensions

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@damianavila @juhasch I mean not only gist (or gist_it), but all the other extensions.

I unzip IPython-notebook-extensions-master.zip and copy folders publishing, slidemode, etc. to <ipython locate>/nbextensions,
then I copy the contents of custom.example.js to custom.js,
then I uncomment the lines e.g. IPython.load_extensions('publishing/nbconvert_button'), and restart notebook, nothing happened,
then I tried IPython.load_extensions('publishing/nbconvert_button.js'), IPython.load_extensions('nbextensions/publishing/nbconvert_button.js'), and nothing happened...

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

OK, so try if you can load the extension in your browser, i.e. see the sourcecode. For me it is
http://127.0.0.1:8888/nbextensions/publishing/nbconvert_button.js

Then, the Javascript command to load the extension is
IPython.load_extensions('publishing/nbconvert_button') (no .js).

Unfortunately, right now it is not easy to install and load extensions. This will be improved, but we are not there yet.

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@juhasch http://127.0.0.1:8888/nbextensions/publishing/nbconvert_button.js is OK to access, and I'm using IPython.load_extensions('publishing/nbconvert_button') right now, seems same as what the WIKI page says

Is there a way to debug the js script to see whether it's loading correctly? not knowing much about JS

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

This works for me with IPython 2.1. Can you check if there are any messages if you activate the Javascript console in your Broswer ?
It should say Loaded extension: publishing/nbconvert_button

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@juhasch it's:

Default extension for cell metadata editing loaded.
Raw Cell Format toolbar preset loaded.
Slideshow extension for metadata editing loaded.
gist extension loaded
Uncaught TypeError: Cannot read property 'on' of undefined
patching CM for undefined indent
Kernel started:  9421f308-49aa-4936-bf67-d895938e3747
Starting WebSockets: ws://127.0.0.1:8888/api/kernels/9421f308-49aa-4936-bf67-d895938e3747

my custom.js is:

require(["nbextensions/gist"], function (gist_extension) {
    console.log('gist extension loaded');
    gist_extension.load_ipython_extension();
});

// activate extensions only after Notebook is initialized
require(["base/js/events"], function (events) {
    events.on("app_initialized.NotebookApp", function () {
    IPython.load_extensions('publishing/nbconvert_button')
....

from jupyter_contrib_nbextensions.

juhasch avatar juhasch commented on July 26, 2024

You need to get the 2.x version (2-x branch on Github) of the extensions and the custom.js example.

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

@zhangxaochen, I gonna close this one because the issue will be solved by the 2-x branch, let us know if you have more problems...

from jupyter_contrib_nbextensions.

zhangxaochen avatar zhangxaochen commented on July 26, 2024

@juhasch @damianavila branch 2-x is OK, what does the current master working with then?

from jupyter_contrib_nbextensions.

damianavila avatar damianavila commented on July 26, 2024

Working with IPython 3.0-dev...

from jupyter_contrib_nbextensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.