allow hole jannies to change the hole marsey + cachebust all site assets

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-25 00:22:44 +02:00
parent 75ad5b34f2
commit 11d7f34ad0
12 changed files with 84 additions and 15 deletions

View File

@ -2,7 +2,7 @@
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/i/icon.webp?v=3000">
<square150x150logo src="/i/icon.webp?v=3009">
<TileColor>#FF66AC</TileColor>
</tile>
</msapplication>

View File

@ -24,13 +24,13 @@ function flash(){
alert=false;
}
else {
icon.href = escapeHTML(`/assets/images/${site_name}/icon.webp?v=3000`)
icon.href = escapeHTML(`/assets/images/${site_name}/icon.webp?v=3009`)
alert=true;
}
setTimeout(flash, 500)
}
else {
icon.href = escapeHTML(`/assets/images/${site_name}/icon.webp?v=3000`)
icon.href = escapeHTML(`/assets/images/${site_name}/icon.webp?v=3009`)
notifs = 0
title.innerHTML = 'Chat';
}

View File

@ -18,6 +18,7 @@ class Sub(Base):
sidebar_html = Column(String)
sidebarurl = Column(String)
bannerurl = Column(String)
marseyurl = Column(String)
css = Column(String)
stealth = Column(Boolean)
@ -31,13 +32,19 @@ class Sub(Base):
@lazy
def sidebar_url(self):
if self.sidebarurl: return SITE_FULL + self.sidebarurl
return f'/i/{SITE_NAME}/sidebar.webp?v=3000'
return f'/i/{SITE_NAME}/sidebar.webp?v=3009'
@property
@lazy
def banner_url(self):
if self.bannerurl: return SITE_FULL + self.bannerurl
return f'/i/{SITE_NAME}/banner.webp?v=3001'
return f'/i/{SITE_NAME}/banner.webp?v=3009'
@property
@lazy
def marsey_url(self):
if self.marseyurl: return SITE_FULL + self.marseyurl
return f'/i/{SITE_NAME}/headericon.webp?v=3009'
@property
@lazy

View File

@ -224,7 +224,7 @@ class Submission(Base):
return self.thumburl
elif self.is_youtube or self.is_video: return f"{SITE_FULL}/assets/images/default_thumb_video.webp?v=1"
elif self.is_audio: return f"{SITE_FULL}/assets/images/default_thumb_audio.webp?v=1"
elif self.domain == SITE: return f"{SITE_FULL}/assets/images/{SITE_NAME}/site_preview.webp?v=3008"
elif self.domain == SITE: return f"{SITE_FULL}/assets/images/{SITE_NAME}/site_preview.webp?v=3009"
else: return f"{SITE_FULL}/assets/images/default_thumb_link.webp?v=1"
@property

View File

@ -607,7 +607,7 @@ class User(Base):
def banner_url(self):
if FEATURES['USERS_PROFILE_BANNER'] and self.bannerurl:
return self.bannerurl
return f"/i/{SITE_NAME}/site_preview.webp?v=3008"
return f"/i/{SITE_NAME}/site_preview.webp?v=3009"
@property
@lazy

View File

@ -113,7 +113,7 @@ if PUSHER_ID != 'blahblahblah':
'title': title,
'body': notifbody,
'deep_link': url,
'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?v=3000',
'icon': f'{SITE_FULL}/assets/images/{SITE_NAME}/icon.webp?v=3009',
}
},
'fcm': {

View File

@ -468,6 +468,32 @@ def sub_sidebar(v, sub):
return redirect(f'/h/{sub.name}/settings')
@app.post("/h/<sub>/marsey_image")
@limiter.limit("1/second;10/day")
@limiter.limit("1/second;10/day", key_func=lambda:f'{SITE}-{session.get("lo_user")}')
@is_not_permabanned
def sub_marsey(v, sub):
if request.headers.get("cf-ipcountry") == "T1": return {"error":"Image uploads are not allowed through TOR."}, 403
sub = g.db.query(Sub).filter_by(name=sub.lower().strip()).one_or_none()
if not sub: abort(404)
if not v.mods(sub.name): abort(403)
file = request.files["marsey"]
name = f'/images/{time.time()}'.replace('.','') + '.webp'
file.save(name)
marseyurl = process_image(name)
if marseyurl:
if sub.marseyurl and '/images/' in sub.marseyurl:
fpath = '/images/' + sub.marseyurl.split('/images/')[1]
if path.isfile(fpath): os.remove(fpath)
sub.marseyurl = marseyurl
g.db.add(sub)
return redirect(f'/h/{sub.name}/settings')
@app.get("/holes")
@auth_desired_with_logingate
def subs(v):

View File

@ -60,7 +60,7 @@
<div class="navbar navbar-expand-md navbar-light" id="navbar">
<div class="container-fluid" style="padding:0;">
<a href="/" class="navbar-brand mr-auto {% if not has_logo and not sub %}flex-grow-1{% endif %}">
<img id="header--icon" alt="header icon" src="{{asset_siteimg('headericon.webp')}}">
<img id="header--icon" alt="header icon" {% if sub %}src="{{sub.marsey_url}}"{% else %}src="{{asset_siteimg('headericon.webp')}}"{% endif %}>
</a>
{% if sub %}

View File

@ -231,7 +231,7 @@
</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}8{% else %}4{% endif %} MB.</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
</div>
@ -266,7 +266,7 @@
</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}8{% else %}4{% endif %} MB.</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
</div>

View File

@ -40,7 +40,7 @@
{% if sub %}
{% set image=sub.sidebar_url %}
{% else %}
{% set image='/i/' + SITE_NAME + '/sidebar.webp?v=3000' %}
{% set image='/i/' + SITE_NAME + '/sidebar.webp?v=3009' %}
{% endif %}
{% if request.path != '/sidebar' %}

View File

@ -40,6 +40,42 @@
<span class="text-small text-muted">Hide posts in this hole from the main feed by default (users can opt-in to see it there).</span>
</div>
<h2 class="h5 mt-5">Marsey</h2>
<div class="settings-section rounded">
<div class="d-flex">
<div class="title w-lg-25 text-md-center">
<img loading="lazy" alt="sub marsey picture" src="{{sub.marsey_url}}" class="profile-pic-75">
</div>
<div class="body w-lg-100 my-auto">
<div class="d-flex">
<div>
<form action="/h/{{sub.name}}/marsey_image" method="post" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}">
<label class="btn btn-secondary text-capitalize mr-2 mb-0">
Update<input autocomplete="off" type="file" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} hidden name="marsey" onchange="form.submit()">
</label>
</form>
</div>
</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
</div>
</div>
</div>
<h2 class="h5 mt-5">Sidebar Picture</h2>
<div class="settings-section rounded">
@ -66,7 +102,7 @@
</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}8{% else %}4{% endif %} MB.</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
</div>
@ -102,7 +138,7 @@
</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}8{% else %}4{% endif %} MB.</div>
<div class="text-small text-muted mt-3">JPG, PNG, GIF files are supported. Max file size is {% if v and v.patron %}16{% else %}8{% endif %} MB.</div>
</div>

View File

@ -40,5 +40,5 @@ set CACHE_VER = {
{%- endmacro -%}
{%- macro asset_siteimg(name) -%}
/i/{{SITE_NAME}}/{{name}}?v=3000
/i/{{SITE_NAME}}/{{name}}?v=3009
{%- endmacro -%}