From 5d815defc897cba63d74f49bf1b70fd15a8411e9 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Tue, 9 Jan 2024 23:42:54 +0100
Subject: [PATCH 01/13] Fixed default propic and propic file removal
---
propic.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/propic.py b/propic.py
index c900976..09bc697 100644
--- a/propic.py
+++ b/propic.py
@@ -17,9 +17,16 @@ async def resetDefaultPropic(request, order: Order, isFursuiter, sendAnswer=True
with open("res/propic/default.png", "rb") as f:
data = f.read()
f.close()
- os.remove(f"res/propic/{order.ans(f'propic{s}')}") # converted file
- filenameNoExt = order.ans(f'propic{s}').split(".jpg")[0]
- os.remove(f"res/propic/{filenameNoExt}_original.jpg") # original file
+
+ convertedFilename = order.ans(f'propic{s}')
+ if convertedFilename is not None:
+ convertedFilename = f"res/propic/{convertedFilename}"
+ if os.path.exists(convertedFilename):
+ os.remove(convertedFilename) # converted file
+ originalFilename = f"res/propic/propic{s}_{order.code}_original"
+ if os.path.exists(originalFilename):
+ os.remove(originalFilename) # original file
+
await order.edit_answer_fileUpload(f'propic{s}_file', f'propic{s}_file_{order.code}_default.png', 'image/png', data)
if(sendAnswer):
await order.send_answers()
@@ -35,11 +42,11 @@ async def upload_propic(request, order: Order):
raise exceptions.BadRequest("The deadline has passed. You cannot modify the badges at this moment.")
if request.form.get('submit') == 'Delete main image':
- await order.edit_answer('propic', None)
await resetDefaultPropic(request, order, False, sendAnswer=False)
+ await order.edit_answer('propic', None) #This MUST come after the reset default propic!
elif request.form.get('submit') == 'Delete fursuit image':
- await order.edit_answer('propic_fursuiter', None)
await resetDefaultPropic(request, order, True, sendAnswer=False)
+ await order.edit_answer('propic_fursuiter', None) #This MUST come after the reset default propic!
else:
for fn, body in request.files.items():
if fn not in ['propic', 'propic_fursuiter']:
@@ -66,7 +73,7 @@ async def upload_propic(request, order: Order):
raise exceptions.BadRequest(errorDetails)
- with open(f"res/propic/{fn}_{order.code}_original.jpg", "wb") as f:
+ with open(f"res/propic/{fn}_{order.code}_original", "wb") as f:
f.write(body[0].body)
aspect_ratio = width/height
From 5c44c620e41f53309f743cb78ecdf4ee57af959d Mon Sep 17 00:00:00 2001
From: Stranck
Date: Tue, 9 Jan 2024 23:43:39 +0100
Subject: [PATCH 02/13] Updated sponsor animation speed + fixed bug on iOs
---
res/styles/propic.css | 4 ++--
tpl/blocks/propic.html | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/res/styles/propic.css b/res/styles/propic.css
index 57e8168..917cd3f 100644
--- a/res/styles/propic.css
+++ b/res/styles/propic.css
@@ -58,12 +58,12 @@ svg.propic-border-filter {
.propic-border.propic-animated-super .propic-border-animation {
background: linear-gradient(90deg, #FA5E00 20%, #FAAA00 40%, #FB8C00 60%, #FA3200 80%, #FAC800 100%);
- animation: border-animation 1s linear 0ms infinite;
+ animation: border-animation 2.5s linear 0ms infinite;
}
.propic-border.propic-animated-normal .propic-border-animation {
background: linear-gradient(90deg, #6124AB 20%, #AB248F 40%, #8E24AA 60%, #3524AB 80%, #AB243E 100%);
- animation: border-animation 1s linear 0ms infinite;
+ animation: border-animation 2.5s linear 0ms infinite;
}
@keyframes border-animation {
diff --git a/tpl/blocks/propic.html b/tpl/blocks/propic.html
index cd78b0f..3f5a48e 100644
--- a/tpl/blocks/propic.html
+++ b/tpl/blocks/propic.html
@@ -8,7 +8,7 @@
{% endif %}
-
+
{% if flag %}
{% endif %}
From 04e7bd30055d384359b82eb3127546f157c1abee Mon Sep 17 00:00:00 2001
From: Stranck
Date: Tue, 9 Jan 2024 23:43:53 +0100
Subject: [PATCH 03/13] Fixed room button centering
---
res/styles/room.css | 6 ++++++
tpl/blocks/room.html | 4 ++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/res/styles/room.css b/res/styles/room.css
index 700af6c..a965512 100644
--- a/res/styles/room.css
+++ b/res/styles/room.css
@@ -11,4 +11,10 @@ span.nsc-room-counter {
div.room-actions a>span {
display: none;
}
+}
+
+#room a[role=button] {
+ display: inline-flex;
+ justify-content: center;
+ align-items: center;
}
\ No newline at end of file
diff --git a/tpl/blocks/room.html b/tpl/blocks/room.html
index fa95b56..5164156 100644
--- a/tpl/blocks/room.html
+++ b/tpl/blocks/room.html
@@ -85,9 +85,9 @@
{% endif %}
{# 0 %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm {{[None,'single','double','triple','quadruple','quintuple'][len(room_members)]}} room #}
- Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
+ Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
- Rename room {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
+ Rename room
{% endif %}
{% else %}
{% if order.room_id and not order.room_confirmed %}
From 9dfacc3b5bec8927d2d46415a55acf39a53c78b5 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Tue, 9 Jan 2024 23:48:38 +0100
Subject: [PATCH 04/13] Fixed strong text in room button
---
res/styles/room.css | 2 +-
tpl/blocks/room.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/res/styles/room.css b/res/styles/room.css
index a965512..6460419 100644
--- a/res/styles/room.css
+++ b/res/styles/room.css
@@ -15,6 +15,6 @@ span.nsc-room-counter {
#room a[role=button] {
display: inline-flex;
- justify-content: center;
+ justify-content: space-around;
align-items: center;
}
\ No newline at end of file
diff --git a/tpl/blocks/room.html b/tpl/blocks/room.html
index 5164156..f083909 100644
--- a/tpl/blocks/room.html
+++ b/tpl/blocks/room.html
@@ -85,7 +85,7 @@
{% endif %}
{# 0 %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm {{[None,'single','double','triple','quadruple','quintuple'][len(room_members)]}} room #}
- Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
+ Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
Rename room
{% endif %}
From c5fb4fd55d13211d5ea514b7cb0721995b638c17 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Wed, 10 Jan 2024 11:24:24 +0100
Subject: [PATCH 05/13] Hash is not used anymore in propics upload
---
propic.py | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/propic.py b/propic.py
index 09bc697..de1d85f 100644
--- a/propic.py
+++ b/propic.py
@@ -58,10 +58,13 @@ async def upload_propic(request, order: Order):
if len(body[0].body) > PROPIC_MAX_FILE_SIZE:
raise exceptions.BadRequest("File size too large for " + ("Profile picture" if fn == 'propic' else 'Fursuit picture'))
- h = sha224(body[0].body).hexdigest()[:32]
errorDetails = ''
+ bodyBytesBuff = None
+ imgBytesBuff = None
+ img = None
try:
- img = Image.open(BytesIO(body[0].body))
+ bodyBytesBuff = BytesIO(body[0].body)
+ img = Image.open(bodyBytesBuff)
width, height = img.size
# Checking for min / max size
if width < PROPIC_MIN_SIZE[0] or height < PROPIC_MIN_SIZE[1]:
@@ -88,19 +91,28 @@ async def upload_propic(request, order: Order):
width, height = img.size
img.thumbnail((512,512))
- imgBytes = BytesIO()
- img.save(imgBytes, format='jpeg')
- imgBytes = imgBytes.getvalue()
- with open(f"res/propic/{fn}_{order.code}_{h}.jpg", "wb") as f:
+ imgBytesBuff = BytesIO()
+ img.save(imgBytesBuff, format='jpeg')
+ imgBytes = imgBytesBuff.getvalue()
+ with open(f"res/propic/{fn}_{order.code}.jpg", "wb") as f:
f.write(imgBytes)
- await order.edit_answer_fileUpload(f'{fn}_file', f'{fn}_file_{order.code}_{h}.jpg', 'image/jpeg', imgBytes)
+ await order.edit_answer_fileUpload(f'{fn}_file', f'{fn}_file_{order.code}.jpg', 'image/jpeg', imgBytes)
except Exception:
import traceback
if DEV_MODE: print(traceback.format_exc())
raise exceptions.BadRequest(errorDetails if errorDetails else "The image you uploaded is not valid.")
else:
- await order.edit_answer(fn, f"{fn}_{order.code}_{h}.jpg")
+ await order.edit_answer(fn, f"{fn}_{order.code}.jpg")
+
+ if img is not None:
+ img.close()
+ if bodyBytesBuff is not None:
+ bodyBytesBuff.flush()
+ bodyBytesBuff.close()
+ if imgBytesBuff is not None:
+ imgBytesBuff.flush()
+ imgBytesBuff.close()
await order.send_answers()
return redirect("/manage/welcome#badge")
From 456361c5850356b8d01e146aa2665909418343b0 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Wed, 10 Jan 2024 14:04:04 +0100
Subject: [PATCH 06/13] Visual fixes with buttons
---
tpl/base.html | 5 +++++
tpl/blocks/badge.html | 14 ++++----------
tpl/blocks/room.html | 14 +++++---------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tpl/base.html b/tpl/base.html
index 3dfc06c..51f4faa 100644
--- a/tpl/base.html
+++ b/tpl/base.html
@@ -51,6 +51,11 @@
.tag {background:var(--primary);color:var(--contrast);font-size:0.8em;font-weight:600;padding:0.1em 0.3em;border-radius:3px;}
+ .grid_2x2 {
+ grid-template-columns: repeat(2, 1fr);
+ grid-template-rows: repeat(2, 1fr);
+ }
+
.rainbow-text {
background-image: repeating-linear-gradient(90deg, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff);
text-align: center;
diff --git a/tpl/blocks/badge.html b/tpl/blocks/badge.html
index c553a99..91baf5b 100644
--- a/tpl/blocks/badge.html
+++ b/tpl/blocks/badge.html
@@ -42,16 +42,10 @@
{% endif %}
-
- {% if order.ans('propic') %}
-
PROPIC_DEADLINE else ''}} />
- {% endif %}
- {% if order.ans('propic_fursuiter') %}
-
PROPIC_DEADLINE else ''}} />
- {% endif %}
- {% if not order.ans('propic') or (order.is_fursuiter and not order.ans('propic_fursuiter')) %}
-
- {% endif %}
+
+
+ PROPIC_DEADLINE or not order.ans('propic')) else ''}} />
+ PROPIC_DEADLINE or not order.ans('propic_fursuiter')) else ''}} />
diff --git a/tpl/blocks/room.html b/tpl/blocks/room.html
index f083909..dbf1c80 100644
--- a/tpl/blocks/room.html
+++ b/tpl/blocks/room.html
@@ -75,19 +75,15 @@
{% endif %}
{% endif %}
-
+
{% if order.room_owner %}
{% if not order.room_confirmed %}
-
- {% if len(room_members) == 1 %}
- Delete room
- {% endif %}
-
{# 0 %}href="javascript:document.getElementById('modal-roomconfirm').setAttribute('open', 'true');"{% endif %}>Confirm {{[None,'single','double','triple','quadruple','quintuple'][len(room_members)]}} room #}
- Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
-
- Rename room
+
+ Rename room
+ 1) else ''}} >Delete room
+ Confirm {{[None,'single','double','triple','quadruple','quintuple'][order.room_person_no]}} room
{% endif %}
{% else %}
{% if order.room_id and not order.room_confirmed %}
From dafe98dfbbabb43708e3ced3f10f8e348624c0a6 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Thu, 11 Jan 2024 18:15:56 +0100
Subject: [PATCH 07/13] Updated prints
---
app.py | 2 +-
config.example.py | 2 ++
propic.py | 4 ++--
utils.py | 6 +++---
4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app.py b/app.py
index 2633634..4a74756 100644
--- a/app.py
+++ b/app.py
@@ -176,4 +176,4 @@ async def logour(request):
raise exceptions.Forbidden("You have been logged out.")
if __name__ == "__main__":
- app.run(host="0.0.0.0", port=8188, dev=DEV_MODE)
+ app.run(host="0.0.0.0", port=8188, dev=DEV_MODE, access_log=ACCESS_LOG)
diff --git a/config.example.py b/config.example.py
index 77cece6..d2b3985 100644
--- a/config.example.py
+++ b/config.example.py
@@ -16,6 +16,8 @@ FILL_CACHE = True
CACHE_EXPIRE_TIME = 60 * 60 * 4
DEV_MODE = True
+ACCESS_LOG = True
+EXTRA_PRINTS = True
# Metadata property for item-id mapping
METADATA_NAME = "item_name"
diff --git a/propic.py b/propic.py
index de1d85f..64f72e3 100644
--- a/propic.py
+++ b/propic.py
@@ -12,7 +12,7 @@ bp = Blueprint("propic", url_prefix="/manage/propic")
async def resetDefaultPropic(request, order: Order, isFursuiter, sendAnswer=True):
s = "_fursuiter" if isFursuiter else ""
- if (DEV_MODE):
+ if (EXTRA_PRINTS):
print("Resetting {fn} picture for {orderCod}".format(fn="Badge" if not isFursuiter else "fursuit", orderCod = order.code))
with open("res/propic/default.png", "rb") as f:
data = f.read()
@@ -100,7 +100,7 @@ async def upload_propic(request, order: Order):
await order.edit_answer_fileUpload(f'{fn}_file', f'{fn}_file_{order.code}.jpg', 'image/jpeg', imgBytes)
except Exception:
import traceback
- if DEV_MODE: print(traceback.format_exc())
+ if EXTRA_PRINTS: print(traceback.format_exc())
raise exceptions.BadRequest(errorDetails if errorDetails else "The image you uploaded is not valid.")
else:
await order.edit_answer(fn, f"{fn}_{order.code}.jpg")
diff --git a/utils.py b/utils.py
index 211a994..50427fc 100644
--- a/utils.py
+++ b/utils.py
@@ -73,7 +73,7 @@ async def loadItems():
categoryName = checkAndGetCategory ('item', q)
if not categoryName: continue
CATEGORIES_LIST_MAP[categoryName].append(q['id'])
- if (DEV_MODE):
+ if (EXTRA_PRINTS):
print (f'Mapped Items:')
print (ITEMS_ID_MAP)
print (f'Mapped Variations:')
@@ -86,13 +86,13 @@ async def loadItems():
# Tries to get an item name from metadata. Prints a warning if an item has no metadata
def checkAndGetName(type, q):
itemName = extractMetadataName(q)
- if not itemName and DEV_MODE:
+ if not itemName and EXTRA_PRINTS:
print (type + ' ' + q['id'] + ' has not been mapped.')
return itemName
def checkAndGetCategory (type, q):
categoryName = extractCategory (q)
- if not categoryName and DEV_MODE:
+ if not categoryName and EXTRA_PRINTS:
print (type + ' ' + q['id'] + ' has no category set.')
return categoryName
From f3eb905298e5234426a2c296da97050552da36d5 Mon Sep 17 00:00:00 2001
From: Stranck
Date: Thu, 11 Jan 2024 18:44:48 +0100
Subject: [PATCH 08/13] Updated footer credits
---
tpl/base.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tpl/base.html b/tpl/base.html
index 51f4faa..075818c 100644
--- a/tpl/base.html
+++ b/tpl/base.html
@@ -124,7 +124,7 @@
});