This commit is contained in:
Aevann1 2021-11-30 15:09:17 +02:00
parent 9552e3b01b
commit 71325bcf57
10 changed files with 53 additions and 29 deletions

View file

@ -16,6 +16,9 @@ const EMOJIS_STRINGS = [
marseysob: ['cry','tear'], marseysob: ['cry','tear'],
marseytears: ['cry','sob'], marseytears: ['cry','sob'],
marseycarpcrying: ['fish','sob','tear'], marseycarpcrying: ['fish','sob','tear'],
marseyfeelsgood:[ 'happy','pepe'],
marseyhomofascist: ['kiss'],
marseycapy: ['happy','aevann','rodent']
}, },
emojis: ['marseylaugh','marseyblowkiss','marseyshook','marseythumbsup','marseylove','marseyreading','marseywave','marseyjamming','marseyready','marseyscarf','marseymad','marseycry','marseyinabox','marseysad','marseyexcited','marseysleep','marseyangel','marseydead','marseyparty','marseyrain','marseyagree','marseydisagree','marseyjam','marseygasp','marseytwerking','marseysipping','marseyshrug','marseyglow','marseycope','marseyseethe','marseymerchant','marseyno','marseywalking','marseyhearts','marseybegging','marseytrans2','marseygigaretard','marseysneed','marseybaited','marseyeyeroll','marseydepressed','marseypat','marseyking','marseylong1','marseylong2','marseylong3', emojis: ['marseylaugh','marseyblowkiss','marseyshook','marseythumbsup','marseylove','marseyreading','marseywave','marseyjamming','marseyready','marseyscarf','marseymad','marseycry','marseyinabox','marseysad','marseyexcited','marseysleep','marseyangel','marseydead','marseyparty','marseyrain','marseyagree','marseydisagree','marseyjam','marseygasp','marseytwerking','marseysipping','marseyshrug','marseyglow','marseycope','marseyseethe','marseymerchant','marseyno','marseywalking','marseyhearts','marseybegging','marseytrans2','marseygigaretard','marseysneed','marseybaited','marseyeyeroll','marseydepressed','marseypat','marseyking','marseylong1','marseylong2','marseylong3',

View file

@ -20,18 +20,9 @@ document.addEventListener("DOMContentLoaded", function () {
const userName = document.getElementById("username-register").value; const userName = document.getElementById("username-register").value;
const id = document.getElementById("usernameHelpRegister"); const id = document.getElementById("usernameHelpRegister");
const API = '/is_available/' + userName; if (/[^a-zA-Z0-9_\-$]/.test(userName)) {
if (userName.length >= 3) { id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">No special characters or spaces allowed.</span>';
fetch(API) } else {
.then(res => res.json())
.then(json => {
if (!json[userName]) {
id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">Username already taken :(</span>';
}
})
}
if (!/[^a-zA-Z0-9_\-$]/.test(userName)) {
id.innerHTML = '<span class="form-text font-weight-bold text-success mt-1">Username is a-okay!</span>'; id.innerHTML = '<span class="form-text font-weight-bold text-success mt-1">Username is a-okay!</span>';
if (userName.length < 3) { if (userName.length < 3) {
@ -39,10 +30,16 @@ document.addEventListener("DOMContentLoaded", function () {
} else if (userName.length > 25) { } else if (userName.length > 25) {
id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">Username must be 25 characters or less.</span>'; id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">Username must be 25 characters or less.</span>';
} }
} else { else {
id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">No special characters or spaces allowed.</span>'; fetch('/is_available/' + userName)
.then(res => res.json())
.then(json => {
if (!json[userName]) {
id.innerHTML = '<span class="form-text font-weight-bold text-danger mt-1">Username already taken :(</span>';
}
})
}
} }
}); });
}); });

View file

@ -95,7 +95,7 @@ class ModAction(Base):
elif self.target_post: elif self.target_post:
if self.target_post.club: return f'<a href="{self.target_post.permalink}">{cc.upper()} ONLY</a>' if self.target_post.club: return f'<a href="{self.target_post.permalink}">{cc.upper()} ONLY</a>'
return f'<a href="{self.target_post.permalink}">{self.target_post.title.replace("<","").replace(">","")}</a>' return f'<a href="{self.target_post.permalink}">{self.target_post.title.replace("<","").replace(">","")}</a>'
elif self.target_comment_id: return f'<a href="/comment/{self.target_comment_id}">comment</a>' elif self.target_comment_id: return f'<a href="/comment/{self.target_comment_id}?context=9#context">comment</a>'
@property @property
@lazy @lazy

View file

@ -167,6 +167,24 @@ def front_all(v):
g.db.add(v) g.db.add(v)
g.db.commit() g.db.commit()
if v.marseyawarded and v.marseyawarded < time.time():
v.marseyawarded = None
send_notification(v.id, "Your marsey award has expired!")
g.db.add(v)
g.db.commit()
if v.longpost and v.longpost < time.time():
v.longpost = None
send_notification(v.id, "Your pizzashill award has expired!")
g.db.add(v)
g.db.commit()
if v.bird and v.bird < time.time():
v.bird = None
send_notification(v.id, "Your bird site award has expired!")
g.db.add(v)
g.db.commit()
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
else: return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page) else: return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)

View file

@ -155,6 +155,13 @@ def settings_profile_post(v):
msg="Your bio has been updated.") msg="Your bio has been updated.")
elif request.values.get("bio") == "":
v.bio = None
v.bio_html = None
g.db.add(v)
g.db.commit()
return render_template("settings_profile.html", v=v, msg="Your bio has been updated.")
elif request.values.get("sig") == "": elif request.values.get("sig") == "":
v.sig = None v.sig = None
v.sig_html = None v.sig_html = None

