Add uri_root_path option. References #104.

This commit is contained in:
Florian Mounier
2016-06-13 16:15:57 +02:00
parent 7ebb122221
commit 503de38429
7 changed files with 26 additions and 10 deletions

View File

@@ -64,6 +64,9 @@ tornado.options.define("generate_current_user_pkcs", default=False,
tornado.options.define("generate_user_pkcs", default='',
help="Generate user pfx for client authentication "
"(Must be root to create for another user)")
tornado.options.define("uri_root_path", default='',
help="Sets the servier root path: "
"example.com/<uri_root_path>/static/")
if os.getuid() == 0:
ev = os.getenv('XDG_CONFIG_DIRS', '/etc')
@@ -296,7 +299,8 @@ from butterfly import application
application.butterfly_dir = butterfly_dir
log.info('Starting server')
http_server = tornado_systemd.SystemdHTTPServer(
application, ssl_options=ssl_opts)
application,
ssl_options=ssl_opts)
http_server.listen(port, address=host)
if http_server.systemd:

View File

@@ -66,7 +66,10 @@ if hasattr(tornado.options.options, 'debug'):
application = tornado.web.Application(
static_path=os.path.join(os.path.dirname(__file__), "static"),
template_path=os.path.join(os.path.dirname(__file__), "templates"),
debug=tornado.options.options.debug
debug=tornado.options.options.debug,
static_url_prefix='%s/static/' % (
'/%s' % tornado.options.options.uri_root_path
if tornado.options.options.uri_root_path else '')
)
import butterfly.routes

File diff suppressed because one or more lines are too long

View File

@@ -12,7 +12,7 @@
$ = document.querySelectorAll.bind(document);
document.addEventListener('DOMContentLoaded', function() {
var ctl, lastData, queue, send, t_queue, term, treat, ws, wsUrl;
var ctl, lastData, queue, root_path, send, t_queue, term, treat, ws, wsUrl;
term = null;
send = function(data) {
return ws.send('S' + data);
@@ -30,7 +30,11 @@
} else {
wsUrl = 'ws://';
}
wsUrl += document.location.host + '/ws' + location.pathname;
root_path = document.body.getAttribute('data-root-path');
if (root_path.length) {
root_path = "/" + root_path;
}
wsUrl += document.location.host + root_path + '/ws' + location.pathname;
ws = new WebSocket(wsUrl);
ws.addEventListener('open', function() {
console.log("WebSocket open", arguments);

File diff suppressed because one or more lines are too long

View File

@@ -14,7 +14,8 @@
</head>
<body spellcheck="false"
data-force-unicode-width="{{ 'yes' if options.force_unicode_width else 'no' }}">
data-force-unicode-width="{{ 'yes' if options.force_unicode_width else 'no' }}"
data-root-path="{{ options.uri_root_path }}">
<div id="popup" class="hidden">
</div>
<script src="{{ static_url('html-sanitizer.js') }}"></script>

View File

@@ -36,7 +36,11 @@ document.addEventListener 'DOMContentLoaded', ->
else
wsUrl = 'ws://'
wsUrl += document.location.host + '/ws' + location.pathname
root_path = document.body.getAttribute('data-root-path')
if root_path.length
root_path = "/#{root_path}"
wsUrl += document.location.host + root_path + '/ws' + location.pathname
ws = new WebSocket wsUrl
ws.addEventListener 'open', ->