##// END OF EJS Templates
restore websocket_url configurable...
MinRK -
Show More
@@ -127,6 +127,10 b' class IPythonHandler(AuthenticatedHandler):'
127 @property
127 @property
128 def base_url(self):
128 def base_url(self):
129 return self.settings.get('base_url', '/')
129 return self.settings.get('base_url', '/')
130
131 @property
132 def ws_url(self):
133 return self.settings.get('websocket_url', '')
130
134
131 #---------------------------------------------------------------
135 #---------------------------------------------------------------
132 # Manager objects
136 # Manager objects
@@ -215,6 +219,7 b' class IPythonHandler(AuthenticatedHandler):'
215 def template_namespace(self):
219 def template_namespace(self):
216 return dict(
220 return dict(
217 base_url=self.base_url,
221 base_url=self.base_url,
222 ws_url=self.ws_url,
218 logged_in=self.logged_in,
223 logged_in=self.logged_in,
219 login_available=self.login_available,
224 login_available=self.login_available,
220 static_url=self.static_url,
225 static_url=self.static_url,
@@ -172,6 +172,7 b' class NotebookWebApplication(web.Application):'
172
172
173 # IPython stuff
173 # IPython stuff
174 nbextensions_path = ipython_app.nbextensions_path,
174 nbextensions_path = ipython_app.nbextensions_path,
175 websocket_url=ipython_app.websocket_url,
175 mathjax_url=ipython_app.mathjax_url,
176 mathjax_url=ipython_app.mathjax_url,
176 config=ipython_app.config,
177 config=ipython_app.config,
177 jinja2_env=env,
178 jinja2_env=env,
@@ -512,6 +513,13 b' class NotebookApp(BaseIPythonApplication):'
512 def _nbextensions_path_default(self):
513 def _nbextensions_path_default(self):
513 return [os.path.join(get_ipython_dir(), 'nbextensions')]
514 return [os.path.join(get_ipython_dir(), 'nbextensions')]
514
515
516 websocket_url = Unicode("", config=True,
517 help="""The base URL for websockets,
518 if it differs from the HTTP server (hint: it almost certainly doesn't).
519
520 Should be in the form of an HTTP origin: ws[s]://hostname[:port]
521 """
522 )
515 mathjax_url = Unicode("", config=True,
523 mathjax_url = Unicode("", config=True,
516 help="""The url for MathJax.js."""
524 help="""The url for MathJax.js."""
517 )
525 )
@@ -43,6 +43,7 b' require(['
43
43
44 var common_options = {
44 var common_options = {
45 base_url : utils.get_body_data("baseUrl"),
45 base_url : utils.get_body_data("baseUrl"),
46 ws_url : IPython.utils.get_body_data("wsUrl"),
46 notebook_path : utils.get_body_data("notebookPath"),
47 notebook_path : utils.get_body_data("notebookPath"),
47 notebook_name : utils.get_body_data('notebookName')
48 notebook_name : utils.get_body_data('notebookName')
48 };
49 };
@@ -23,6 +23,11 b' define(['
23 this.stdin_channel = null;
23 this.stdin_channel = null;
24 this.kernel_service_url = kernel_service_url;
24 this.kernel_service_url = kernel_service_url;
25 this.name = name;
25 this.name = name;
26 this.ws_url = IPython.utils.get_body_data("wsUrl");
27 if (!this.ws_url) {
28 // trailing 's' in https will become wss for secure web sockets
29 this.ws_url = location.protocol.replace('http', 'ws') + "//" + location.host;
30 }
26 this.running = false;
31 this.running = false;
27 this.username = "username";
32 this.username = "username";
28 this.session_id = utils.uuid();
33 this.session_id = utils.uuid();
@@ -122,8 +127,6 b' define(['
122 console.log("Kernel started: ", json.id);
127 console.log("Kernel started: ", json.id);
123 this.running = true;
128 this.running = true;
124 this.kernel_id = json.id;
129 this.kernel_id = json.id;
125 // trailing 's' in https will become wss for secure web sockets
126 this.ws_host = location.protocol.replace('http', 'ws') + "//" + location.host;
127 this.kernel_url = utils.url_path_join(this.kernel_service_url, this.kernel_id);
130 this.kernel_url = utils.url_path_join(this.kernel_service_url, this.kernel_id);
128 this.start_channels();
131 this.start_channels();
129 };
132 };
@@ -145,16 +148,16 b' define(['
145 Kernel.prototype.start_channels = function () {
148 Kernel.prototype.start_channels = function () {
146 var that = this;
149 var that = this;
147 this.stop_channels();
150 this.stop_channels();
148 var ws_host_url = this.ws_host + this.kernel_url;
151 var ws_host_url = this.ws_url + this.kernel_url;
149 console.log("Starting WebSockets:", ws_host_url);
152 console.log("Starting WebSockets:", ws_host_url);
150 this.shell_channel = new this.WebSocket(
153 this.shell_channel = new this.WebSocket(
151 this.ws_host + utils.url_join_encode(this.kernel_url, "shell")
154 this.ws_url + utils.url_join_encode(this.kernel_url, "shell")
152 );
155 );
153 this.stdin_channel = new this.WebSocket(
156 this.stdin_channel = new this.WebSocket(
154 this.ws_host + utils.url_join_encode(this.kernel_url, "stdin")
157 this.ws_url + utils.url_join_encode(this.kernel_url, "stdin")
155 );
158 );
156 this.iopub_channel = new this.WebSocket(
159 this.iopub_channel = new this.WebSocket(
157 this.ws_host + utils.url_join_encode(this.kernel_url, "iopub")
160 this.ws_url + utils.url_join_encode(this.kernel_url, "iopub")
158 );
161 );
159
162
160 var already_called_onclose = false; // only alert once
163 var already_called_onclose = false; // only alert once
@@ -24,6 +24,7 b' window.mathjax_url = "{{mathjax_url}}";'
24
24
25 data-project="{{project}}"
25 data-project="{{project}}"
26 data-base-url="{{base_url}}"
26 data-base-url="{{base_url}}"
27 data-ws-url="{{ws_url}}"
27 data-notebook-name="{{notebook_name}}"
28 data-notebook-name="{{notebook_name}}"
28 data-notebook-path="{{notebook_path}}"
29 data-notebook-path="{{notebook_path}}"
29 class="notebook_app"
30 class="notebook_app"
General Comments 0
You need to be logged in to leave comments. Login now