Release v2.0: URL upload, BBCode sharing, QR codes

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-07 02:36:59 +03:00
parent 49abcc20b4
commit d4f0eaa7d9
11 changed files with 646 additions and 42 deletions
+41 -7
View File
@@ -21,7 +21,7 @@ from app.folder_utils import can_edit_folder
from app.models import Folder, Photo
from app.settings_service import get_settings
from app.storage_service import delete_photo_file, get_photo_stream
from app.upload_service import process_uploads
from app.upload_service import process_uploads, process_url_uploads
from sqlalchemy import text
bp = Blueprint("main", __name__)
@@ -64,12 +64,24 @@ def upload():
if not can_edit_folder(folder):
abort(403)
result = process_uploads(
request.files,
current_user,
folder,
current_app.config["ALLOWED_EXTENSIONS"],
)
image_urls = request.form.get("image_urls", "").strip()
max_upload_mb = current_app.config["MAX_CONTENT_LENGTH"] // (1024 * 1024)
if image_urls:
result = process_url_uploads(
image_urls,
current_user,
folder,
current_app.config["ALLOWED_EXTENSIONS"],
max_upload_mb,
)
else:
result = process_uploads(
request.files,
current_user,
folder,
current_app.config["ALLOWED_EXTENSIONS"],
)
if result["uploaded"] == 0 and result["errors"]:
flash(result["errors"][0], "error")
@@ -115,6 +127,28 @@ def api_photos():
)
@bp.route("/photo/<int:photo_id>/qr")
def photo_qr(photo_id):
import io
import qrcode
from app.share_utils import photo_absolute_url
photo = Photo.query.get_or_404(photo_id)
target = photo_absolute_url(photo, request.url_root)
qr = qrcode.QRCode(box_size=8, border=2)
qr.add_data(target)
qr.make(fit=True)
img = qr.make_image(fill_color="black", back_color="white")
buf = io.BytesIO()
img.save(buf, format="PNG")
buf.seek(0)
return send_file(buf, mimetype="image/png", download_name=f"photo-{photo.id}-qr.png")
@bp.route("/uploads/<path:filename>")
def uploaded_file(filename):
photo = Photo.query.filter_by(filename=filename).first()