fix: image cache busting
This commit is contained in:
parent
5aa3d2e4c2
commit
2f79377c09
12 changed files with 34 additions and 12 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
||||||
# Matemat Changelog
|
# Matemat Changelog
|
||||||
|
|
||||||
|
<!-- BEGIN RELEASE v0.3.2 -->
|
||||||
|
## Version 0.3.2
|
||||||
|
|
||||||
|
Caching fix
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
<!-- BEGIN CHANGES 0.3.2-->
|
||||||
|
- Cache busting for profile and product pictures
|
||||||
|
<!-- END CHANGES 0.3.2 -->
|
||||||
|
|
||||||
|
<!-- END RELEASE v0.3.2 -->
|
||||||
|
|
||||||
<!-- BEGIN RELEASE v0.3.1 -->
|
<!-- BEGIN RELEASE v0.3.1 -->
|
||||||
## Version 0.3.1
|
## Version 0.3.1
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
__version__ = '0.3.1'
|
__version__ = '0.3.2'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
|
@ -47,9 +48,10 @@ def admin():
|
||||||
users = db.list_users()
|
users = db.list_users()
|
||||||
products = db.list_products()
|
products = db.list_products()
|
||||||
# Render the "Admin/Settings" page
|
# Render the "Admin/Settings" page
|
||||||
|
now = str(int(datetime.utcnow().timestamp()))
|
||||||
return template.render('admin.html',
|
return template.render('admin.html',
|
||||||
authuser=user, authlevel=authlevel, users=users, products=products,
|
authuser=user, authlevel=authlevel, users=users, products=products,
|
||||||
receipt_preference_class=ReceiptPreference,
|
receipt_preference_class=ReceiptPreference, now=now,
|
||||||
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from bottle import route, redirect
|
from bottle import route, redirect
|
||||||
|
|
||||||
from matemat.db import MatematDatabase
|
from matemat.db import MatematDatabase
|
||||||
|
@ -12,6 +14,7 @@ def main_page():
|
||||||
"""
|
"""
|
||||||
config = get_app_config()
|
config = get_app_config()
|
||||||
session_id: str = session.start()
|
session_id: str = session.start()
|
||||||
|
now = str(int(datetime.utcnow().timestamp()))
|
||||||
with MatematDatabase(config['DatabaseFile']) as db:
|
with MatematDatabase(config['DatabaseFile']) as db:
|
||||||
# Check whether a user is logged in
|
# Check whether a user is logged in
|
||||||
if session.has(session_id, 'authenticated_user'):
|
if session.has(session_id, 'authenticated_user'):
|
||||||
|
@ -26,7 +29,7 @@ def main_page():
|
||||||
# Prepare a response with a jinja2 template
|
# Prepare a response with a jinja2 template
|
||||||
return template.render('productlist.html',
|
return template.render('productlist.html',
|
||||||
authuser=user, users=users, products=products, authlevel=authlevel,
|
authuser=user, users=users, products=products, authlevel=authlevel,
|
||||||
stock=get_stock_provider(), setupname=config['InstanceName'])
|
stock=get_stock_provider(), setupname=config['InstanceName'], now=now)
|
||||||
else:
|
else:
|
||||||
# If there are no admin users registered, jump to the admin creation procedure
|
# If there are no admin users registered, jump to the admin creation procedure
|
||||||
if not db.has_admin_users():
|
if not db.has_admin_users():
|
||||||
|
@ -34,5 +37,5 @@ def main_page():
|
||||||
# If no user is logged in, fetch the list of users and render the userlist template
|
# If no user is logged in, fetch the list of users and render the userlist template
|
||||||
users = db.list_users(with_touchkey=True)
|
users = db.list_users(with_touchkey=True)
|
||||||
return template.render('userlist.html',
|
return template.render('userlist.html',
|
||||||
users=users, setupname=config['InstanceName'],
|
users=users, setupname=config['InstanceName'], now=now,
|
||||||
signup=(config.get('SignupEnabled', '0') == '1'))
|
signup=(config.get('SignupEnabled', '0') == '1'))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from datetime import datetime
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import magic
|
import magic
|
||||||
|
@ -55,9 +56,10 @@ def modproduct():
|
||||||
redirect('/admin')
|
redirect('/admin')
|
||||||
|
|
||||||
# Render the "Modify Product" page
|
# Render the "Modify Product" page
|
||||||
|
now = str(int(datetime.utcnow().timestamp()))
|
||||||
return template.render('modproduct.html',
|
return template.render('modproduct.html',
|
||||||
authuser=authuser, product=product, authlevel=authlevel,
|
authuser=authuser, product=product, authlevel=authlevel,
|
||||||
setupname=config['InstanceName'])
|
setupname=config['InstanceName'], now=now)
|
||||||
|
|
||||||
|
|
||||||
def handle_change(args: FormsDict, files: FormsDict, product: Product, db: MatematDatabase) -> None:
|
def handle_change(args: FormsDict, files: FormsDict, product: Product, db: MatematDatabase) -> None:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
from datetime import datetime
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
|
@ -55,8 +56,9 @@ def moduser():
|
||||||
redirect('/admin')
|
redirect('/admin')
|
||||||
|
|
||||||
# Render the "Modify User" page
|
# Render the "Modify User" page
|
||||||
|
now = str(int(datetime.utcnow().timestamp()))
|
||||||
return template.render('moduser.html',
|
return template.render('moduser.html',
|
||||||
authuser=authuser, user=user, authlevel=authlevel,
|
authuser=authuser, user=user, authlevel=authlevel, now=now,
|
||||||
receipt_preference_class=ReceiptPreference,
|
receipt_preference_class=ReceiptPreference,
|
||||||
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Package: matemat
|
Package: matemat
|
||||||
Version: 0.3.1
|
Version: 0.3.2
|
||||||
Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com>
|
Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com>
|
||||||
Section: web
|
Section: web
|
||||||
Priority: optional
|
Priority: optional
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<h2>Avatar</h2>
|
<h2>Avatar</h2>
|
||||||
|
|
||||||
<form id="admin-avatar-form" method="post" action="/admin?change=avatar" enctype="multipart/form-data" accept-charset="UTF-8">
|
<form id="admin-avatar-form" method="post" action="/admin?change=avatar" enctype="multipart/form-data" accept-charset="UTF-8">
|
||||||
<img src="/static/upload/thumbnails/users/{{ authuser.id }}.png" alt="Avatar of {{ authuser.name }}" /><br/>
|
<img src="/static/upload/thumbnails/users/{{ authuser.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ authuser.name }}" /><br/>
|
||||||
|
|
||||||
<label for="admin-avatar-avatar">Upload new file: </label>
|
<label for="admin-avatar-avatar">Upload new file: </label>
|
||||||
<input id="admin-avatar-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
<input id="admin-avatar-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
<input id="modproduct-balance" name="stock" type="text" value="{{ product.stock }}" /><br/>
|
<input id="modproduct-balance" name="stock" type="text" value="{{ product.stock }}" /><br/>
|
||||||
|
|
||||||
<label for="modproduct-image">
|
<label for="modproduct-image">
|
||||||
<img height="150" src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Image of {{ product.name }}" />
|
<img height="150" src="/static/upload/thumbnails/products/{{ product.id }}.png?cacheBuster={{ now }}" alt="Image of {{ product.name }}" />
|
||||||
</label><br/>
|
</label><br/>
|
||||||
<input id="modproduct-image" type="file" name="image" accept="image/*" /><br/>
|
<input id="modproduct-image" type="file" name="image" accept="image/*" /><br/>
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
<input id="moduser-account-balance-reason" type="text" name="reason" placeholder="Shows up on receipt" /><br/>
|
<input id="moduser-account-balance-reason" type="text" name="reason" placeholder="Shows up on receipt" /><br/>
|
||||||
|
|
||||||
<label for="moduser-account-avatar">
|
<label for="moduser-account-avatar">
|
||||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
<img src="/static/upload/thumbnails/users/{{ user.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ user.name }}" />
|
||||||
</label><br/>
|
</label><br/>
|
||||||
<input id="moduser-account-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
<input id="moduser-account-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
</span><br/>
|
</span><br/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="imgcontainer">
|
<div class="imgcontainer">
|
||||||
<img src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}" draggable="false"/>
|
<img src="/static/upload/thumbnails/products/{{ product.id }}.png?cacheBuster={{ now }}" alt="Picture of {{ product.name }}" draggable="false"/>
|
||||||
{% set pstock = stock.get_stock(product) %}
|
{% set pstock = stock.get_stock(product) %}
|
||||||
{% if pstock is not none %}
|
{% if pstock is not none %}
|
||||||
<span class="thumblist-stock">{{ pstock }}</span>
|
<span class="thumblist-stock">{{ pstock }}</span>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<a href="/touchkey?uid={{ user.id }}&username={{ user.name }}">
|
<a href="/touchkey?uid={{ user.id }}&username={{ user.name }}">
|
||||||
<span class="thumblist-title">{{ user.name }}</span><br/>
|
<span class="thumblist-title">{{ user.name }}</span><br/>
|
||||||
<div class="imgcontainer">
|
<div class="imgcontainer">
|
||||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" draggable="false"/>
|
<img src="/static/upload/thumbnails/users/{{ user.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ user.name }}" draggable="false"/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue