From 171fb6bd4404a8795f6defd41e8635d1763bb1e6 Mon Sep 17 00:00:00 2001 From: PekopT Date: Tue, 18 Oct 2016 01:57:16 +0300 Subject: [PATCH] wss + robots --- archilance/urls.py | 4 ---- assets/js/chat.js | 7 ++++++- robots.txt => robots/robots.txt | 0 templates/partials/base.html | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) rename robots.txt => robots/robots.txt (100%) diff --git a/archilance/urls.py b/archilance/urls.py index c402dc2..a81eb22 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -47,10 +47,6 @@ urlpatterns = [ 'message': 'Произошла ошибка при оплате', }, name='tmp-payment-fail'), - url(r'^robots\.txt$', TemplateView.as_view(), - {'template': 'robots.txt', 'mimetype': 'text/plain'} - ), - ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: diff --git a/assets/js/chat.js b/assets/js/chat.js index 0cb86cd..e541f8d 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -29,7 +29,12 @@ window.confirm = function (message, callback, caption) { var SocketHandler = function () { domain = domain.replace(':' + port, ''); - var url = 'ws://' + domain + '/chat/' + userId + '/'; + if (window.location.protocol == 'https:') { + var ws = "wss://"; + } else { + var ws = "ws://"; + } + var url = ws + domain + '/chat/' + userId + '/'; var sock = new WebSocket(url); var intervalId; sock.onopen = function () { diff --git a/robots.txt b/robots/robots.txt similarity index 100% rename from robots.txt rename to robots/robots.txt diff --git a/templates/partials/base.html b/templates/partials/base.html index d3d09ef..5a036e3 100644 --- a/templates/partials/base.html +++ b/templates/partials/base.html @@ -33,7 +33,7 @@ - + @@ -100,7 +100,13 @@ if ((queryString.indexOf('/chat') != 0) && (queryString.indexOf('/users/contractor-office/work-projects') != 0)) { domain = domain.replace(':' + port, ''); - var url = 'ws://' + domain + '/chat/' + userId + '/'; + if (window.location.protocol == 'https:') { + var ws = "wss://"; + } else { + var ws = "ws://"; + } + + var url = ws + domain + '/chat/' + userId + '/'; var sock = new WebSocket(url); var intervalId; sock.onopen = function () {