fdsfsd
This commit is contained in:
parent
0abd7a566f
commit
d7f99d1a0e
7 changed files with 23 additions and 23 deletions
|
@ -183,7 +183,7 @@ def sanitize(sanitized, noimages=False):
|
||||||
remoji = emoji
|
remoji = emoji
|
||||||
|
|
||||||
if path.isfile(f'./files/assets/images/emojis/{remoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{remoji}.webp'):
|
||||||
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" {classes}src="https://{site}/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
new = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" {classes}src="/assets/images/emojis/{remoji}.webp" >', new, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace(old, new)
|
sanitized = sanitized.replace(old, new)
|
||||||
|
|
||||||
|
@ -193,10 +193,10 @@ def sanitize(sanitized, noimages=False):
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 class="emoji mirrored" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
sanitized = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 class="emoji mirrored" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="https://{site}/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||||
|
|
||||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
||||||
|
|
||||||
|
@ -240,10 +240,10 @@ def filter_emojis_only(title):
|
||||||
if emoji.startswith("!"):
|
if emoji.startswith("!"):
|
||||||
emoji = emoji[1:]
|
emoji = emoji[1:]
|
||||||
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 src="https://{site}/assets/images/emojis/{emoji}.webp" class="emoji mirrored">', title, flags=re.I)
|
title = re.sub(f'(?<!"):!{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!{emoji}: emoji" title=":!{emoji}:" delay="0" height=30 src="/assets/images/emojis/{emoji}.webp" class="emoji mirrored">', title, flags=re.I)
|
||||||
|
|
||||||
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
|
||||||
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="https://{site}/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
title = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}: emoji" title=":{emoji}:" delay="0" height=30 class="emoji" src="/assets/images/emojis/{emoji}.webp">', title, flags=re.I)
|
||||||
|
|
||||||
if len(title) > 1500: abort(400)
|
if len(title) > 1500: abort(400)
|
||||||
else: return title
|
else: return title
|
|
@ -33,7 +33,7 @@ def distribute(v, cid):
|
||||||
for vote in votes:
|
for vote in votes:
|
||||||
u = vote.user
|
u = vote.user
|
||||||
u.coins += coinsperperson
|
u.coins += coinsperperson
|
||||||
send_notification(u.id, f"You won {coinsperperson} coins betting on https://{request.host}{post} !")
|
send_notification(u.id, f"You won {coinsperperson} coins betting on {post} !")
|
||||||
g.db.add(u)
|
g.db.add(u)
|
||||||
|
|
||||||
autobetter.coins = 0
|
autobetter.coins = 0
|
||||||
|
|
|
@ -585,7 +585,7 @@ def award_post(pid, v):
|
||||||
return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
|
return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
|
||||||
if author.longpost: author.longpost += 86400
|
if author.longpost: author.longpost += 86400
|
||||||
else: author.longpost = time.time() + 86400
|
else: author.longpost = time.time() + 86400
|
||||||
send_notification(IDIO_ID, f"@{v.username} used {kind} award on {request.host_url}{post.shortlink}")
|
send_notification(IDIO_ID, f"@{v.username} used {kind} award on [{post.shortlink}]({post.shortlink})")
|
||||||
elif kind == "bird":
|
elif kind == "bird":
|
||||||
if author.longpost:
|
if author.longpost:
|
||||||
return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
|
return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
|
||||||
|
@ -747,7 +747,7 @@ def award_comment(cid, v):
|
||||||
return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
|
return {"error": "This user is the under the effect of a conflicting award: Bird Site award."}, 404
|
||||||
if author.longpost: author.longpost += 86400
|
if author.longpost: author.longpost += 86400
|
||||||
else: author.longpost = time.time() + 86400
|
else: author.longpost = time.time() + 86400
|
||||||
send_notification(IDIO_ID, f"@{v.username} used {kind} award on {request.host_url}{c.shortlink}")
|
send_notification(IDIO_ID, f"@{v.username} used {kind} award on [{c.shortlink}]({c.shortlink})")
|
||||||
elif kind == "bird":
|
elif kind == "bird":
|
||||||
if author.longpost:
|
if author.longpost:
|
||||||
return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
|
return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404
|
||||||
|
|
|
@ -194,7 +194,7 @@ def api_comment(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
body += f"\n\n"
|
body += f"\n\n"
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
body += f"\n\n"
|
body += f"\n\n"
|
||||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||||
|
|
|
@ -63,12 +63,12 @@ def publish(pid, v):
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).filter_by(username=username).first()
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
||||||
|
|
||||||
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: https://{site}{post.permalink}")
|
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: [{post.title}]({post.permalink})")
|
||||||
|
|
||||||
for follow in v.followers:
|
for follow in v.followers:
|
||||||
user = get_account(follow.user_id)
|
user = get_account(follow.user_id)
|
||||||
if post.club and not user.club_allowed: continue
|
if post.club and not user.club_allowed: continue
|
||||||
send_notification(user.id, f"@{v.username} has made a new post: [{post.title}](https://{site}{post.permalink})", True)
|
send_notification(user.id, f"@{v.username} has made a new post: [{post.title}]({post.permalink})", True)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
cache.delete_memoized(frontlist)
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ def edit_post(pid, v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
body += f"\n\n"
|
body += f"\n\n"
|
||||||
|
|
||||||
|
@ -542,7 +542,7 @@ def edit_post(pid, v):
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
user = g.db.query(User).filter_by(username=username).first()
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
||||||
|
|
||||||
message = f"@{v.username} has mentioned you: https://{site}{p.permalink}"
|
message = f"@{v.username} has mentioned you: [{p.title}]({p.permalink})"
|
||||||
|
|
||||||
for x in notify_users: send_notification(x, message)
|
for x in notify_users: send_notification(x, message)
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ def thumbnail_thread(pid):
|
||||||
for chunk in image_req.iter_content(1024):
|
for chunk in image_req.iter_content(1024):
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
|
|
||||||
post.thumburl = f"https://{site}" + process_image(name, True)
|
post.thumburl = process_image(name, True)
|
||||||
db.add(post)
|
db.add(post)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
@ -919,7 +919,7 @@ def submit_post(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
body += f"\n\n"
|
body += f"\n\n"
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ def submit_post(v):
|
||||||
if file.content_type.startswith('image/'):
|
if file.content_type.startswith('image/'):
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
new_post.url = request.host_url[:-1] + process_image(name)
|
new_post.url = process_image(name)
|
||||||
|
|
||||||
elif file.content_type.startswith('video/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
|
|
|
@ -126,7 +126,7 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
bio += f"\n\n"
|
bio += f"\n\n"
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ def settings_profile_post(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = process_image(name)
|
||||||
|
|
||||||
bio += f"\n\n"
|
bio += f"\n\n"
|
||||||
|
|
||||||
|
@ -722,13 +722,13 @@ def settings_images_profile(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
highres = request.host_url[:-1] + process_image(name)
|
highres = process_image(name)
|
||||||
|
|
||||||
if not highres: abort(400)
|
if not highres: abort(400)
|
||||||
|
|
||||||
name2 = name.replace('.webp', 'r.webp')
|
name2 = name.replace('.webp', 'r.webp')
|
||||||
copyfile(name, name2)
|
copyfile(name, name2)
|
||||||
imageurl = request.host_url + process_image(name2, True)
|
imageurl = process_image(name2, True)
|
||||||
|
|
||||||
if not imageurl: abort(400)
|
if not imageurl: abort(400)
|
||||||
|
|
||||||
|
@ -758,7 +758,7 @@ def settings_images_banner(v):
|
||||||
|
|
||||||
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
bannerurl = request.host_url[:-1] + process_image(name)
|
bannerurl = process_image(name)
|
||||||
|
|
||||||
if bannerurl:
|
if bannerurl:
|
||||||
if v.bannerurl and '/images/' in v.bannerurl : os.remove('images/' + v.bannerurl.split('/images/')[1])
|
if v.bannerurl and '/images/' in v.bannerurl : os.remove('images/' + v.bannerurl.split('/images/')[1])
|
||||||
|
|
|
@ -232,7 +232,7 @@ def contact(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
@validate_formkey
|
@validate_formkey
|
||||||
def submit_contact(v):
|
def submit_contact(v):
|
||||||
message = f'This message has been sent automatically to all admins via https://{site}/contact, user email is "{v.email}"\n\nMessage:\n\n' + request.values.get("message", "")
|
message = f'This message has been sent automatically to all admins via [/contact](/contact), user email is "{v.email}"\n\nMessage:\n\n' + request.values.get("message", "")
|
||||||
send_admin(v.id, message)
|
send_admin(v.id, message)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return render_template("contact.html", v=v, msg="Your message has been sent.")
|
return render_template("contact.html", v=v, msg="Your message has been sent.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue