forked from jupyterlab/extension-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jupyterlab#145 from jupyterlab/fcollonval-patch-1
Update server extension entry points
- Loading branch information
Showing
6 changed files
with
137 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
import json | ||
import os.path as osp | ||
from pathlib import Path | ||
|
||
from .handlers import setup_handlers | ||
from ._version import __version__ | ||
|
||
HERE = osp.abspath(osp.dirname(__file__)) | ||
HERE = Path(__file__).parent.resolve() | ||
|
||
with open(osp.join(HERE, 'labextension', 'package.json')) as fid: | ||
with (HERE / "labextension" / "package.json").open() as fid: | ||
data = json.load(fid) | ||
|
||
|
||
def _jupyter_labextension_paths(): | ||
return [{ | ||
'src': 'labextension', | ||
'dest': data['name'] | ||
}] | ||
return [{"src": "labextension", "dest": data["name"]}] | ||
|
||
|
||
def _jupyter_server_extension_paths(): | ||
def _jupyter_server_extension_points(): | ||
return [{"module": "jlab_ext_example"}] | ||
|
||
|
||
def load_jupyter_server_extension(lab_app): | ||
def _load_jupyter_server_extension(server_app): | ||
"""Registers the API handler to receive HTTP requests from the frontend extension. | ||
Parameters | ||
---------- | ||
lab_app: jupyterlab.labapp.LabApp | ||
server_app: jupyterlab.labapp.LabApp | ||
JupyterLab application instance | ||
""" | ||
url_path = "jlab-ext-example" | ||
setup_handlers(lab_app.web_app, url_path) | ||
lab_app.log.info( | ||
"Registered jlab_ext_example extension at URL path /{}".format(url_path) | ||
setup_handlers(server_app.web_app, url_path) | ||
server_app.log.info( | ||
f"Registered jlab_ext_example extension at URL path /{url_path}" | ||
) | ||
|
||
# For backward compatibility with the classical notebook | ||
load_jupyter_server_extension = _load_jupyter_server_extension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
version_info = (0, 1, 0) | ||
__version__ = ".".join(map(str, version_info)) | ||
import json | ||
from pathlib import Path | ||
|
||
__all__ = ["__version__"] | ||
|
||
def _fetchVersion(): | ||
HERE = Path(__file__).parent.resolve() | ||
|
||
for settings in HERE.rglob("package.json"): | ||
try: | ||
with settings.open() as f: | ||
return json.load(f)["version"] | ||
except FileNotFoundError: | ||
pass | ||
|
||
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}") | ||
|
||
__version__ = _fetchVersion() |
7 changes: 7 additions & 0 deletions
7
advanced/server-extension/jupyter-config/jupyter_notebook_config.d/jlab_ext_example.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"NotebookApp": { | ||
"nbserver_extensions": { | ||
"jlab_ext_example": true | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.