Add SSL flexibility to chat server
This commit is contained in:
parent
349389ce93
commit
6d192cf54d
3 changed files with 12 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,4 +13,6 @@ resources/ranks.css
|
||||||
resources/table.css
|
resources/table.css
|
||||||
sass_processed
|
sass_processed
|
||||||
<desired bridge log path>
|
<desired bridge log path>
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,14 @@ class ChatView(ListView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
# hard code, should be fixed later
|
||||||
|
address = f'{self.request.get_host()}/ws/chat/'
|
||||||
|
if self.request.is_secure():
|
||||||
|
context['ws_address'] = f'wss://{address}'
|
||||||
|
else:
|
||||||
|
context['ws_address'] = f'ws://{address}'
|
||||||
|
|
||||||
context['title'] = self.title
|
context['title'] = self.title
|
||||||
last_five_minutes = timezone.now()-timezone.timedelta(minutes=5)
|
last_five_minutes = timezone.now()-timezone.timedelta(minutes=5)
|
||||||
context['online_users'] = Profile.objects \
|
context['online_users'] = Profile.objects \
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
{% block js_media %}
|
{% block js_media %}
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var chatSocket = new WebSocket(
|
// change ws to wss if using HTTPS
|
||||||
'ws://' + window.location.host +
|
var chatSocket = new WebSocket( "{{ws_address}}" );
|
||||||
'/ws/chat/');
|
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="{{ static('mathjax_config.js') }}"></script>
|
<script type="text/javascript" src="{{ static('mathjax_config.js') }}"></script>
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
|
|
Loading…
Reference in a new issue