From a98cfed551c8f13dbad2e886ea63908a3ab3d63d Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Mon, 12 Aug 2019 09:10:54 -0700 Subject: [PATCH 1/2] adding jupyterlab file paths for preview --- binderhub/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/binderhub/main.py b/binderhub/main.py index f12fe9d26..4a01c27ec 100644 --- a/binderhub/main.py +++ b/binderhub/main.py @@ -61,6 +61,12 @@ def get(self, provider_prefix, _unescaped_spec): org, repo_name, ref = spec.split('/', 2) # NOTE: tornado unquotes query arguments too -> notebooks%2Findex.ipynb becomes notebooks/index.ipynb filepath = self.get_argument('filepath', '').lstrip('/') + + # Check if we have a JupyterLab + file path, if so then use it for the filepath + urlpath = self.get_argument('urlpath', '').lstrip('/') + if 'lab/tree/' in urlpath: + filepath = urlpath.split('lab/tree/')[-1] + blob_or_tree = 'blob' if filepath else 'tree' nbviewer_url = f'{nbviewer_url}/{org}/{repo_name}/{blob_or_tree}/{ref}/{filepath}' self.render_template( From 17149a0a8020ae6bc7111fa142fa84a5991e4bf0 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Mon, 12 Aug 2019 17:30:35 -0700 Subject: [PATCH 2/2] making the nbviewer url properly handle lab workspaces --- binderhub/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/binderhub/main.py b/binderhub/main.py index 4a01c27ec..33331086a 100644 --- a/binderhub/main.py +++ b/binderhub/main.py @@ -64,8 +64,8 @@ def get(self, provider_prefix, _unescaped_spec): # Check if we have a JupyterLab + file path, if so then use it for the filepath urlpath = self.get_argument('urlpath', '').lstrip('/') - if 'lab/tree/' in urlpath: - filepath = urlpath.split('lab/tree/')[-1] + if urlpath.startswith("lab") and "/tree/" in urlpath: + filepath = urlpath.split('tree/', 1)[-1] blob_or_tree = 'blob' if filepath else 'tree' nbviewer_url = f'{nbviewer_url}/{org}/{repo_name}/{blob_or_tree}/{ref}/{filepath}'