[mod] try to make websockets relative

This commit is contained in:
Laurent Peuch 2018-08-27 01:09:25 +02:00
parent 67c837c496
commit f7ea9da20c
4 changed files with 8 additions and 4 deletions

4
run.py
View file

@ -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"):

View file

@ -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

View file

@ -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);

View file

@ -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);