From 27ae81180eba18f7c3fb8732a11dd2ab7d315383 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 29 Apr 2024 22:06:06 +1200 Subject: [PATCH] chat ui improvements --- index.html | 199 +++++++++++++++++++++++----------- public/assets/images/user.png | Bin 0 -> 3490 bytes web.py | 16 ++- 3 files changed, 148 insertions(+), 67 deletions(-) create mode 100644 public/assets/images/user.png diff --git a/index.html b/index.html index 33d8f6e..45dc244 100644 --- a/index.html +++ b/index.html @@ -16,11 +16,11 @@ -
+
-
+
-
-
- <{{ peer.destination_hash }}> {{ peer.app_data }} -
-
- - -
-
-
-
-
-
- - -
- - - -
- - -
- - - -
+ +
+ +
+
+
+
+ + + +
+
Peers Discovered ({{ Object.keys(peers).length }})
+
+
+
+
+
-
-
- You - Error - @<{{ chatItem.source_hash }}> -
-
{{ chatItem.message.content }}
-
- -
- +
+
{{ peer.app_data || "Anonymous Peer" }}
+
@<{{ peer.destination_hash.substring(0, 8) }}>
-
- -
-
+ +
+ + +
+ + +
+ + +
+
{{ selectedPeer.app_data || "Anonymous Peer" }}
+
@<{{ selectedPeer.destination_hash }}>
+
+ + +
+
+
+
+ + + +
+
+
+
- -
- -
-
+ + +
+
+
+
+
+
+ + +
+ + + +
+ + +
+ + + +
+ +
+
+
+ You + Error + @<{{ chatItem.source_hash }}> +
+
{{ chatItem.message.content }}
+
+ +
+ +
+
+
+
+
+
+ + +
+
+ + +
+ +
+ +
+
+ +
+
+ +
+ + +
+
+ + + +
+
No Active Chat
+
Select a Peer to start chatting!
+
diff --git a/public/assets/images/user.png b/public/assets/images/user.png new file mode 100644 index 0000000000000000000000000000000000000000..b24c5367418a5473f07631c76467fd4b70aed746 GIT binary patch literal 3490 zcmbVOdmxnQ8h^jJ7{+z@2&HjJ4NHkBg&NYBj9g|a+G(RiZrepJNn56yG*O$|Zg$%l zgD6Fzlqh1@AnVTk6gagLZ2297PL1&-xi6kelL{?H#Br7T^tEj6f zt58%F71gxVC>p4yrlykWJZ&vhTOH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py @@ -3,6 +3,8 @@ import argparse import http import json +import mimetypes +import os import RNS import LXMF @@ -43,7 +45,7 @@ class ReticulumWebChat: # handle serving custom http paths async def process_request(self, path, request_headers): - + # serve index.html if path == "/": with open("index.html") as f: @@ -51,10 +53,20 @@ class ReticulumWebChat: return http.HTTPStatus.OK, [ ('Content-Type', 'text/html') ], file_content.encode("utf-8") + + # serve anything in public folder + public_file_path = os.path.join("public", path.lstrip("/")) + if os.path.isfile(public_file_path): + mime_type, _ = mimetypes.guess_type(public_file_path) + with open(public_file_path, "rb") as f: + file_content = f.read() + return http.HTTPStatus.OK, [ + ('Content-Type', mime_type) + ], file_content # by default, websocket is always served, but we only want it to be available at /ws # so we will return 404 for everything other than /ws - elif path != "/ws": + if path != "/ws": return http.HTTPStatus.NOT_FOUND, [ ('Content-Type', 'text/html') ], b"Not Found"