diff --git a/run.py b/run.py index 435ff90..644ffa1 100644 --- a/run.py +++ b/run.py @@ -389,13 +389,13 @@ async def job(request, job_id): if job.count == 0: raise NotFound() - return {"job": job[0], 'relative_path_to_root': '../../'} + return {"job": job[0], 'relative_path_to_root': '../../', 'path': request.path} @app.route('/') @jinja.template('index.html') async def index(request): - return {'relative_path_to_root': ''} + return {'relative_path_to_root': '', 'path': request.path} def main(path_to_analyseCI, ssl=False, keyfile_path="/etc/yunohost/certs/ci-apps.yunohost.org/key.pem", certfile_path="/etc/yunohost/certs/ci-apps.yunohost.org/crt.pem"): diff --git a/static/js/app.js b/static/js/app.js index 00956b1..bc2366b 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -6,6 +6,10 @@ function websocketPrefix() { } } +function websocketRelativePath(path) { + return window.location.pathname.substring(0, window.location.pathname.length - path.length) +} + /* ansi_up.js * author : Dru Nelson * license : MIT diff --git a/templates/index.html b/templates/index.html index 4dc00d7..c1993dc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -45,7 +45,7 @@ } }) - ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + '/index-ws'); + ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + websocketRelativePath('<{ path }>') + '/index-ws'); ws.onmessage = function (event) { var message = JSON.parse(event.data); diff --git a/templates/job.html b/templates/job.html index 419eaa8..0faa4db 100644 --- a/templates/job.html +++ b/templates/job.html @@ -50,7 +50,7 @@ } }) - ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + '/job-<{ job.id }>-ws'); + ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + websocketRelativePath('<{ path }>') + '/job-<{ job.id }>-ws'); ws.onmessage = function (event) { var message = JSON.parse(event.data);