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

DEV: Added support for custom Notebook server base_url(s). Fixes #21. #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions qgrid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

from IPython.display import display_html, display_javascript

from IPython import get_ipython
ipython = get_ipython()
if ipython and ('NotebookApp' in ipython.config) and \
('base_url' in ipython.config['NotebookApp']):
NOTEBOOK_BASE_URL = ipython.config['NotebookApp']['base_url']
else:
NOTEBOOK_BASE_URL = ''
LOCAL_BASE_URL = NOTEBOOK_BASE_URL + "/nbextensions/qgridjs"
CDN_BASE_URL = "https://cdn.rawgit.com/quantopian/qgrid/"\
+ "ddf33c0efb813cd574f3838f6cf1fd584b733621/qgrid/qgridjs/"


def template_contents(filename):
template_filepath = os.path.join(
Expand Down Expand Up @@ -61,10 +72,9 @@ def _ipython_display_(self):
)

if self.remote_js:
cdn_base_url = \
"https://cdn.rawgit.com/quantopian/qgrid/ddf33c0efb813cd574f3838f6cf1fd584b733621/qgrid/qgridjs/"
cdn_base_url = CDN_BASE_URL
else:
cdn_base_url = "/nbextensions/qgridjs"
cdn_base_url = LOCAL_BASE_URL

raw_html = SLICK_GRID_CSS.format(
div_id=self.div_id,
Expand Down