diff --git a/app.py b/app.py index 2dd702b..be8c101 100755 --- a/app.py +++ b/app.py @@ -17,7 +17,8 @@ from functools import lru_cache from urllib.parse import urlparse, unquote from werkzeug.middleware.proxy_fix import ProxyFix import re - +import qrcode +import base64 import search import auth import analytics as a @@ -415,6 +416,7 @@ def get_transcript(subpath): @auth.require_secret def create_share(subpath): scheme = request.scheme # current scheme (http or https) + host = request.host if 'admin ' not in session and not session.get('admin'): return "Unauthorized", 403 @@ -440,20 +442,25 @@ def create_share(subpath): ] } - print (data) - token = auth.generate_secret_key_compressed(data) - - content = f"""Ordner:\\ -{foldername}\\ -\\ -GΓΌltig bis:\\ -{validity_date}\\ -\\ -Link:\\ -`{scheme}://{request.host}?token={token}`""" - return content, 200, {'Content-Type': 'text/markdown; charset=utf-8'} + url = f"{scheme}://{host}?token={token}" + qr = qrcode.QRCode(version=1, box_size=10, border=4) + qr.add_data(url) + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") + buffer = io.BytesIO() + img.save(buffer, format="PNG") + buffer.seek(0) + img_base64 = base64.b64encode(buffer.getvalue()).decode('ascii') + token_item = auth.decode_secret_key_compressed(token) + + return render_template('view_token.html', + token_qr_code=img_base64, + token_folder=token_item.get('folders'), + token_url=url, + token_valid_to=token_item.get('validity', 'Unbekannt') + ) def query_recent_connections(): diff --git a/static/app.css b/static/app.css index 8bfd07f..57c34dc 100644 --- a/static/app.css +++ b/static/app.css @@ -100,17 +100,11 @@ div.directory-item a, li.directory-item a, li.file-item a, li.link-item a { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; -} -.directories-grid .directory-item { - background-color: #fff; - padding: 15px; - border-radius: 5px; text-align: center; - box-shadow: 0 1px 3px rgba(0,0,0,0.1); } /* File Item Styles (for both music and image files) */ -.file-item { +.file-item, .directory-item{ display: grid; grid-template-columns: 1fr auto; align-items: center; diff --git a/static/app.js b/static/app.js index f42c754..5f473e5 100644 --- a/static/app.js +++ b/static/app.js @@ -77,26 +77,30 @@ function renderContent(data) { share_link = ''; // Render directories normally if (data.directories.length > 0) { - const areAllShort = data.directories.every(dir => dir.name.length <= 15) && data.files.length === 0; + const areAllShort = data.directories.every(dir => dir.name.length <= 10) && data.files.length === 0; if (areAllShort && data.breadcrumbs.length !== 1) { contentHTML += '