Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Open a notebook via the command line (#98)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jtpio authored Feb 28, 2021
1 parent 027f8f5 commit 78b572a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
20 changes: 18 additions & 2 deletions jupyterlab_classic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -105,17 +105,26 @@ 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")
schemas_dir = pjoin(app_dir, "schemas")
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))
Expand All @@ -129,6 +138,13 @@ def initialize_templates(self):
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

Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@
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,
Expand Down

0 comments on commit 78b572a

Please sign in to comment.