Merge remote-tracking branch 'origin/master'

remotes/1693045480750635534/spooky-22
fireworks88 2021-08-22 22:03:15 +02:00
commit 83954f5a0e
6 changed files with 49 additions and 24 deletions

View File

@ -1,23 +1,37 @@
from sqlalchemy import *
from sqlalchemy.orm import relationship
from files.__main__ import Base
from os import environ
AWARDS = {
"ban": {
"kind": "ban",
"title": "One-Day Ban",
"description": "Ban the author for a day.",
"icon": "fas fa-gavel",
"color": "text-danger"
},
"shit": {
"kind": "shit",
"title": "Shitpost",
"description": "Let OP know how much their post sucks ass. Flies will swarm their idiotic post. (flies only work on posts lol!!)",
"icon": "fas fa-poop",
"color": "text-black-50"
site_name = environ.get("SITE_NAME").strip()
if site_name == "Drama":
AWARDS = {
"ban": {
"kind": "ban",
"title": "One-Day Ban",
"description": "Ban the author for a day.",
"icon": "fas fa-gavel",
"color": "text-danger"
},
"shit": {
"kind": "shit",
"title": "Shitpost",
"description": "Let OP know how much their post sucks ass. Flies will swarm their idiotic post. (flies only work on posts lol!!)",
"icon": "fas fa-poop",
"color": "text-black-50"
}
}
else:
AWARDS = {
"shit": {
"kind": "shit",
"title": "Shitpost",
"description": "Let OP know how much their post sucks ass. Flies will swarm their idiotic post. (flies only work on posts lol!!)",
"icon": "fas fa-poop",
"color": "text-black-50"
}
}
}
class AwardRelationship(Base):

View File

@ -172,22 +172,26 @@ def sanitize(sanitized):
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'):
sanitized = sanitized.replace(f':{i.group(1)}:', f'<img data-toggle="tooltip" title="{i.group(1)}" delay="0" height=30 src="https://{site}/assets/images/emojis/{i.group(1)}.gif"<span>')
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/embed/").replace("https://music.youtube.com/watch?v=", "https://youtube.com/embed/").replace("/watch?v=", "/embed/").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/embed/")
for i in re.finditer('<a href="(https://(streamable|youtube).com/(e|embed)/.*?)"', sanitized):
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.", "https://").replace("https://m.", "https://")
for i in re.finditer('" target="_blank">(https://youtube.com/watch\?v\=.*?)</a>', sanitized):
url = i.group(1)
replacing = f'<a href="{url}" target="_blank">{url}</a>'
htmlsource = f'<div style="padding-top:5px; padding-bottom: 10px;"><iframe frameborder="0" src="{url}?controls=0"></iframe></div>'
sanitized = sanitized.replace(replacing, htmlsource.replace("watch?v=", "embed/"))
for i in re.finditer('<a href="(https://streamable.com/e/.*?)"', sanitized):
url = i.group(1)
replacing = f'<a href="{url}" target="_blank">{url}</a>'
htmlsource = f'<div style="padding-top:5px; padding-bottom: 10px;"><iframe frameborder="0" src="{url}?controls=0"></iframe></div>'
sanitized = sanitized.replace(replacing, htmlsource)
for i in re.finditer('<a href="(https://open.spotify.com/embed/.*?)"', sanitized):
url = i.group(1)
replacing = f'<a href="{url}" target="_blank">{url}</a>'
htmlsource = f'<iframe src="{url}" width="100%" height="80" frameBorder="0" allowtransparency="true" allow="encrypted-media"></iframe>'
sanitized = sanitized.replace(replacing, htmlsource)
sanitized = sanitized.replace("https://mobile.twitter.com", "https://twitter.com")
for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
sanitized = sanitized.replace(rd, "https://old.reddit.com/")

View File

@ -884,6 +884,9 @@ def submit_post(v):
g.db.add(c)
g.db.flush()
new_post.comment_count = g.db.query(Comment).filter_by(parent_submission=new_post.id).count()
g.db.add(new_post)
if "rdrama" in request.host:
if v.id == 995: body = "fuck off carp"
else: body = random.choice(snappyquotes)

View File

@ -24,7 +24,11 @@ tiers={
"(Paypig)": 1,
"(Renthog)": 2,
"(Landchad)": 3,
"(Terminally online turboautist)": 4
"(Terminally online turboautist)": 4,
"(Ape)": 1,
"(Monke)": 2,
"(Gigachad)": 3,
"(Ascended Griller)": 4
}
@app.post("/settings/removebackground")

View File

@ -44,7 +44,7 @@ def participation_stats(v):
@auth_desired
def patrons(v):
if v and v.is_banned and not v.unban_utc: return render_template("seized.html")
users = [x for x in g.db.query(User).filter(User.patron > 0).order_by(User.patron.desc()).all()]
users = g.db.query(User).options(lazyload('*')).filter(User.patron > 0).order_by(User.patron.desc()).all()
return render_template("patrons.html", v=v, users=users)
@app.get("/admins")

View File

@ -1034,7 +1034,7 @@
<body id="{% if request.path != '/comments' %}{% block pagetype %}frontpage{% endblock %}{% endif %}" style="overflow-x: hidden; {% if v and v.background %} background:url(/assets/images/backgrounds/{{v.background}}) no-repeat center center fixed !important; background-size: cover!important; background-color: #000!important;{% endif %}">
<a href="https://secure.transequality.org/site/Donation2?df_id=1480"><img src="/assets/images/{{'SITE_NAME' | app_config}}/{% if v %}banner.gif{% else %}cached.gif{% endif %}" style="padding:4px;" width="100%"></a>
<a href="{% if 'rdrama' in request.host %}https://secure.transequality.org/site/Donation2?df_id=1480{% else %}/{% endif %}"><img src="/assets/images/{{'SITE_NAME' | app_config}}/{% if v %}banner.gif{% else %}cached.gif{% endif %}" style="padding:4px;" width="100%"></a>
{% include "header.html" %}