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

[WIP] Voila as an ExtensionApp #270

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
- osx
env:
matrix:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.7
before_install:
Expand All @@ -18,8 +18,10 @@ before_install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda create -q -n test-environment -c conda-forge python=$PYTHON_VERSION jupyter_server==0.1.0 jupyterlab_pygments==0.1.0 pytest==3.10.1 nbconvert=5.6 pytest-cov nodejs flake8 ipywidgets matplotlib xeus-cling
- conda create -q -n test-environment -c conda-forge python=$PYTHON_VERSION nodejs flake8 xeus-cling
- source activate test-environment
- pip uninstall jupyter_server -y
- pip install git+https://github.com/jupyter/jupyter_server@master
install:
- pip install ".[test]"
- cd tests/test_template; pip install .; cd ../../;
Expand Down
2 changes: 1 addition & 1 deletion etc/jupyter/jupyter_server_config.d/voila.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"voila.server_extension": true
"voila": true
}
}
}
41 changes: 11 additions & 30 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,12 @@ def get_data_files():
},
'entry_points': {
'console_scripts': [
'jupyter-voila = voila.app:main',
'voila = voila.app:main'
]
},
'install_requires': [
'jupyter_server>=0.1.0,<0.2.0',
'jupyter_server>=0.2.0.dev0,<0.3.0',
'nbconvert>=5.6.0,<6',
'jupyterlab_pygments>=0.1.0,<0.2',
'pygments>=2.4.1,<3' # Explicitly requiring pygments which is a second-order dependency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

{%- block html_head_js -%}
<script
src="{{resources.base_url}}voila/static/require.min.js"
src="{{resources.base_url}}static/voila/require.min.js"
integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA="
crossorigin="anonymous">
</script>

{% block notebook_execute %}
{%- set kernel_id = kernel_start() -%}
<script id="jupyter-config-data" type="application/json">
Expand Down Expand Up @@ -50,12 +49,15 @@
{% block footer %}
{% block footer_js %}
<script>
requirejs.config({ baseUrl: '{{resources.base_url}}voila/', waitSeconds: 30})
requirejs.config({
baseUrl: '{{resources.base_url}}static/voila/',
waitSeconds: 30
})
requirejs(
[
"static/main",
"main",
{% for ext in resources.nbextensions -%}
"{{resources.base_url}}voila/nbextensions/{{ ext }}.js",
"{{resources.base_url}}static/voila/nbextensions/{{ ext }}.js",
{% endfor %}
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
{%- block html_head_css -%}
{{ super() }}

<link rel="stylesheet" type="text/css" href="{{resources.base_url}}voila/static/index.css">
<link rel="stylesheet" type="text/css" href="{{resources.base_url}}static/voila/index.css"></link>

{% if resources.theme == 'dark' %}
<link rel="stylesheet" type="text/css" href="{{resources.base_url}}voila/static/theme-dark.css">
<link rel="stylesheet" type="text/css" href="{{resources.base_url}}static/voila/theme-dark.css"></link>
{% else %}
<link rel="stylesheet" type="text/css" href="{{resources.base_url}}voila/static/theme-light.css">
<link rel="stylesheet" type="text/css" href="{{resources.base_url}}static/voila/theme-light.css"></link>
{% endif %}

{% for css in resources.inlining.css %}
Expand Down
2 changes: 1 addition & 1 deletion share/jupyter/voila/templates/default/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
****************************************************************************/

// NOTE: this file is not transpiled, async/await is the only modern feature we use here
require(['static/voila'], function(voila) {
require(['voila'], function(voila) {
// requirejs doesn't like to be passed an async function, so create one inside
(async function() {
var kernel = await voila.connectKernel()
Expand Down
21 changes: 6 additions & 15 deletions tests/app/config_paths_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# test all objects that should be configurable
import pytest

import os


Expand All @@ -9,26 +8,18 @@

@pytest.fixture
def voila_config_file_paths_arg():
path = os.path.join(BASE_DIR, '..', 'configs', 'general')
return '--VoilaTest.config_file_paths=[%r]' % path
config_path = os.path.join(BASE_DIR, '..', 'configs', 'general')
return '--Voila.config_file_paths=[%r]' % config_path


def test_config_app(voila_app):
assert voila_app.voila_configuration.template == 'test_template'
assert voila_app.voila_configuration.enable_nbextensions is True


def test_config_kernel_manager(voila_app):
assert voila_app.kernel_manager.cull_interval == 10


def test_config_contents_manager(voila_app):
assert voila_app.contents_manager.use_atomic_writing is False
assert voila_app.template == 'test_template'
assert voila_app.enable_nbextensions is True


@pytest.mark.gen_test
def test_template(http_client, base_url):
response = yield http_client.fetch(base_url)
def test_template(http_client, default_url):
response = yield http_client.fetch(default_url)
assert response.code == 200
assert 'test_template.css' in response.body.decode('utf-8')
assert 'Hi Voila' in response.body.decode('utf-8')
Loading