mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
Open a notebook via the command line (#98)
* Open a notebook via the command line * Assign default_url to self.serverapp * Update to latest jupyter server to open via the cli * Add redirect handler to open non notebook files
This commit is contained in:
parent
027f8f515f
commit
78b572a136
@ -6,7 +6,7 @@ from jupyter_server.extension.handler import (
|
||||
ExtensionHandlerMixin,
|
||||
ExtensionHandlerJinjaMixin,
|
||||
)
|
||||
from jupyter_server.utils import url_path_join as ujoin, url_escape
|
||||
from jupyter_server.utils import url_path_join as ujoin
|
||||
from jupyterlab.commands import get_app_dir, get_user_settings_dir, get_workspaces_dir
|
||||
from jupyterlab_server import LabServerApp
|
||||
from jupyterlab_server.config import get_page_config, recursive_update, LabConfig
|
||||
@ -105,8 +105,9 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp):
|
||||
app_name = "JupyterLab Classic"
|
||||
description = "JupyterLab Classic - A JupyterLab Distribution with the Classic Notebook look and feel"
|
||||
app_version = version
|
||||
extension_url = "/classic/tree"
|
||||
extension_url = "/classic"
|
||||
default_url = "/classic/tree"
|
||||
file_url_prefix = "/classic/notebooks"
|
||||
load_other_extensions = True
|
||||
app_dir = app_dir
|
||||
app_settings_dir = pjoin(app_dir, "settings")
|
||||
@ -114,8 +115,16 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp):
|
||||
themes_dir = pjoin(app_dir, "themes")
|
||||
user_settings_dir = get_user_settings_dir()
|
||||
workspaces_dir = get_workspaces_dir()
|
||||
subcommands = {}
|
||||
|
||||
def initialize_handlers(self):
|
||||
self.handlers.append(
|
||||
(
|
||||
rf"/{self.file_url_prefix}/((?!.*\.ipynb($|\?)).*)",
|
||||
web.RedirectHandler,
|
||||
{"url": "/classic/edit/{0}"}
|
||||
)
|
||||
)
|
||||
self.handlers.append(("/classic/tree(.*)", ClassicTreeHandler))
|
||||
self.handlers.append(("/classic/notebooks(.*)", ClassicNotebookHandler))
|
||||
self.handlers.append(("/classic/edit(.*)", ClassicFileHandler))
|
||||
@ -129,6 +138,13 @@ class ClassicApp(NBClassicConfigShimMixin, LabServerApp):
|
||||
self.static_paths = [self.static_dir]
|
||||
self.template_paths = [self.templates_dir]
|
||||
|
||||
def initialize_settings(self):
|
||||
super().initialize_settings()
|
||||
|
||||
def initialize(self, argv=None):
|
||||
"""Subclass because the ExtensionApp.initialize() method does not take arguments"""
|
||||
super().initialize()
|
||||
|
||||
|
||||
main = launch_new_instance = ClassicApp.launch_instance
|
||||
|
||||
|
6
setup.py
6
setup.py
@ -84,7 +84,11 @@ setup_args = dict(
|
||||
cmdclass=cmdclass,
|
||||
packages=setuptools.find_packages(),
|
||||
install_requires=[
|
||||
"jupyterlab~=3.0",
|
||||
"jupyterlab>=3.0.9,<4",
|
||||
"jupyterlab_server~=2.3",
|
||||
"jupyter_server~=1.4",
|
||||
"nbclassic~=0.2",
|
||||
"tornado>=6.1.0",
|
||||
],
|
||||
zip_safe=False,
|
||||
include_package_data=True,
|
||||
|
Loading…
Reference in New Issue
Block a user