Merge pull request #972 from blink1073/add-lab-page

Add Lab Page
Min RK 10 years ago
commit d6b4ef071b

2
.gitignore vendored

@ -11,6 +11,8 @@ notebook/static/style/*.min.css*
notebook/static/*/js/built/
notebook/static/*/built/
notebook/static/built/
notebook/static/*/js/main.min.js*
notebook/static/lab/*bundle.js
node_modules
*.py[co]
__pycache__

@ -0,0 +1,28 @@
"""Tornado handlers for the tree view."""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tornado import web
from ..base.handlers import IPythonHandler
class LabHandler(IPythonHandler):
"""Render the Jupyter Lab View."""
@web.authenticated
def get(self):
self.write(self.render_template('lab.html',
page_title='Jupyter Lab',
terminals_available=self.settings['terminals_available']))
#-----------------------------------------------------------------------------
# URL to handler mappings
#-----------------------------------------------------------------------------
default_handlers = [
(r"/lab", LabHandler),
]

@ -270,6 +270,7 @@ class NotebookWebApplication(web.Application):
handlers.extend(load_handlers('services.nbconvert.handlers'))
handlers.extend(load_handlers('services.kernelspecs.handlers'))
handlers.extend(load_handlers('services.security.handlers'))
handlers.extend(load_handlers('lab.handlers'))
# BEGIN HARDCODED WIDGETS HACK
widgets = None
@ -1228,4 +1229,3 @@ def list_running_servers(runtime_dir=None):
#-----------------------------------------------------------------------------
main = launch_new_instance = NotebookApp.launch_instance

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@ -0,0 +1,28 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
'use strict';
require('jupyter-js-plugins/lib/default-theme/index.css');
var phosphide = require('phosphide/lib/core/application');
var app = new phosphide.Application({
extensions: [
require('phosphide/lib/extensions/commandpalette').commandPaletteExtension,
require('jupyter-js-plugins/lib/terminal/plugin').terminalExtension,
require('jupyter-js-plugins/lib/filehandler/plugin').fileHandlerExtension,
require('jupyter-js-plugins/lib/filebrowser/plugin').fileBrowserExtension,
require('jupyter-js-plugins/lib/imagehandler/plugin').imageHandlerExtension,
require('jupyter-js-plugins/lib/help/plugin').helpHandlerExtension,
require('jupyter-js-plugins/lib/readonly-notebook/plugin').notebookHandlerExtension,
require('jupyter-js-plugins/lib/shortcuts/plugin').shortcutsExtension
],
providers: [
require('jupyter-js-plugins/lib/documentmanager/plugin').documentManagerProvider,
require('jupyter-js-plugins/lib/services/plugin').servicesProvider
]
});
window.onload = function() {
app.run();
}

@ -0,0 +1,31 @@
{
"private": true,
"name": "jupyter-js-lab",
"version": "0.1.0",
"description": "JupyterLab",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"dependencies": {
"jupyter-js-plugins": "^0.9.0",
"phosphide": "^0.9.0"
},
"devDependencies": {
"css-loader": "^0.23.1",
"es6-promise": "^3.0.2",
"file-loader": "^0.8.5",
"json-loader": "^0.5.4",
"rimraf": "^2.5.0",
"style-loader": "^0.13.0",
"typescript": "^1.7.5",
"url-loader": "^0.5.7",
"webpack": "^1.12.11"
},
"scripts": {
"clean": "rimraf build",
"build": "webpack --config webpack.conf.js",
"postinstall": "npm dedupe",
"test": "echo 'no tests specified'"
},
"author": "Project Jupyter",
"license": "BSD-3-Clause"
}

@ -0,0 +1,43 @@
// Support for Node 0.10
// See https://github.com/webpack/css-loader/issues/144
require('es6-promise').polyfill();
var ContextReplacementPlugin = require("webpack/lib/ContextReplacementPlugin");
module.exports = {
entry: './index.js',
output: {
path: './build',
filename: 'bundle.js'
},
node: {
fs: "empty"
},
debug: true,
bail: true,
module: {
loaders: [
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.json$/, loader: 'json-loader' },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, loader: "file" },
// required to load font-awesome
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/font-woff" },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=application/octet-stream" },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&minetype=image/svg+xml" }
]
},
externals: {
"base/js/namespace": "base/js/namespace",
"notebook/js/outputarea": "notebook/js/outputarea",
"services/kernels/comm": "services/kernels/comm"
},
plugins: [
new ContextReplacementPlugin(
/codemirror\/mode.*$/,
/codemirror\/mode.*\.js$/
)
]
}

@ -0,0 +1,99 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>{{page_title}}</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" type="text/css" href="{{static_url("components/font-awesome/css/font-awesome.css")}}"></link>
<script src="{{static_url("components/es6-promise/promise.min.js")}}" type="text/javascript" charset="utf-8"></script>
<script src="{{static_url("components/requirejs/require.js") }}" type="text/javascript" charset="utf-8"></script>
<script>
require.config({
{% if version_hash %}
urlArgs: "v={{version_hash}}",
{% endif %}
baseUrl: '{{static_url("", include_version=False)}}',
paths: {
{% if ignore_minified_js %}
'auth/js/main': 'auth/js/main',
{% else %}
'auth/js/main': 'auth/js/main.min',
{% endif %}
custom : '{{ base_url }}custom',
nbextensions : '{{ base_url }}nbextensions',
widgets : '{{ base_url }}deprecatedwidgets',
kernelspecs : '{{ base_url }}kernelspecs',
underscore : 'components/underscore/underscore-min',
backbone : 'components/backbone/backbone-min',
jquery: 'components/jquery/jquery.min',
bootstrap: 'components/bootstrap/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
'jquery-ui': 'components/jquery-ui/ui/minified/jquery-ui.min',
moment: 'components/moment/moment',
codemirror: 'components/codemirror',
termjs: 'components/term.js/src/term',
typeahead: 'components/jquery-typeahead/dist/jquery.typeahead'
},
map: { // for backward compatibility
"*": {
"jqueryui": "jquery-ui",
}
},
shim: {
typeahead: {
deps: ["jquery"],
exports: "typeahead"
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
bootstrap: {
deps: ["jquery"],
exports: "bootstrap"
},
bootstraptour: {
deps: ["bootstrap"],
exports: "Tour"
},
"jquery-ui": {
deps: ["jquery"],
exports: "$"
}
},
waitSeconds: 30,
});
require.config({
map: {
'*':{
'contents': '{{ contents_js_source }}',
}
}
});
</script>
{% block meta %}
{% endblock %}
</head>
<body class="{% block bodyclasses %}{% endblock %}" {% block params %}{% endblock %}>
{% block script %}
<script id='jupyter-config-data' type="application/json">{
"baseUrl": "{{base_url | urlencode}}",
"wsUrl": "{{ws_url| urlencode}}",
"notebookPath": "{{notebook_path | urlencode}}"
}</script>
<script src="{{ static_url("lab/build/bundle.js") }}" type="text/javascript" charset="utf-8"></script>
{% endblock %}
</body>
</html>

@ -15,6 +15,7 @@ data-terminals-available="{{terminals_available}}"
{% block site %}
<div id="ipython-main-app" class="container">
<div id="lab_link" class="pull-right" style="padding: 4px"><a href="{{ base_url }}lab" title='Try JupyterLab'><img src='{{static_url("base/images/jupyter_lab.png") }}' alt='Try JupyterLab' height="40px" width="200px"/></a></div>
<div id="tab_content" class="tabbable">
<ul id="tabs" class="nav nav-tabs">
<li class="active"><a href="#notebooks" data-toggle="tab">Files</a></li>
@ -173,7 +174,7 @@ data-terminals-available="{{terminals_available}}"
See <a href="https://github.com/ipython/ipyparallel">IPython parallel</a> for installation details.
</div>
</div><!-- class:tab-content -->
</div><!-- id:tab_content -->
</div><!-- id:tab_content -->
</div><!-- ipython-main-app -->
{% endblock %}

@ -101,6 +101,7 @@ def find_package_data():
excludes = [
pjoin('static', 'components'),
pjoin('static', '*', 'less'),
pjoin('static', '*', 'node_modules')
]
# walk notebook resources:
@ -129,6 +130,9 @@ def find_package_data():
pjoin('static', 'services', 'built', '*contents.js.map'),
])
# Add the Lab page contents
static_data.append(pjoin('static', 'lab', 'build', '*'))
components = pjoin("static", "components")
# select the components we actually need to install
# (there are lots of resources we bundle for sdist-reasons that we don't actually use)
@ -337,6 +341,7 @@ class JavascriptDependencies(Command):
bower_dir = pjoin(static, 'components')
node_modules = pjoin(repo_root, 'node_modules')
lab_dir = pjoin(repo_root, 'notebook', 'static', 'lab')
def run(self):
try:
@ -353,6 +358,14 @@ class JavascriptDependencies(Command):
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
try:
run(['npm', 'install', '--progress=false'], cwd=self.lab_dir)
run(['npm', 'run', 'build'], cwd=self.lab_dir)
except Exception as e:
print("Failed to run `npm install`: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
# update package data in case this created new files
update_package_data(self.distribution)
@ -497,6 +510,7 @@ def css_js_prerelease(command, strict=False):
jsdeps = self.distribution.get_command_obj('jsdeps')
js = self.distribution.get_command_obj('js')
css = self.distribution.get_command_obj('css')
js.force = strict
targets = [ jsdeps.bower_dir ]

Loading…
Cancel
Save