master
Aevann1 2021-12-14 22:25:57 +02:00
parent c9be301462
commit 481af28e35
7 changed files with 23 additions and 23 deletions

View File

@ -183,7 +183,7 @@ def sanitize(sanitized, noimages=False):
remoji = emoji
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)
@ -193,10 +193,10 @@ def sanitize(sanitized, noimages=False):
if emoji.startswith("!"):
emoji = emoji[1:]
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'):
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")
@ -240,10 +240,10 @@ def filter_emojis_only(title):
if emoji.startswith("!"):
emoji = emoji[1:]
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'):
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)
else: return title

View File

@ -33,7 +33,7 @@ def distribute(v, cid):
for vote in votes:
u = vote.user
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)
autobetter.coins = 0

View File

@ -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
if author.longpost: author.longpost += 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":
if author.longpost:
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
if author.longpost: author.longpost += 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":
if author.longpost:
return {"error": "This user is the under the effect of a conflicting award: Pizzashill award."}, 404

View File

@ -194,7 +194,7 @@ def api_comment(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
body += f"\n\n![]({url})"
@ -724,7 +724,7 @@ def edit_comment(cid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
body += f"\n\n![]({url})"
body_md = CustomRenderer().render(mistletoe.Document(body))

View File

@ -63,12 +63,12 @@ def publish(pid, v):
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)
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:
user = get_account(follow.user_id)
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)
@ -425,7 +425,7 @@ def edit_post(pid, v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
body += f"\n\n![]({url})"
@ -542,7 +542,7 @@ def edit_post(pid, v):
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)
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)
@ -698,7 +698,7 @@ def thumbnail_thread(pid):
for chunk in image_req.iter_content(1024):
file.write(chunk)
post.thumburl = f"https://{site}" + process_image(name, True)
post.thumburl = process_image(name, True)
db.add(post)
db.commit()
db.close()
@ -919,7 +919,7 @@ def submit_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
body += f"\n\n![]({url})"
@ -1019,7 +1019,7 @@ def submit_post(v):
if file.content_type.startswith('image/'):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
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/'):
file.save("video.mp4")

View File

@ -126,7 +126,7 @@ def settings_profile_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
bio += f"\n\n![]({url})"
@ -316,7 +316,7 @@ def settings_profile_post(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
url = request.host_url[:-1] + process_image(name)
url = process_image(name)
bio += f"\n\n![]({url})"
@ -722,13 +722,13 @@ def settings_images_profile(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
highres = request.host_url[:-1] + process_image(name)
highres = process_image(name)
if not highres: abort(400)
name2 = name.replace('.webp', 'r.webp')
copyfile(name, name2)
imageurl = request.host_url + process_image(name2, True)
imageurl = process_image(name2, True)
if not imageurl: abort(400)
@ -758,7 +758,7 @@ def settings_images_banner(v):
name = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
file.save(name)
bannerurl = request.host_url[:-1] + process_image(name)
bannerurl = process_image(name)
if bannerurl:
if v.bannerurl and '/images/' in v.bannerurl : os.remove('images/' + v.bannerurl.split('/images/')[1])

View File

@ -232,7 +232,7 @@ def contact(v):
@auth_required
@validate_formkey
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)
g.db.commit()
return render_template("contact.html", v=v, msg="Your message has been sent.")