Merge remote-tracking branch 'origin/master'

master
fireworks88 2021-09-17 20:49:55 +02:00
commit 2cd538ae87
8 changed files with 67 additions and 66 deletions

View File

@ -436,7 +436,8 @@ def badge_grant_post(v):
g.db.add(user)
g.db.commit()
g.db.commit()
return redirect("/admin/badge_grant")

View File

@ -200,14 +200,13 @@ ALLOW_MULTIPLE = (
@app.post("/post/<pid>/awards")
@auth_required
@validate_formkey
def award_post(pid, v):
if v.is_suspended and v.unban_utc == 0:
return {"error": "forbidden."}, 403
kind = request.form.get("kind", "")
if kind not in AWARDS:
return {"error": "That award doesn't exist."}, 404
@ -260,12 +259,11 @@ def award_post(pid, v):
g.db.add(post.author)
g.db.commit()
return {"message": "Award given!"}
return redirect(request.referrer)
@app.post("/comment/<cid>/awards")
@auth_required
@validate_formkey
def award_comment(cid, v):
if v.is_suspended and v.unban_utc == 0:
@ -325,7 +323,7 @@ def award_comment(cid, v):
g.db.add(c.author)
g.db.commit()
return {"message": "Award given!"}
return redirect(request.referrer)
@app.get("/admin/user_award")
@auth_required

View File

@ -161,7 +161,7 @@ def api_comment(v):
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
body_md = CustomRenderer().render(mistletoe.Document(body))
@ -607,7 +607,7 @@ def edit_comment(cid, v):
if c.is_banned or c.deleted_utc > 0: abort(403)
body = request.form.get("body", "")[:10000]
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
body_md = CustomRenderer().render(mistletoe.Document(body))

View File

@ -47,17 +47,29 @@ def check_for_alts(current_id):
otheralts = g.db.query(Alt).options(lazyload('*')).filter(or_(Alt.user1 == past_id, Alt.user2 == past_id, Alt.user1 == current_id, Alt.user2 == current_id)).all()
for a in otheralts:
new_alt = Alt(user1=a.user1, user2=past_id)
g.db.add(new_alt)
try:
new_alt = Alt(user1=a.user1, user2=past_id)
g.db.add(new_alt)
g.db.flush()
except: g.db.rollback()
for a in otheralts:
new_alt = Alt(user1=a.user1, user2=current_id)
g.db.add(new_alt)
try:
new_alt = Alt(user1=a.user1, user2=current_id)
g.db.add(new_alt)
g.db.flush()
except: g.db.rollback()
for a in otheralts:
new_alt = Alt(user1=a.user2, user2=past_id)
g.db.add(new_alt)
try:
new_alt = Alt(user1=a.user2, user2=past_id)
g.db.add(new_alt)
g.db.flush()
except: g.db.rollback()
for a in otheralts:
new_alt = Alt(user1=a.user2, user2=current_id)
g.db.add(new_alt)
try:
new_alt = Alt(user1=a.user2, user2=current_id)
g.db.add(new_alt)
g.db.flush()
except: g.db.rollback()
# login post procedure

View File

@ -33,7 +33,7 @@ def toggle_club(pid, v):
post = get_post(pid)
if (post.author_id != v.id or v.club_banned) and not v.admin_level >= 3: abort(403)
if post.author_id != v.id or not v.paid_dues: abort(403)
post.club = not post.club
g.db.add(post)
@ -251,7 +251,7 @@ def edit_post(pid, v):
p.title_html = filter_title(title)
if body != p.body:
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
@ -803,7 +803,7 @@ def submit_post(v):
else: return render_template("submit.html", v=v, error="2048 character limit for URLs.", title=title, url=url,body=request.form.get("body", "")), 400
# render text
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
body_md = CustomRenderer().render(mistletoe.Document(body))
@ -859,9 +859,12 @@ def submit_post(v):
# check for embeddable video
domain = parsed_url.netloc
if v.paid_dues: club = bool(request.form.get("club",""))
else: club = False
new_post = Submission(
private=bool(request.form.get("private","")),
club=bool(request.form.get("club","")),
club=club,
author_id=v.id,
over_18=bool(request.form.get("over_18","")),
app_id=v.client.application.id if v.client else None,

View File

@ -102,7 +102,7 @@ def settings_profile_post(v):
if request.values.get("bio"):
bio = request.values.get("bio")[:1500]
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', bio, re.MULTILINE):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE):
if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})')
bio = bio.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n")
@ -312,6 +312,7 @@ def gumroad(v):
return {"error": f"{patron} rewards already claimed"}, 400
v.patron = tier
g.db.add(v)
grant_awards = {}
if tier == 1:
@ -355,12 +356,12 @@ def gumroad(v):
g.db.bulk_save_objects(_awards)
new_badge = Badge(badge_id=20+tier,
user_id=v.id,
)
g.db.add(new_badge)
if not v.has_badge(20+tier):
new_badge = Badge(badge_id=20+tier,
user_id=v.id,
)
g.db.add(new_badge)
g.db.add(v)
g.db.commit()
return {"message": f"{patron} rewards claimed!"}

