Add a tree page with the filebrowser

pull/6294/head
Jeremy Tuloup 5 years ago
parent cdc11d709b
commit 95b39d037e

@ -67,7 +67,7 @@ async function main() {
const app = new App();
// TODO: formalize the way the set of initial extensions and plugins are specified
const mods = [
let mods = [
require('@jupyterlab-classic/application-extension'),
require('@jupyterlab/apputils-extension').default.filter(({ id }) =>
[
@ -80,36 +80,52 @@ async function main() {
require('@jupyterlab/codemirror-extension').default.filter(({ id }) =>
['@jupyterlab/codemirror-extension:services'].includes(id)
),
require('@jupyterlab/completer-extension').default.filter(({ id }) =>
[
'@jupyterlab/completer-extension:manager',
'@jupyterlab/completer-extension:notebooks'
].includes(id)
),
require('@jupyterlab/docmanager-extension').default.filter(({ id }) =>
['@jupyterlab/docmanager-extension:plugin'].includes(id)
),
require('@jupyterlab/mainmenu-extension'),
require('@jupyterlab/mathjax2-extension'),
require('@jupyterlab/rendermime-extension'),
require('@jupyterlab/notebook-extension').default.filter(({ id }) =>
[
'@jupyterlab/notebook-extension:factory',
'@jupyterlab/notebook-extension:widget-factory',
'@jupyterlab/notebook-extension:tracker'
'@jupyterlab/notebook-extension:tracker',
'@jupyterlab/notebook-extension:widget-factory'
].includes(id)
),
require('@jupyterlab/rendermime-extension'),
require('@jupyterlab/shortcuts-extension'),
require('@jupyterlab/tooltip-extension').default.filter(({ id }) =>
[
'@jupyterlab/tooltip-extension:manager',
'@jupyterlab/tooltip-extension:notebooks'
].includes(id)
),
require('@jupyterlab/theme-light-extension'),
require('@jupyterlab/theme-dark-extension')
];
const page = PageConfig.getOption('classicPage');
if (page === 'tree') {
mods = mods.concat([
require('@jupyterlab-classic/filebrowser-extension').default.filter(
({ id }) =>
[
'@jupyterlab-classic/filebrowser-extension:browser',
'@jupyterlab-classic/filebrowser-extension:factory'
].includes(id)
)
]);
} else if (page === 'notebooks') {
mods = mods.concat([
require('@jupyterlab/completer-extension').default.filter(({ id }) =>
[
'@jupyterlab/completer-extension:manager',
'@jupyterlab/completer-extension:notebooks'
].includes(id)
),
require('@jupyterlab/tooltip-extension').default.filter(({ id }) =>
[
'@jupyterlab/tooltip-extension:manager',
'@jupyterlab/tooltip-extension:notebooks'
].includes(id)
)
]);
}
const extension_data = JSON.parse(
PageConfig.getOption('federated_extensions')
);

@ -12,6 +12,7 @@
"dependencies": {
"@jupyterlab-classic/application": "^0.1.0",
"@jupyterlab-classic/application-extension": "^0.1.0",
"@jupyterlab-classic/filebrowser-extension": "^0.1.0",
"@jupyterlab-classic/ui-components": "^0.1.0",
"@jupyterlab/apputils-extension": "^3.0.0-rc.12",
"@jupyterlab/codemirror-extension": "^3.0.0-rc.12",

@ -1,4 +1,5 @@
@import url('~@jupyterlab-classic/application-extension/style/index.css');
@import url('~@jupyterlab-classic/filebrowser-extension/style/index.css');
@import url('~@jupyterlab-classic/ui-components/style/index.css');
/* TODO: check is the the extension package can be used directly */

@ -24,9 +24,8 @@ app_dir = get_app_dir()
version = __version__
class ClassicHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
@web.authenticated
def get(self, path=None):
class ClassicPageConfigMixin:
def get_page_config(self):
config = LabConfig()
app = self.extensionapp
base_url = self.settings.get("base_url")
@ -71,7 +70,27 @@ class ClassicHandler(ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterH
logger=self.log,
),
)
return page_config
class ClassicTreeHandler(ClassicPageConfigMixin, ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
@web.authenticated
def get(self, path=None):
page_config = self.get_page_config()
return self.write(
self.render_template(
"tree.html",
base_url=self.base_url,
token=self.settings["token"],
page_config=page_config,
)
)
class ClassicNotebookHandler(ClassicPageConfigMixin, ExtensionHandlerJinjaMixin, ExtensionHandlerMixin, JupyterHandler):
@web.authenticated
def get(self, path=None):
page_config = self.get_page_config()
return self.write(
self.render_template(
"notebooks.html",
@ -97,7 +116,8 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp):
def initialize_handlers(self):
super().initialize_handlers()
self.handlers.append(("/classic/notebooks(.*)", ClassicHandler))
self.handlers.append(("/classic/tree(.*)", ClassicTreeHandler))
self.handlers.append(("/classic/notebooks(.*)", ClassicNotebookHandler))
def initialize_templates(self):
super().initialize_templates()

@ -13,6 +13,9 @@
{# Set a dummy variable - we just want the side effect of the update. #}
{% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}
{# Sentinel value to say that we are on the tree page #}
{% set _ = page_config_full.update(classicPage='notebooks') %}
<script id="jupyter-config-data" type="application/json">
{{ page_config_full | tojson }}
</script>

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{page_config['appName'] | e}}</title>
</head>
<body>
{# Copy so we do not modify the page_config with updates. #}
{% set page_config_full = page_config.copy() %}
{# Set a dummy variable - we just want the side effect of the update. #}
{% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}
{# Sentinel value to say that we are on the tree page #}
{% set _ = page_config_full.update(classicPage='tree') %}
<script id="jupyter-config-data" type="application/json">
{{ page_config_full | tojson }}
</script>
<script src="{{page_config['fullStaticUrl'] | e}}/bundle.js" main="index"></script>
<script type="text/javascript">
/* Remove token from URL. */
(function () {
var parsedUrl = new URL(window.location.href);
if (parsedUrl.searchParams.get('token')) {
parsedUrl.searchParams.delete('token');
window.history.replaceState({ }, '', parsedUrl.href);
}
})();
</script>
</body>
</html>

@ -102,10 +102,10 @@ export class ClassicShell extends Widget implements JupyterFrontEnd.IShell {
if (area === 'menu') {
return this._menuHandler.addWidget(widget, rank);
}
if (this._main.widgets.length > 0) {
// do not add the widget if there is already one
return;
}
// TODO: better handle this
this._main.widgets.forEach(w => {
w.close();
});
this._main.addWidget(widget);
this._main.update();
this._currentChanged.emit(void 0);

@ -0,0 +1,67 @@
{
"name": "@jupyterlab-classic/filebrowser-extension",
"version": "0.1.0",
"description": "JupyterLab Classic - File browser Extension",
"homepage": "https://github.com/jtpio/jupyterlab-classic",
"bugs": {
"url": "https://github.com/jtpio/jupyterlab-classic/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jtpio/jupyterlab-classic.git"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter",
"sideEffects": [
"style/**/*.css"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"directories": {
"lib": "lib/"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js",
"schema/*.json",
"style/**/*.css"
],
"scripts": {
"build": "tsc -b",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"docs": "typedoc src",
"prepublishOnly": "npm run build",
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyterlab-classic/application": "0.1.0",
"@jupyterlab/application": "^3.0.0-rc.13",
"@jupyterlab/apputils": "^3.0.0-rc.13",
"@jupyterlab/coreutils": "^5.0.0-rc.13",
"@jupyterlab/docmanager": "^3.0.0-rc.13",
"@jupyterlab/filebrowser": "^3.0.0-rc.13",
"@jupyterlab/launcher": "^3.0.0-rc.13",
"@jupyterlab/mainmenu": "^3.0.0-rc.13",
"@jupyterlab/services": "^6.0.0-rc.13",
"@jupyterlab/settingregistry": "^3.0.0-rc.13",
"@jupyterlab/statedb": "^3.0.0-rc.13",
"@jupyterlab/translation": "^3.0.0-rc.13",
"@jupyterlab/ui-components": "^3.0.0-rc.13",
"@lumino/algorithm": "^1.3.3",
"@lumino/commands": "^1.12.0",
"@lumino/messaging": "^1.4.3",
"@lumino/widgets": "^1.16.1"
},
"devDependencies": {
"rimraf": "~3.0.0",
"typescript": "~4.0.2"
},
"publishConfig": {
"access": "public"
},
"jupyterlab": {
"extension": true
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
.jp-FileBrowser {
height: 100%;
}

@ -0,0 +1,3 @@
@import url('~@jupyterlab/filebrowser/style/index.css');
@import url('./base.css');

@ -0,0 +1,13 @@
{
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"],
"references": [
{
"path": "../application"
}
]
}

@ -1806,6 +1806,22 @@
"@lumino/widgets" "^1.16.1"
react "^17.0.1"
"@jupyterlab/launcher@^3.0.0-rc.13":
version "3.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@jupyterlab/launcher/-/launcher-3.0.0-rc.13.tgz#f128c1bbb0d23b44ed38a9ff08c4f7f6e8b4b2fd"
integrity sha512-Rh0tELQhHcxEUtsDPaNLA2GLOBFW9U5kXqrGXs8imLyDoxxfgwjugcfab79IltDWX6c6brTHFu6Uei9zaDwdmQ==
dependencies:
"@jupyterlab/apputils" "^3.0.0-rc.13"
"@jupyterlab/translation" "^3.0.0-rc.13"
"@jupyterlab/ui-components" "^3.0.0-rc.13"
"@lumino/algorithm" "^1.3.3"
"@lumino/commands" "^1.12.0"
"@lumino/coreutils" "^1.5.3"
"@lumino/disposable" "^1.4.3"
"@lumino/properties" "^1.2.3"
"@lumino/widgets" "^1.16.1"
react "^17.0.1"
"@jupyterlab/logconsole@^3.0.0-rc.12":
version "3.0.0-rc.12"
resolved "https://registry.yarnpkg.com/@jupyterlab/logconsole/-/logconsole-3.0.0-rc.12.tgz#cb3b9e48577542bdeeb4221c17218b59909ce5cd"
@ -1852,6 +1868,20 @@
"@lumino/disposable" "^1.4.3"
"@lumino/widgets" "^1.16.1"
"@jupyterlab/mainmenu@^3.0.0-rc.13":
version "3.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@jupyterlab/mainmenu/-/mainmenu-3.0.0-rc.13.tgz#2a56ebff92d052e79947753fdc5c1c6fe32ed816"
integrity sha512-lgNL6XZdmgFIifiePB6T62N3qiiDSaWNy3S60/smJnvys89oV5b5M3VIxFgR/JgV8Dg1lelFoyrE2zur3GJn/g==
dependencies:
"@jupyterlab/apputils" "^3.0.0-rc.13"
"@jupyterlab/services" "^6.0.0-rc.13"
"@jupyterlab/ui-components" "^3.0.0-rc.13"
"@lumino/algorithm" "^1.3.3"
"@lumino/commands" "^1.12.0"
"@lumino/coreutils" "^1.5.3"
"@lumino/disposable" "^1.4.3"
"@lumino/widgets" "^1.16.1"
"@jupyterlab/mathjax2-extension@^3.0.0-rc.12":
version "3.0.0-rc.13"
resolved "https://registry.yarnpkg.com/@jupyterlab/mathjax2-extension/-/mathjax2-extension-3.0.0-rc.13.tgz#acdf4cea112e7d4b7ade3f56b3f4385e72d0bf9f"

Loading…
Cancel
Save