Skip to content

Commit aa129dc

Browse files
author
Jeff
committed
clean up
1 parent f55e596 commit aa129dc

File tree

6 files changed

+31
-63
lines changed

6 files changed

+31
-63
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ node_modules
1212

1313
# This file is for local config which we never want committed:
1414
/sogs.ini
15+
16+
17+
/.vscode/

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

sogs/static/view_room.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const makebuffer = (raw) => {
32
let b = Uint8Array.from(window.atob(raw), (v) => v.charCodeAt(0));
43
// This data is padded with a 0x80 delimiter followed by any number of 0x00 bytes, but these are
@@ -50,12 +49,12 @@ const setup = async () => {
5049

5150
if(msgs.length === 0)
5251
{
53-
elem.appendChild(document.createTextNode(`the ${window.view_room} room is empty`));
52+
elem.appendChild(document.createTextNode(`the ${window.view_room_token} room is empty`));
5453
}
5554

5655
for(let msg of msgs.reverse())
5756
{
58-
let e = document.createElement("li")
57+
let e = document.createElement("li");
5958
try
6059
{
6160
const data = makebuffer(msg.data);
@@ -64,41 +63,42 @@ const setup = async () => {
6463
{
6564
throw Error(err);
6665
}
67-
66+
6867
const plain = Message.decode(data).dataMessage;
6968

7069
// reply
71-
if (plain.quote){
72-
originalMsg = document.createElement('p');
70+
if (plain.quote)
71+
{
72+
let originalMsg = document.createElement('p');
7373
originalMsg.classList.add('text-sm', 'italic', 'border-l-2', 'border-accent', 'pl-2');
7474

75-
authorId = plain.quote.author
75+
let authorId = plain.quote.author;
7676
authorId = authorId.substr(authorId.length - 8);
7777
originalMsg.appendChild(document.createTextNode("..." + authorId +": "+plain.quote.text));
7878
e.appendChild(originalMsg);
7979
}
80-
80+
8181
// message body
8282
e.appendChild(document.createTextNode(plain.profile.displayName +": "+plain.body));
8383
e.classList.add('bg-gray-300','dark:bg-lightGray', 'w-fit', 'rounded-lg', 'p-2', 'my-2')
8484
elem.appendChild(e);
85-
86-
// attachments
87-
if (plain.attachments.length > 0){
88-
plain.attachments.forEach(attachment => {
89-
console.log(attachment);
90-
attachmentElement = document.createElement('p');
91-
attachmentElement.appendChild(document.createTextNode("📎\xa0\xa0\xa0"));
92-
93-
attachmentLink = document.createElement('a');
94-
attachmentLink.appendChild(document.createTextNode((attachment.fileName || attachment.contentType) + ` (${formatBytes(attachment.size)})` ));
95-
attachmentLink.href = attachment.url;
96-
attachmentLink.download = (attachment.fileName || "");
97-
98-
attachmentElement.appendChild(attachmentLink);
99-
attachmentElement.classList.add('text-sm', 'italic', 'pl-1');
100-
e.appendChild(attachmentElement);
101-
});
85+
86+
// show attachments
87+
for(let attachment of plain.attachments)
88+
{
89+
90+
let attachmentElement = document.createElement('p');
91+
attachmentElement.appendChild(document.createTextNode("📎\xa0\xa0\xa0"));
92+
93+
let attachmentLink = document.createElement('a');
94+
attachmentLink.appendChild(document.createTextNode((attachment.fileName || attachment.contentType) + ` (${formatBytes(attachment.size)})` ));
95+
attachmentLink.href = attachment.url;
96+
attachmentLink.download = (attachment.fileName || "");
97+
98+
attachmentElement.appendChild(attachmentLink);
99+
attachmentElement.classList.add('text-sm', 'italic', 'pl-1');
100+
e.appendChild(attachmentElement);
101+
102102
}
103103

104104
}

sogs/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% for room in rooms %}
1212
<a class="px-5 flex flex-col justify-center items-center transition duration-250 text-center w-full h-24
1313
border-2 border-accent bg-gray-300 hover:bg-black hover:text-white md:h-28
14-
dark:border-accent rounded-full dark:bg-darkGray dark:hover:bg-accent dark:hover:text-black " href="/r/{{room.token}}">
14+
dark:border-accent rounded-full dark:bg-darkGray dark:hover:bg-accent dark:hover:text-black " href="{{room.url}}">
1515
<p class=" text-2xl xs:text-3xl sm:text-4xl">{{room.token }}</p>
1616
<p class="text-sm xs:text-lg sm:text-xl">{{room.active_users }} Active User{{'s' if room.active_users > 1}}</p>
1717
</a>

sogs/templates/view_room.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
</ul>
4444
</div>
4545
<script>
46-
window.view_room = "{{room.token}}";
46+
window.view_room_token = "{{room.token}}";
47+
window.view_room_url = "{{room.url}}";
4748
window.poll_room_url = "/room/{{room.token}}/messages/recent";
4849
</script>
4950
<script src="/static/protobuf.min.js"></script>

uwsgi-sogs.ini

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)