View File

@ -1,4 +1,12 @@
<input type="hidden" id="awardTarget" value="" />
<script>
function bruh(kind) {
document.getElementById('giveaward').disabled=false;
document.getElementById('kind').value=kind;
try {document.getElementsByClassName('picked')[0].classList.toggle('picked');} catch(e) {}
document.getElementById(kind).classList.toggle('picked')
}
</script>
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered" role="document">
<div class="modal-content">
@ -9,72 +17,51 @@
</button>
</div>
<div id="awardModalBody" class="modal-body">
<form class="pt-3 pb-0" action="/post/{{p.id}}/awards" method="post">
<form id="awardTarget" class="pt-3 pb-0" action="" method="post">
<div class="card-columns awards-wrapper">
{% for award in v.user_awards %}
<div>
<label class="card" onclick="document.getElementById('desc-{{award.kind}}').classList.toggle('d-none');document.getElementById('giveaward').disabled=false">
<i class="{{award.icon}} {{award.color}}"></i><br />
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px;">{{award.title}}</span>
<span class="text-muted">{{award.owned}} owned</span>
</label>
</div>
<div id="desc-{{award.kind}}" class="d-none">
<div class="award-desc p-3">
<i style="font-size: 35px;"></i>
<div style="margin-left: 15px;">
<strong>{{pickedAward.title}} Award</strong><br />
<span class="text-muted">{{pickedAward.description}}</span>
</div>
</div>
<label for="note" class="pt-4">Note (optional):</label>
<textarea id="note" name="note" class="form-control" placeholder="Note to include in award notification"></textarea>
</div>
<input name="{{award.kind}}" hidden>
<input id="giveaward" class="btn btn-primary" type="submit" value="Give Award" disabled>
<a href="javascript:void(0)" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
<i class="{{award.icon}} {{award.color}}"></i><br />
<span class="d-block pt-2" style="font-weight: bold; font-size: 14px; color:#E1E1E1">{{award.title}}</span>
<span class="text-muted">{{award.owned}} owned</span>
</a>
{% endfor %}
</div>
<label for="note" class="pt-4">Note (optional):</label>
<input id="kind" name="kind" value="" hidden>
<textarea id="note" name="note" class="form-control" placeholder="Note to include in award notification"></textarea>
<input id="giveaward" class="btn btn-primary" style="float:right" type="submit" value="Give Award" disabled>
</form>
</div>
</div>
</div>
</div>
</div>
<style>
.awards-wrapper input[type="radio"] {
display: none;
}
.awards-wrapper label {
.awards-wrapper a {
cursor: pointer;
padding: 15px;
text-align: center;
text-transform: none!important;
}
.awards-wrapper label i {
.awards-wrapper a i {
font-size: 45px;
}
.awards-wrapper label.disabled {
.awards-wrapper a.disabled {
opacity: 0.6;
}
.awards-wrapper label:hover {
/*background-color: rgba(173, 226, 255, 0.7)!important;*/
.awards-wrapper a:hover, .picked {
background-color: var(--primary)!important;
background-opacity: 0.4;
}
.awards-wrapper input[type="radio"]:checked+label {
/*background-color: rgba(173, 226, 255, 0.9)!important;*/
.awards-wrapper input[type="radio"]:checked+a {
background-color: var(--primary)!important;
background-opacity: 0.9;
}
.award-desc {
border-radius: 5px;
background-color: rgba(221, 221, 221, 0.23);
display: flex;
}
</style>

View File

@ -670,8 +670,7 @@
function awardModal(link) {
var target = document.getElementById("awardTarget");
target.value = link;
target.action = link;
}
// Expand Images on Desktop