View file

@ -454,12 +454,12 @@ def api_is_available(name, v):
if len(name)<3 or len(name)>25: if len(name)<3 or len(name)>25:
return {name:False} return {name:False}
name=name.replace('_','\_') name2 = name.replace('_','\_')
x= g.db.query(User).filter( x= g.db.query(User).filter(
or_( or_(
User.username.ilike(name), User.username.ilike(name2),
User.original_username.ilike(name) User.original_username.ilike(name2)
) )
).first() ).first()
@ -468,7 +468,6 @@ def api_is_available(name, v):
else: else:
return {name: True} return {name: True}
@app.get("/id/<id>") @app.get("/id/<id>")
def user_id(id): def user_id(id):
@ -556,12 +555,12 @@ def u_username(username, v=None):
else: return render_template("userpage_private.html", time=int(time.time()), u=u, v=v) else: return render_template("userpage_private.html", time=int(time.time()), u=u, v=v)
if hasattr(u, 'is_blocking') and u.is_blocking and (not v or v.admin_level < 2): if v and hasattr(u, 'is_blocking') and u.is_blocking:
if request.headers.get("Authorization"): return {"error": f"You are blocking @{u.username}."} if request.headers.get("Authorization"): return {"error": f"You are blocking @{u.username}."}
else: return render_template("userpage_blocking.html", u=u, v=v) else: return render_template("userpage_blocking.html", u=u, v=v)
if hasattr(u, 'is_blocked') and u.is_blocked and (not v or v.admin_level < 2): if v and v.admin_level < 2 and hasattr(u, 'is_blocked') and u.is_blocked:
if request.headers.get("Authorization"): return {"error": "This person is blocking you."} if request.headers.get("Authorization"): return {"error": "This person is blocking you."}
else: return render_template("userpage_blocked.html", u=u, v=v) else: return render_template("userpage_blocked.html", u=u, v=v)

View file

@ -207,7 +207,7 @@
{{single_comment(reply, level=level+1)}} {{single_comment(reply, level=level+1)}}
{% endfor %} {% endfor %}
</div> </div>
{% elif "notifications" in request.path %} {% elif replies and "notifications" in request.path %}
<div id="replies-of-{{c.id}}" class="d-none d-md-block"> <div id="replies-of-{{c.id}}" class="d-none d-md-block">
{% set standalone=False %} {% set standalone=False %}
{% for reply in replies %} {% for reply in replies %}
@ -579,7 +579,7 @@
{{single_comment(reply, level=level+1)}} {{single_comment(reply, level=level+1)}}
{% endfor %} {% endfor %}
</div> </div>
{% elif "notifications" in request.path %} {% elif replies and "notifications" in request.path %}
<div id="replies-of-{{c.id}}" class="d-none d-md-block"> <div id="replies-of-{{c.id}}" class="d-none d-md-block">
{% set standalone=False %} {% set standalone=False %}
{% for reply in replies %} {% for reply in replies %}

View file

@ -1,4 +1,4 @@
<script src="/assets/js/emoji_modal.js?v=120"></script> <script src="/assets/js/emoji_modal.js?v=121"></script>
<style> <style>
a.emojitab { a.emojitab {

View file

@ -4,7 +4,7 @@
<head> <head>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"></script>
<script src="/assets/js/signup.js?v=53"></script> <script src="/assets/js/signup.js?v=63"></script>
{% if hcaptcha %} {% if hcaptcha %}
<script src="https://hcaptcha.com/1/api.js"></script> <script src="https://hcaptcha.com/1/api.js"></script>
@ -89,7 +89,7 @@
<label for="username-register" class="mt-3">Username</label> <label for="username-register" class="mt-3">Username</label>
<input class="form-control" id="username-register" <input class="form-control" id="username-register"
aria-describedby="usernameHelpRegister" type="text" name="username" pattern="[a-zA-Z0-9_\-]{3,25}" required=""> aria-describedby="usernameHelpRegister" type="text" name="username" pattern="[a-zA-Z0-9_\-]{3,25}" min="3" max="25" required="">
<small id="usernameHelpRegister"></small> <small id="usernameHelpRegister"></small>
<label for="email-register" class="mt-3">Email Address</label> <label for="email-register" class="mt-3">Email Address</label>

View file

@ -147,7 +147,7 @@
</span> </span>
{% endif %} {% endif %}
{% if v and v.has_follower(u) %} {% if v and v.has_follower(u) %}
<span class="followsyou text-primary badge badge-secondary text-small align-middle ml-2">Follows you</span> <span class="followsyou badge badge-secondary text-small align-middle ml-2">Follows you</span>
{% endif %} {% endif %}
<div class="profile-actions align-middle d-none ml-2"> <div class="profile-actions align-middle d-none ml-2">
{% if v and v.id != u.id %} {% if v and v.id != u.id %}
@ -446,7 +446,7 @@
</span> </span>
{% endif %} {% endif %}
{% if v and v.has_follower(u) and not v.is_nofollow %} {% if v and v.has_follower(u) and not v.is_nofollow %}
<span class="followsyou text-primary badge badge-secondary text-small align-middle mx-1">Follows you</span> <span class="followsyou badge badge-secondary text-small align-middle mx-1">Follows you</span>
{% endif %} {% endif %}
{% if u.customtitle %}<p style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/quadrants/{{u.quadrant}}.webp?v=1">{% endif %}{{u.customtitle | safe}}</p> {% if u.customtitle %}<p style="color: #{{u.titlecolor}}">{% if u.quadrant %}<img loading="lazy" height="20" src="/assets/images/quadrants/{{u.quadrant}}.webp?v=1">{% endif %}{{u.customtitle | safe}}</p>
{% else %} {% else %}