Skip to content

Commit 9b73ec7

Browse files
authored
Merge pull request #153 from jcoady/master
Update jupyterlab vpython to work on JupyterHub and MyBinder
2 parents 7b868d6 + b2232bc commit 9b73ec7

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

labextension/vpython/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vpython",
3-
"version": "3.0.3",
3+
"version": "3.0.7",
44
"description": "VPython extension for JupyterLab",
55
"keywords": [
66
"jupyter",

labextension/vpython/src/glowcommlab.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'script-loader!../vpython_libraries/glow.min.js';
44
import 'script-loader!../vpython_libraries/plotly.min.js';
55
import '../style/jquery-ui.custom.css'
66
import '../style/ide.css'
7+
import img from '../vpython_data/flower_texture.jpg' // use this to get the path to vpython_data
78

89
// Ensure downstream JupyterLab webpack places the fonts and images in predictable locations
910
import '!!file-loader?name=/vpython_data/[name].[ext]!../vpython_data/earth_texture.jpg'
@@ -41,12 +42,7 @@ export function createWebsocket(msg, serviceUrl) {
4142
var uri = msg.content.data.wsuri
4243
var url;
4344

44-
if (document.location.hostname.includes("localhost")){
45-
url = "ws://localhost:" + port + uri;
46-
}
47-
else {
48-
url = serviceUrl + port + uri;
49-
}
45+
url = serviceUrl + port + uri;
5046
ws = new WebSocket(url);
5147
ws.binaryType = "arraybuffer";
5248

@@ -84,13 +80,11 @@ export function setupWebsocket(msg,serviceUrl) {
8480
wscheckfontsloaded(msg,serviceUrl)
8581
}
8682

87-
// Old datadir value for a source extension npm package. (used prior to JupyterLab 3.0)
88-
//var datadir = '/static/lab/vpython_data/'
89-
//window.Jupyter_VPython = "/static/lab/vpython_data/" // prefix used by glow.min.js for textures
90-
9183
// New datadir value for a prebuilt extension (new in JupyterLab 3.0)
92-
var datadir = '/lab/extensions/vpython/static/vpython_data/'
93-
window.Jupyter_VPython = "/lab/extensions/vpython/static/vpython_data/" // prefix used by glow.min.js for textures
84+
var url = new URL(img);
85+
var datadir = url.pathname.substring(0, url.pathname.lastIndexOf('/')) + "/vpython_data/"; // path to vpython_data dir
86+
window.Jupyter_VPython = datadir // prefix used by glow.min.js for textures
87+
url = null
9488

9589
function fontloading() {
9690
"use strict";

0 commit comments

Comments
 (0)