diff --git a/chat_box/models.py b/chat_box/models.py
index 297b921..748e933 100644
--- a/chat_box/models.py
+++ b/chat_box/models.py
@@ -19,17 +19,11 @@ class Message(models.Model):
body = models.TextField(verbose_name=_('body of comment'), max_length=8192)
def notify_ws_clients(self):
- # inform client that there is a new message
notification = {
'type': 'recieve_group_message',
'message': '{}'.format(self.id)
}
channel_layer = get_channel_layer()
- # print("user.id {}".format(self.user.id))
- # print("user.id {}".format(self.recipient.id))
-
- async_to_sync(channel_layer.group_send)("{}".format(self.user.id), notification)
- async_to_sync(channel_layer.group_send)("{}".format(self.recipient.id), notification)
def save(self, *args, **kwargs):
new_message = self.id
diff --git a/chat_box/views.py b/chat_box/views.py
index 110c3c2..d507c98 100644
--- a/chat_box/views.py
+++ b/chat_box/views.py
@@ -1,11 +1,31 @@
-from django.shortcuts import render
+from django.http import HttpResponseRedirect
from django.utils.translation import gettext as _
from django.views.generic import ListView
+from django.urls import reverse
+from django.utils import timezone
+
from .models import Message
class ChatView(ListView):
model = Message
- title = _('Chat Box')
+ context_object_name = 'messages'
template_name = 'chat/chat.html'
+ title = _('Chat Box')
+
+ def get_context_data(self, **kwargs):
+ context = super(ChatView, self).get_context_data(**kwargs)
+ context['title'] = self.title
+ return context
+
+ def get_queryset(self):
+ return None
+
+
+def send(request):
+ new_message = Message(body=request.POST['message'],
+ author=request.profile,
+ time=timezone.now())
+ new_message.save()
+ return HttpResponseRedirect(reverse('chat'))
diff --git a/dmoj/urls.py b/dmoj/urls.py
index 3b96d68..c13ab03 100644
--- a/dmoj/urls.py
+++ b/dmoj/urls.py
@@ -1,4 +1,4 @@
-from chat_box.views import ChatView
+from chat_box.views import ChatView, send
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
@@ -367,7 +367,10 @@ urlpatterns = [
url(r'^custom_checker_sample/', about.custom_checker_sample, name='custom_checker_sample'),
- url(r'^chat/', ChatView.as_view(), name='chat'),
+ url(r'^chat/', include([
+ url(r'^$', ChatView.as_view(), name='chat'),
+ url(r'send$', send, name='send_message')
+ ])),
]
favicon_paths = ['apple-touch-icon-180x180.png', 'apple-touch-icon-114x114.png', 'android-chrome-72x72.png',
diff --git a/resources/chatbox.scss b/resources/chatbox.scss
new file mode 100644
index 0000000..dbbc2f4
--- /dev/null
+++ b/resources/chatbox.scss
@@ -0,0 +1,58 @@
+#chat-log {
+ padding: 0;
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ height: 20em;
+ width: 100%;
+ overflow: hidden;
+ overflow-wrap: break-word;
+ overflow-y: scroll;
+}
+
+#chat-log li {
+ list-style-type: none;
+ margin: 0.5em;
+}
+
+#chat-input {
+ width: 100%;
+ padding: 0.4em;
+ color: black;
+}
+
+#chat-submit {
+ margin-top: 1em;
+}
+
+.profile-pic {
+ height: 2.6em;
+ width: 2.6em;
+ border-radius: 0.3em;
+ margin-top: 0.1em;
+ float: left;
+}
+
+.body-message {
+ padding-left: 3em;
+}
+
+.user-time {
+ margin-bottom: 0.3em;
+}
+
+.time {
+ margin-left: 0.5em;
+}
+
+.user {
+ font-weight: bold;
+}
+
+.clear {
+ clear: both;
+}
+.message {
+ word-wrap: break-word;
+}
+
+
diff --git a/resources/icons/android-chrome-144x144.png b/resources/icons/android-chrome-144x144.png
index 4414980..6a5f355 100644
Binary files a/resources/icons/android-chrome-144x144.png and b/resources/icons/android-chrome-144x144.png differ
diff --git a/resources/icons/android-chrome-192x192.png b/resources/icons/android-chrome-192x192.png
index 643a3cc..86ba0f1 100644
Binary files a/resources/icons/android-chrome-192x192.png and b/resources/icons/android-chrome-192x192.png differ
diff --git a/resources/icons/android-chrome-36x36.png b/resources/icons/android-chrome-36x36.png
index f9ab9a9..1afb5d0 100644
Binary files a/resources/icons/android-chrome-36x36.png and b/resources/icons/android-chrome-36x36.png differ
diff --git a/resources/icons/android-chrome-48x48.png b/resources/icons/android-chrome-48x48.png
index 17b3d6d..373c603 100644
Binary files a/resources/icons/android-chrome-48x48.png and b/resources/icons/android-chrome-48x48.png differ
diff --git a/resources/icons/android-chrome-72x72.png b/resources/icons/android-chrome-72x72.png
index 473c807..47ea2ce 100644
Binary files a/resources/icons/android-chrome-72x72.png and b/resources/icons/android-chrome-72x72.png differ
diff --git a/resources/icons/android-chrome-96x96.png b/resources/icons/android-chrome-96x96.png
index 7a48552..5d553bf 100644
Binary files a/resources/icons/android-chrome-96x96.png and b/resources/icons/android-chrome-96x96.png differ
diff --git a/resources/icons/apple-touch-icon-114x114-precomposed.png b/resources/icons/apple-touch-icon-114x114-precomposed.png
new file mode 100644
index 0000000..5764db5
Binary files /dev/null and b/resources/icons/apple-touch-icon-114x114-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-114x114.png b/resources/icons/apple-touch-icon-114x114.png
index c58ca6b..4bb4160 100644
Binary files a/resources/icons/apple-touch-icon-114x114.png and b/resources/icons/apple-touch-icon-114x114.png differ
diff --git a/resources/icons/apple-touch-icon-120x120-precomposed.png b/resources/icons/apple-touch-icon-120x120-precomposed.png
new file mode 100644
index 0000000..2ee5716
Binary files /dev/null and b/resources/icons/apple-touch-icon-120x120-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-120x120.png b/resources/icons/apple-touch-icon-120x120.png
index 7176de4..63a1fdd 100644
Binary files a/resources/icons/apple-touch-icon-120x120.png and b/resources/icons/apple-touch-icon-120x120.png differ
diff --git a/resources/icons/apple-touch-icon-144x144-precomposed.png b/resources/icons/apple-touch-icon-144x144-precomposed.png
new file mode 100644
index 0000000..2fd4d8e
Binary files /dev/null and b/resources/icons/apple-touch-icon-144x144-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-144x144.png b/resources/icons/apple-touch-icon-144x144.png
index aff4d3b..cc16c9f 100644
Binary files a/resources/icons/apple-touch-icon-144x144.png and b/resources/icons/apple-touch-icon-144x144.png differ
diff --git a/resources/icons/apple-touch-icon-152x152-precomposed.png b/resources/icons/apple-touch-icon-152x152-precomposed.png
new file mode 100644
index 0000000..1f6ea27
Binary files /dev/null and b/resources/icons/apple-touch-icon-152x152-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-152x152.png b/resources/icons/apple-touch-icon-152x152.png
index 983db1e..300b82f 100644
Binary files a/resources/icons/apple-touch-icon-152x152.png and b/resources/icons/apple-touch-icon-152x152.png differ
diff --git a/resources/icons/apple-touch-icon-180x180-precomposed.png b/resources/icons/apple-touch-icon-180x180-precomposed.png
new file mode 100644
index 0000000..8553085
Binary files /dev/null and b/resources/icons/apple-touch-icon-180x180-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-180x180.png b/resources/icons/apple-touch-icon-180x180.png
index ae819ae..d737f87 100644
Binary files a/resources/icons/apple-touch-icon-180x180.png and b/resources/icons/apple-touch-icon-180x180.png differ
diff --git a/resources/icons/apple-touch-icon-57x57-precomposed.png b/resources/icons/apple-touch-icon-57x57-precomposed.png
new file mode 100644
index 0000000..deb2048
Binary files /dev/null and b/resources/icons/apple-touch-icon-57x57-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-57x57.png b/resources/icons/apple-touch-icon-57x57.png
index b6efba1..2b2533d 100644
Binary files a/resources/icons/apple-touch-icon-57x57.png and b/resources/icons/apple-touch-icon-57x57.png differ
diff --git a/resources/icons/apple-touch-icon-60x60-precomposed.png b/resources/icons/apple-touch-icon-60x60-precomposed.png
new file mode 100644
index 0000000..6b16cb1
Binary files /dev/null and b/resources/icons/apple-touch-icon-60x60-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-60x60.png b/resources/icons/apple-touch-icon-60x60.png
index 82d7a24..7c86aba 100644
Binary files a/resources/icons/apple-touch-icon-60x60.png and b/resources/icons/apple-touch-icon-60x60.png differ
diff --git a/resources/icons/apple-touch-icon-72x72-precomposed.png b/resources/icons/apple-touch-icon-72x72-precomposed.png
new file mode 100644
index 0000000..85fa920
Binary files /dev/null and b/resources/icons/apple-touch-icon-72x72-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-72x72.png b/resources/icons/apple-touch-icon-72x72.png
index e34f93a..3aa3aff 100644
Binary files a/resources/icons/apple-touch-icon-72x72.png and b/resources/icons/apple-touch-icon-72x72.png differ
diff --git a/resources/icons/apple-touch-icon-76x76-precomposed.png b/resources/icons/apple-touch-icon-76x76-precomposed.png
new file mode 100644
index 0000000..abaf04a
Binary files /dev/null and b/resources/icons/apple-touch-icon-76x76-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon-76x76.png b/resources/icons/apple-touch-icon-76x76.png
index 0106c6b..a2d3734 100644
Binary files a/resources/icons/apple-touch-icon-76x76.png and b/resources/icons/apple-touch-icon-76x76.png differ
diff --git a/resources/icons/apple-touch-icon-precomposed.png b/resources/icons/apple-touch-icon-precomposed.png
index ae09341..8553085 100644
Binary files a/resources/icons/apple-touch-icon-precomposed.png and b/resources/icons/apple-touch-icon-precomposed.png differ
diff --git a/resources/icons/apple-touch-icon.png b/resources/icons/apple-touch-icon.png
index ae819ae..e537d48 100644
Binary files a/resources/icons/apple-touch-icon.png and b/resources/icons/apple-touch-icon.png differ
diff --git a/resources/icons/browserconfig.xml b/resources/icons/browserconfig.xml
index 81ec113..df8a72d 100644
--- a/resources/icons/browserconfig.xml
+++ b/resources/icons/browserconfig.xml
@@ -1,12 +1,11 @@