forked from s3lph/matemat
Fixed user-generated static resources paths.
This commit is contained in:
parent
8da58950ad
commit
68a228e95f
8 changed files with 15 additions and 15 deletions
|
@ -13,4 +13,4 @@ if __name__ == '__main__':
|
|||
port = int(sys.argv[1])
|
||||
|
||||
# Start the web server
|
||||
MatematWebserver(port=port, staticroot='/var/matemat/upload').start()
|
||||
MatematWebserver(port=port, staticroot='./static').start()
|
||||
|
|
|
@ -78,8 +78,8 @@ def handle_change(args: RequestArguments, user: User, db: MatematDatabase) -> No
|
|||
if 'avatar' not in args:
|
||||
return
|
||||
avatar = bytes(args.avatar)
|
||||
os.makedirs('/var/matemat/upload/thumbnails/users/', exist_ok=True)
|
||||
with open(f'/var/matemat/upload/thumbnails/users/{user.id}.png', 'wb') as f:
|
||||
os.makedirs('./static/upload/thumbnails/users/', exist_ok=True)
|
||||
with open(f'./static/upload/thumbnails/users/{user.id}.png', 'wb') as f:
|
||||
f.write(avatar)
|
||||
|
||||
except UnicodeDecodeError:
|
||||
|
@ -111,8 +111,8 @@ def handle_admin_change(args: RequestArguments, db: MatematDatabase):
|
|||
newproduct = db.create_product(name, price_member, price_non_member)
|
||||
if 'image' in args:
|
||||
image = bytes(args.image)
|
||||
os.makedirs('/var/matemat/upload/thumbnails/products/', exist_ok=True)
|
||||
with open(f'/var/matemat/upload/thumbnails/products/{newproduct.id}.png', 'wb') as f:
|
||||
os.makedirs('./static/upload/thumbnails/products/', exist_ok=True)
|
||||
with open(f'./static/upload/thumbnails/products/{newproduct.id}.png', 'wb') as f:
|
||||
f.write(image)
|
||||
|
||||
elif change == 'restock':
|
||||
|
|
|
@ -47,7 +47,7 @@ def handle_change(args: RequestArguments, product: Product, db: MatematDatabase)
|
|||
if change == 'del':
|
||||
db.delete_product(product)
|
||||
try:
|
||||
os.remove(f'/var/matemat/upload/thumbnails/products/{product.id}.png')
|
||||
os.remove(f'./static/upload/thumbnails/products/{product.id}.png')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
@ -76,6 +76,6 @@ def handle_change(args: RequestArguments, product: Product, db: MatematDatabase)
|
|||
if 'image' in args:
|
||||
image = bytes(args.image)
|
||||
if len(image) > 0:
|
||||
os.makedirs('/var/matemat/upload/thumbnails/products/', exist_ok=True)
|
||||
with open(f'/var/matemat/upload/thumbnails/products/{product.id}.png', 'wb') as f:
|
||||
os.makedirs('./static/upload/thumbnails/products/', exist_ok=True)
|
||||
with open(f'./static/upload/thumbnails/products/{product.id}.png', 'wb') as f:
|
||||
f.write(image)
|
||||
|
|
|
@ -47,7 +47,7 @@ def handle_change(args: RequestArguments, user: User, db: MatematDatabase) -> No
|
|||
if change == 'del':
|
||||
db.delete_user(user)
|
||||
try:
|
||||
os.remove(f'/var/matemat/upload/thumbnails/users/{user.id}.png')
|
||||
os.remove(f'./static/upload/thumbnails/users/{user.id}.png')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
@ -83,6 +83,6 @@ def handle_change(args: RequestArguments, user: User, db: MatematDatabase) -> No
|
|||
if 'avatar' in args:
|
||||
avatar = bytes(args.avatar)
|
||||
if len(avatar) > 0:
|
||||
os.makedirs('/var/matemat/upload/thumbnails/users/', exist_ok=True)
|
||||
with open(f'/var/matemat/upload/thumbnails/users/{user.id}.png', 'wb') as f:
|
||||
os.makedirs('./static/upload/thumbnails/users/', exist_ok=True)
|
||||
with open(f'./static/upload/thumbnails/users/{user.id}.png', 'wb') as f:
|
||||
f.write(avatar)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<input id="modproduct-balance" name="stock" type="text" value="{{ product.stock }}" /><br/>
|
||||
|
||||
<label for="modproduct-image">
|
||||
<img height="150" src="/img/thumbnails/products/{{ product.id }}.png" alt="Image of {{ product.name }}" />
|
||||
<img height="150" src="/upload/thumbnails/products/{{ product.id }}.png" alt="Image of {{ product.name }}" />
|
||||
</label><br/>
|
||||
<input id="modproduct-image" type="file" name="image" accept="image/png" /><br/>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<input id="moduser-account-balance" name="balance" type="text" value="{{ user.balance }}" /><br/>
|
||||
|
||||
<label for="moduser-account-avatar">
|
||||
<img height="150" src="/img/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
||||
<img height="150" src="/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
||||
</label><br/>
|
||||
<input id="moduser-account-avatar" type="file" name="avatar" accept="image/png" /><br/>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Your balance: {{ authuser.balance }}
|
|||
{% endif %}
|
||||
; Stock: {{ product.stock }}</span><br/>
|
||||
<div class="imgcontainer">
|
||||
<img src="/img/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}" />
|
||||
<img src="/upload/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}" />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<a href="/touchkey?uid={{ user.id }}&username={{ user.name }}">
|
||||
<span class="thumblist-title">{{ user.name }}</span><br/>
|
||||
<div class="imgcontainer">
|
||||
<img src="/img/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
||||
<img src="/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue