forked from rDrama/rDrama
move profile background to the settings for consistency + improve banner-pic a bit
parent
a469a4bf52
commit
407eabf8f5
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
<label for="banner">Banner</label>
|
||||
</div>
|
||||
<div class="title w-lg-75 text-md-center">
|
||||
<img loading="lazy" alt="your banner" src="{{v.banner_url}}" class="banner-pic-135">
|
||||
<img loading="lazy" alt="your banner" src="{{v.banner_url}}" class="banner-pic">
|
||||
</div>
|
||||
<div class="body w-lg-100 my-auto">
|
||||
<div class="d-flex">
|
||||
|
@ -155,6 +155,31 @@
|
|||
</div>
|
||||
</div>
|
||||
{%- endif %}
|
||||
|
||||
<div class="d-lg-flex border-bottom">
|
||||
<div class="title w-lg-25">
|
||||
<label for="profile_background">Profile Background</label>
|
||||
</div>
|
||||
{% if v.profile_background %}
|
||||
<div class="title w-lg-75 text-md-center">
|
||||
<img loading="lazy" alt="your profile background" src="{{v.profile_background}}" class="profile-background-pic">
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="body w-lg-100 my-auto">
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
<form action="/settings/images/profile_background" method="post" enctype="multipart/form-data">
|
||||
<input hidden name="formkey" value="{{v|formkey}}">
|
||||
<label class="btn btn-secondary text-capitalize mr-2 mb-0">
|
||||
Update<input autocomplete="off" type="file" {% if g.is_tor %}disabled{% endif %} accept="image/*" hidden name="profile_background" data-nonce="{{g.nonce}}" onchange_submit>
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-small text-muted mt-3">All image files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-lg-flex border-bottom">
|
||||
<div class="title w-lg-25">
|
||||
<label for="name">Username</label>
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
{% for banner in sub.banner_urls %}
|
||||
<section id="sub-banner-update-{{loop.index - 1}}" class="d-flex sub-settings-subsection">
|
||||
<div class="title w-lg-75">
|
||||
<img loading="lazy" alt="/h/{{sub.name}} banner" src="{{banner}}" class="banner-pic-135 sub-banner-preview sub-banner-{{sub.name}}">
|
||||
<img loading="lazy" alt="/h/{{sub.name}} banner" src="{{banner}}" class="banner-pic sub-banner-preview sub-banner-{{sub.name}}">
|
||||
</div>
|
||||
<div class="body w-lg-100 my-auto">
|
||||
<div class="d-flex">
|
||||
|
|
|
@ -222,30 +222,6 @@
|
|||
<i id="toggle-anthem-icon" class="fas fa-music mr-1"></i> Profile Anthem
|
||||
</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.id == u.id %}
|
||||
<form id="upload-profile-background" action="/settings/profile_background" method="post" enctype="multipart/form-data">
|
||||
<input hidden name="formkey" value="{{v|formkey}}">
|
||||
<label class="btn btn-primary" for="upload-profile-background-file" style="margin-bottom:0!important">
|
||||
<i class="fas fa-image mr-1"></i>
|
||||
{% if v.profile_background -%}
|
||||
{{v.profile_background.split('/')[-1]}}
|
||||
{% else -%}
|
||||
Upload Profile Background
|
||||
{% endif %}
|
||||
</label>
|
||||
<input autocomplete="off" id="upload-profile-background-file" accept="image/*", type="file" name="file" data-nonce="{{g.nonce}}" onchange_submit hidden>
|
||||
</form>
|
||||
|
||||
{% if v.profile_background -%}
|
||||
<div class="d-flex mb-3">
|
||||
<button type="button" class="btn btn-danger" data-nonce="{{g.nonce}}" data-onclick="postToastReload(this,'/settings/profile_background', 'DELETE')">
|
||||
<i class="fas fa-image-slash mr-1"></i>
|
||||
Remove current background
|
||||
</button>
|
||||
</div>
|
||||
{%- endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="mt-3" id="profile--info">
|
||||
|
@ -479,34 +455,6 @@
|
|||
</button>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.id == u.id %}
|
||||
<div>
|
||||
<form class="mt-3" id="upload-profile-background-mobile" action="/settings/profile_background" method="post" enctype="multipart/form-data">
|
||||
<input hidden name="formkey" value="{{v|formkey}}">
|
||||
<label class="btn btn-primary text-break" for="upload-profile-background-file-mobile" style="margin-bottom:0!important">
|
||||
<i class="fas fa-image mr-1"></i>
|
||||
{% if v.profile_background %}
|
||||
{{v.profile_background.split('/')[-1]}}
|
||||
{% else %}
|
||||
Upload Profile Background
|
||||
{% endif %}
|
||||
</label>
|
||||
<input autocomplete="off" id="upload-profile-background-file-mobile" accept="image/*", type="file" name="file" data-nonce="{{g.nonce}}" onchange_submit hidden>
|
||||
</form>
|
||||
|
||||
{% if v.profile_background -%}
|
||||
<div class="d-block mt-3">
|
||||
<button type="button" class="btn btn-danger" data-nonce="{{g.nonce}}" data-onclick="postToastReload(this,'/settings/profile_background', 'DELETE')">
|
||||
<i class="fas fa-image-slash mr-1"></i>
|
||||
Remove current background
|
||||
</button>
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<br>
|
||||
{% endif %}
|
||||
|
||||
{% if v and v.id != u.id %}
|
||||
<button type="button" id="button-unsub2" class="btn btn-secondary {% if not is_following %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unfollow/{{u.username}}','button-unsub2','button-sub2','d-none')">Unfollow</button>
|
||||
|
||||
|
|
Loading…
Reference in New Issue