diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 9f496b2c9..d09a3df5e 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -4079,11 +4079,11 @@ small, .small { .user-name { color: inherit; } -.banner-pic-135 { - object-fit: cover; - height: 135px; - max-width: 572px; - width: 572px; +.banner-pic { + max-width: min(100%, 600px); +} +.profile-background-pic { + max-width: min(100%, 400px); } .profile-pic { width: 50px; @@ -5136,9 +5136,6 @@ pre .com, code .com { } .comment.collapsed .comment-body:hover { opacity: 0.5; -} - .banner-pic-135 { - max-width: 100%; } .x-scroll-parent { overflow: hidden; diff --git a/files/routes/settings.py b/files/routes/settings.py index 5e720bda2..88219b8ce 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -78,39 +78,6 @@ def upload_custom_background(v): return redirect('/settings/personal') -@app.post('/settings/profile_background') -@limiter.limit('1/second', scope=rpath) -@limiter.limit('1/second', scope=rpath, key_func=get_ID) -@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) -@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) -@auth_required -def upload_profile_background(v): - if g.is_tor: abort(403, "Image uploads are not allowed through TOR!") - - file = request.files["file"] - - name = f'/images/{time.time()}'.replace('.','') + '.webp' - file.save(name) - background = process_image(name, v) - - if background: - if v.profile_background and path.isfile(v.profile_background): - remove_media_using_link(v.profile_background) - v.profile_background = background - g.db.add(v) - badge_grant(badge_id=193, user=v) - return redirect(f'/@{v.username}') - -@app.delete('/settings/profile_background') -@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) -@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) -@auth_required -def delete_profile_background(v): - if v.profile_background: - remove_media_using_link(v.profile_background) - v.profile_background = None - return {"message": "Profile background removed!"} - @app.post("/settings/personal") @limiter.limit('1/second', scope=rpath) @limiter.limit('1/second', scope=rpath, key_func=get_ID) @@ -617,6 +584,30 @@ def settings_images_banner(v): return redirect("/settings/personal?msg=Banner successfully updated!") + +@app.post("/settings/images/profile_background") +@limiter.limit('1/second', scope=rpath) +@limiter.limit('1/second', scope=rpath, key_func=get_ID) +@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) +@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) +@auth_required +def settings_images_profile_background(v): + if g.is_tor: abort(403, "Image uploads are not allowed through TOR!") + + file = request.files["profile_background"] + + name = f'/images/{time.time()}'.replace('.','') + '.webp' + file.save(name) + profile_background = process_image(name, v) + + if profile_background: + if v.profile_background and '/images/' in v.profile_background and path.isfile(v.profile_background): + remove_media_using_link(v.profile_background) + v.profile_background = profile_background + g.db.add(v) + + return redirect("/settings/personal?msg=Profile background successfully updated!") + @app.get("/settings/css") @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) @limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index f05a8d030..93859f07b 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -138,7 +138,7 @@