working on serverextension

This commit is contained in:
Tim Paine 2018-03-13 00:44:53 -04:00
parent 0881370cdb
commit 13767b7255
7 changed files with 207 additions and 0 deletions

101
.gitignore vendored
View file

@ -60,3 +60,104 @@ typings/
package-lock.json
lib
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/

34
Makefile Normal file
View file

@ -0,0 +1,34 @@
tests: ## Clean and Make unit tests
python3 -m nose -v tests --with-coverage --cover-erase --cover-package=`find jupyterlab_iframe -name "*.py" | sed "s=\./==g" | sed "s=/=.=g" | sed "s/.py//g" | tr '\n' ',' | rev | cut -c2- | rev`
test: ## run the tests for travis CI
@ python3 -m nose -v tests --with-coverage --cover-erase --cover-package=`find jupyterlab_iframe -name "*.py" | sed "s=\./==g" | sed "s=/=.=g" | sed "s/.py//g" | tr '\n' ',' | rev | cut -c2- | rev`
clean: ## clean the repository
find . -name "__pycache__" | xargs rm -rf
find . -name "*.pyc" | xargs rm -rf
find . -name ".ipynb_checkpoints" | xargs rm -rf
rm -rf .coverage cover htmlcov logs build dist *.egg-info
# make -C ./docs clean
install: ## install to site-packages
python3 setup.py install
serverextension: install ## enable serverextension
jupyter serverextension enable --py jupyterlab_iframe
labextension: install ## enable labextension
jupyter labextension install .
# docs: ## make documentation
# make -C ./docs html
# Thanks to Francoise at marmelab.com for this
.DEFAULT_GOAL := help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
print-%:
@echo '$*=$($*)'
.PHONY: clean install serverextension labextension test tests help docs

View file

@ -1,2 +1,7 @@
# jupyterlab_iframe
Iframe widget
```python3
c.JupyterLabIFrame.iframes = ['list', 'of', 'sites']
```

BIN
jupyterlab_iframe/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,4 @@
def _jupyter_server_extension_paths():
return [{
"module": "jupyterlab_iframe.extension"
}]

View file

@ -0,0 +1,24 @@
from notebook.base.handlers import IPythonHandler
class IFrameHandler(IPythonHandler):
def initialize(self, iframes=None):
self.iframes = iframes
def get(self):
self.finish(self.iframes)
def load_jupyter_server_extension(nb_server_app):
"""
Called when the extension is loaded.
Args:
nb_server_app (NotebookWebApplication): handle to the Notebook webserver instance.
"""
web_app = nb_server_app.web_app
iframes = nb_server_app.config.get('JupyterLabIFrame', {}).get('iframes', [])
host_pattern = '.*$'
print('Installing jupyterlab_iframe handler on path %s' % '/iframes')
print('Handinling iframes: %s' % iframes)
web_app.add_handlers(host_pattern, [('/iframes', IFrameHandler, {'iframes': iframes})])

39
setup.py Normal file
View file

@ -0,0 +1,39 @@
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='jupyterlab_iframe',
version='0.0.1',
description='IFrame widgets for JupyterLab',
long_description=long_description,
url='https://github.com/timkpaine/jupyterlab_iframe',
download_url='https://github.com/timkpaine/jupyterlab_iframe/archive/v0.0.1.tar.gz',
author='Tim Paine',
author_email='t.paine154@gmail.com',
license='GPL',
classifiers=[
'Development Status :: 3 - Alpha',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
keywords='jupyter jupyterlab',
packages=find_packages(exclude=['tests', ]),
zip_safe=False,
# entry_points={
# 'console_scripts': [
# 'sample=sample:main',
# ],
# },
)