add spaces for consistency

pull/195/head
Aevann 2023-08-24 00:57:39 +03:00
parent 6994ea3605
commit 8d84748c42
22 changed files with 96 additions and 96 deletions

View File

@ -1,5 +1,5 @@
function removeComment(t,comment_id,button1,button2,cls) {
url="/remove_comment/"+comment_id
url = "/remove_comment/"+comment_id
postToastSwitch(t, url,
button1,
@ -24,7 +24,7 @@ function removeComment(t,comment_id,button1,button2,cls) {
}
function approveComment(t,comment_id,button1,button2,cls) {
url="/approve_comment/"+comment_id
url = "/approve_comment/"+comment_id
postToastSwitch(t, url,
button1,

View File

@ -1,5 +1,5 @@
function removePost(t,post_id,button1,button2,cls) {
url="/remove_post/"+post_id
url = "/remove_post/"+post_id
postToastSwitch(t, url,
button1,
@ -21,7 +21,7 @@ function removePost(t,post_id,button1,button2,cls) {
function approvePost(t,post_id,button1,button2,cls) {
url="/approve_post/"+post_id
url = "/approve_post/"+post_id
postToastSwitch(t, url,
button1,

View File

@ -259,10 +259,10 @@ socket.on('online', function(data){
})
addEventListener('blur', function(){
focused=false
focused = false
})
addEventListener('focus', function(){
focused=true
focused = true
})
let timer_id;

View File

@ -82,9 +82,9 @@ function toggleReplyBox(t, id) {
}
function toggleEdit(id){
comment=document.getElementById("comment-text-"+id);
form=document.getElementById("comment-edit-"+id);
box=document.getElementById('comment-edit-body-'+id);
comment = document.getElementById("comment-text-"+id);
form = document.getElementById("comment-edit-"+id);
box = document.getElementById('comment-edit-body-'+id);
actions = document.getElementById('comment-' + id +'-actions');
comment.classList.toggle("d-none");

View File

@ -126,8 +126,8 @@ if (!location.pathname.endsWith('/submit'))
function autoExpand(field) {
xpos=window.scrollX;
ypos=window.scrollY;
xpos = window.scrollX;
ypos = window.scrollY;
field.style.height = 'inherit';

View File

@ -1,16 +1,16 @@
function togglePostEdit(id){
body=document.getElementById("post-body");
title=document.getElementById("post-title");
form=document.getElementById("edit-post-body-"+id);
body = document.getElementById("post-body");
title = document.getElementById("post-title");
form = document.getElementById("edit-post-body-"+id);
body.classList.toggle("d-none");
title.classList.toggle("d-none");
form.classList.toggle("d-none");
box=document.getElementById("post-edit-box-"+id);
box = document.getElementById("post-edit-box-"+id);
autoExpand(box);
markdown(box);
box=document.getElementById("post-edit-title");
box = document.getElementById("post-edit-title");
autoExpand(box);
close_inline_speed_emoji_modal();

View File

@ -18,7 +18,7 @@ class ModAction(Base):
target_user_id = Column(Integer, ForeignKey("users.id"))
target_post_id = Column(Integer, ForeignKey("posts.id"))
target_comment_id = Column(Integer, ForeignKey("comments.id"))
_note=Column(String)
_note = Column(String)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="User.id==ModAction.user_id")

View File

@ -48,7 +48,7 @@ class Post(Base):
upvotes = Column(Integer, default=1)
downvotes = Column(Integer, default=0)
realupvotes = Column(Integer, default=1)
app_id=Column(Integer, ForeignKey("oauth_apps.id"))
app_id = Column(Integer, ForeignKey("oauth_apps.id"))
title = Column(String)
title_html = Column(String)
url = Column(String)

View File

@ -7,10 +7,10 @@ from sqlalchemy.sql.sqltypes import *
from files.classes import Base
class SaveRelationship(Base):
__tablename__="save_relationship"
__tablename__ = "save_relationship"
user_id=Column(Integer, ForeignKey("users.id"), primary_key=True)
post_id=Column(Integer, ForeignKey("posts.id"), primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
post_id = Column(Integer, ForeignKey("posts.id"), primary_key=True)
created_utc = Column(Integer)
post = relationship("Post", uselist=False)
@ -25,10 +25,10 @@ class SaveRelationship(Base):
class CommentSaveRelationship(Base):
__tablename__="comment_save_relationship"
__tablename__ = "comment_save_relationship"
user_id=Column(Integer, ForeignKey("users.id"), primary_key=True)
comment_id=Column(Integer, ForeignKey("comments.id"), primary_key=True)
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
comment_id = Column(Integer, ForeignKey("comments.id"), primary_key=True)
created_utc = Column(Integer)
comment = relationship("Comment", uselist=False)

View File

@ -19,7 +19,7 @@ class SubAction(Base):
target_user_id = Column(Integer, ForeignKey("users.id"))
target_post_id = Column(Integer, ForeignKey("posts.id"))
target_comment_id = Column(Integer, ForeignKey("comments.id"))
_note=Column(String)
_note = Column(String)
created_utc = Column(Integer)
user = relationship("User", primaryjoin="User.id==SubAction.user_id")

View File

@ -227,7 +227,7 @@ def execute_snappy(post, v):
text = f"@Snappy has banned you for **{days}** days for the following reason:\n\n> {reason}"
send_repeatable_notification(v.id, text)
duration = f"for {days} days"
ma=ModAction(
ma = ModAction(
kind="ban_user",
user_id=snappy.id,
target_user_id=v.id,
@ -366,7 +366,7 @@ def tempban_for_spam(v):
send_repeatable_notification(v.id, text)
v.ban(reason="Spam", days=1)
ma=ModAction(
ma = ModAction(
kind="ban_user",
user_id=AUTOJANNY_ID,
target_user_id=v.id,
@ -549,18 +549,18 @@ def execute_lawlz_actions(v, p):
p.stickied = "AutoJanny"
p.distinguish_level = 6
p.flair = filter_emojis_only(":ben10: Required Reading")
ma_1=ModAction(
ma_1 = ModAction(
kind="pin_post",
user_id=AUTOJANNY_ID,
target_post_id=p.id,
_note='for 1 day'
)
ma_2=ModAction(
ma_2 = ModAction(
kind="distinguish_post",
user_id=AUTOJANNY_ID,
target_post_id=p.id
)
ma_3=ModAction(
ma_3 = ModAction(
kind="flair_post",
user_id=AUTOJANNY_ID,
target_post_id=p.id,

View File

@ -231,7 +231,7 @@ def get_comment(i, v=None, graceful=False):
if graceful: return None
else: abort(404, "Empty comment ID.")
comment=g.db.get(Comment, i)
comment = g.db.get(Comment, i)
if not comment:
if graceful: return None
else: abort(404, "Comment not found.")

View File

@ -907,7 +907,7 @@ def admin_title_change(user_id, v):
user = get_account(user_id)
new_name=request.values.get("title")[:256].strip()
new_name = request.values.get("title")[:256].strip()
user.customtitleplain=new_name
new_name = filter_emojis_only(new_name)
@ -928,7 +928,7 @@ def admin_title_change(user_id, v):
if user.flairchanged: kind = "set_flair_locked"
else: kind = "set_flair_notlocked"
ma=ModAction(
ma = ModAction(
kind=kind,
user_id=v.id,
target_user_id=user.id,
@ -1014,7 +1014,7 @@ def ban_user(fullname, v):
send_repeatable_notification(user.id, text)
note = f'duration: {duration}, reason: "{reason}"'
ma=ModAction(
ma = ModAction(
kind="ban_user",
user_id=v.id,
target_user_id=user.id,
@ -1111,7 +1111,7 @@ def chud(fullname, v):
note = f'duration: {duration}'
if reason: note += f', reason: "{reason}"'
ma=ModAction(
ma = ModAction(
kind="chud",
user_id=v.id,
target_user_id=user.id,
@ -1182,7 +1182,7 @@ def unban_user(fullname, v):
x.ban_reason = None
g.db.add(x)
ma=ModAction(
ma = ModAction(
kind="unban_user",
user_id=v.id,
target_user_id=user.id,
@ -1256,7 +1256,7 @@ def progstack_post(post_id, v):
post.realupvotes = floor(post.realupvotes * PROGSTACK_MUL)
g.db.add(post)
ma=ModAction(
ma = ModAction(
kind="progstack_post",
user_id=v.id,
target_post_id=post.id,
@ -1277,7 +1277,7 @@ def unprogstack_post(post_id, v):
post.is_approved = None
g.db.add(post)
ma=ModAction(
ma = ModAction(
kind="unprogstack_post",
user_id=v.id,
target_post_id=post.id,
@ -1298,7 +1298,7 @@ def progstack_comment(comment_id, v):
comment.realupvotes = floor(comment.realupvotes * PROGSTACK_MUL)
g.db.add(comment)
ma=ModAction(
ma = ModAction(
kind="progstack_comment",
user_id=v.id,
target_comment_id=comment.id,
@ -1319,7 +1319,7 @@ def unprogstack_comment(comment_id, v):
comment.is_approved = None
g.db.add(comment)
ma=ModAction(
ma = ModAction(
kind="unprogstack_comment",
user_id=v.id,
target_comment_id=comment.id,
@ -1344,7 +1344,7 @@ def remove_post(post_id, v):
post.ban_reason = v.username
g.db.add(post)
ma=ModAction(
ma = ModAction(
kind="ban_post",
user_id=v.id,
target_post_id=post.id,
@ -1464,7 +1464,7 @@ def sticky_post(post_id, v):
g.db.add(post)
ma=ModAction(
ma = ModAction(
kind="pin_post",
user_id=v.id,
target_post_id=post.id,
@ -1596,7 +1596,7 @@ def remove_comment(c_id, v):
comment.is_approved = None
comment.ban_reason = v.username
g.db.add(comment)
ma=ModAction(
ma = ModAction(
kind="ban_comment",
user_id=v.id,
target_comment_id=comment.id,
@ -1689,10 +1689,10 @@ def admin_banned_domains(v):
@admin_level_required(PERMS['DOMAINS_BAN'])
def ban_domain(v):
domain=request.values.get("domain", "").strip().lower()
domain = request.values.get("domain", "").strip().lower()
if not domain: abort(400)
reason=request.values.get("reason", "").strip()
reason = request.values.get("reason", "").strip()
if not reason: abort(400, 'Reason is required!')
if len(reason) > 100:
@ -1745,7 +1745,7 @@ def unban_domain(v, domain):
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
def admin_nuke_user(v):
user=get_user(request.values.get("user"))
user = get_user(request.values.get("user"))
for post in g.db.query(Post).filter_by(author_id=user.id):
if post.is_banned:
@ -1763,7 +1763,7 @@ def admin_nuke_user(v):
comment.ban_reason = v.username
g.db.add(comment)
ma=ModAction(
ma = ModAction(
kind="nuke_user",
user_id=v.id,
target_user_id=user.id,
@ -1781,7 +1781,7 @@ def admin_nuke_user(v):
@admin_level_required(PERMS['POST_COMMENT_MODERATION'])
def admin_nunuke_user(v):
user=get_user(request.values.get("user"))
user = get_user(request.values.get("user"))
for post in g.db.query(Post).filter_by(author_id=user.id):
if not post.is_banned:
@ -1801,7 +1801,7 @@ def admin_nunuke_user(v):
comment.is_approved = v.id
g.db.add(comment)
ma=ModAction(
ma = ModAction(
kind="unnuke_user",
user_id=v.id,
target_user_id=user.id,
@ -1892,7 +1892,7 @@ def delete_media_post(v):
os.remove(path)
ma=ModAction(
ma = ModAction(
kind="delete_media",
user_id=v.id,
_note=url,

View File

@ -72,7 +72,7 @@ def post_pid_comment_cid(cid, v, pid=None, anything=None, sub=None):
if post.new: defaultsortingcomments = 'new'
elif v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "hot"
sort=request.values.get("sort", defaultsortingcomments)
sort = request.values.get("sort", defaultsortingcomments)
while context and c.level > 1:
parent = c.parent_comment
@ -532,9 +532,9 @@ def unpin_comment(cid, v):
@auth_required
def save_comment(cid, v):
comment=get_comment(cid)
comment = get_comment(cid)
save=g.db.query(CommentSaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
save = g.db.query(CommentSaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if not save:
new_save=CommentSaveRelationship(user_id=v.id, comment_id=comment.id)
@ -551,9 +551,9 @@ def save_comment(cid, v):
@auth_required
def unsave_comment(cid, v):
comment=get_comment(cid)
comment = get_comment(cid)
save=g.db.query(CommentSaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
save = g.db.query(CommentSaveRelationship).filter_by(user_id=v.id, comment_id=comment.id).one_or_none()
if save:
g.db.delete(save)

View File

@ -36,14 +36,14 @@ def front_all(v, sub=None):
if sub: defaultsorting = "new"
sort=request.values.get("sort", defaultsorting)
t=request.values.get('t', defaulttime)
sort = request.values.get("sort", defaultsorting)
t = request.values.get('t', defaulttime)
try: gt=int(request.values.get("after", 0))
except: gt=0
try: gt = int(request.values.get("after", 0))
except: gt = 0
try: lt=int(request.values.get("before", 0))
except: lt=0
try: lt = int(request.values.get("before", 0))
except: lt = 0
if sort == 'hot': default = True
else: default = False
@ -238,8 +238,8 @@ def comment_idlist(v=None, page=1, sort="new", t="day", gt=0, lt=0):
def all_comments(v):
page = get_page()
sort=request.values.get("sort", "new")
t=request.values.get("t", "hour")
sort = request.values.get("sort", "new")
t = request.values.get("t", "hour")
try: gt=int(request.values.get("after", 0))
except: gt=0

View File

@ -482,15 +482,15 @@ def lost_2fa(v):
@limiter.limit('1/second', scope=rpath)
@limiter.limit("6/minute;200/hour;1000/day", deduct_when=lambda response: response.status_code < 400)
def lost_2fa_post():
username=request.values.get("username")
user=get_user(username, graceful=True)
username = request.values.get("username")
user = get_user(username, graceful=True)
if not user or not user.email or not user.mfa_secret:
return render_template("message.html",
title="Removal request received",
message="If username, password, and email match, we will send you an email."), 202
email=request.values.get("email").strip().lower()
email = request.values.get("email").strip().lower()
if not email_regex.fullmatch(email):
abort(400, "Invalid email")
@ -501,10 +501,10 @@ def lost_2fa_post():
title="Removal request received",
message="If username, password, and email match, we will send you an email."), 202
valid=int(time.time())
token=generate_hash(f"{user.id}+{user.username}+disable2fa+{valid}+{user.mfa_secret}+{user.login_nonce}")
valid = int(time.time())
token = generate_hash(f"{user.id}+{user.username}+disable2fa+{valid}+{user.mfa_secret}+{user.login_nonce}")
action_url=f"{SITE_FULL}/reset_2fa?id={user.id}&t={valid}&token={token}"
action_url = f"{SITE_FULL}/reset_2fa?id={user.id}&t={valid}&token={token}"
send_mail(to_address=user.email,
subject="Two-factor Authentication Removal Request",
@ -520,7 +520,7 @@ def lost_2fa_post():
@app.get("/reset_2fa")
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400)
def reset_2fa():
now=int(time.time())
now = int(time.time())
t = request.values.get("t")
if not t: abort(400)
try:
@ -531,10 +531,10 @@ def reset_2fa():
if now > t+3600*24:
abort(410, "This two-factor authentication reset link has expired!")
token=request.values.get("token")
uid=request.values.get("id")
token = request.values.get("token")
uid = request.values.get("id")
user=get_account(uid)
user = get_account(uid)
if not validate_hash(f"{user.id}+{user.username}+disable2fa+{t}+{user.mfa_secret}+{user.login_nonce}", token):
abort(403)

View File

@ -59,7 +59,7 @@ def searchposts(v):
sort = request.values.get("sort", "new").lower()
t = request.values.get('t', 'all').lower()
criteria=searchparse(query)
criteria = searchparse(query)
posts = g.db.query(Post).options(load_only(Post.id)) \
.join(Post.author) \

View File

@ -360,7 +360,7 @@ def settings_personal_post(v):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def filters(v):
filters=request.values.get("filters")[:1000].strip()
filters = request.values.get("filters")[:1000].strip()
if filters == v.custom_filter_list:
abort(400, "You didn't change anything!")
@ -730,7 +730,7 @@ def settings_name_change(v):
if v.shadowbanned: abort(500)
new_name=request.values.get("name").strip()
new_name = request.values.get("name").strip()
if new_name==v.username:
abort(400, "You didn't change anything")
@ -835,7 +835,7 @@ def _change_song_youtube(vid, id):
@limiter.limit("10/day", deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def settings_song_change(v):
song=request.values.get("song").strip()
song = request.values.get("song").strip()
if song == "" and v.song:
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:

View File

@ -212,7 +212,7 @@ def log(v):
@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID)
@auth_required
def log_item(id, v):
action=g.db.get(ModAction, id)
action = g.db.get(ModAction, id)
if not action: abort(404)

View File

@ -507,7 +507,7 @@ def post_sub_css(v, sub):
def get_sub_css(sub):
sub = g.db.query(Sub.css).filter_by(name=sub.strip().lower()).one_or_none()
if not sub: abort(404)
resp=make_response(sub.css or "")
resp = make_response(sub.css or "")
resp.headers.add("Content-Type", "text/css")
return resp
@ -893,7 +893,7 @@ def hole_log_item(id, v, sub):
if not User.can_see(v, sub):
abort(403)
action=g.db.get(SubAction, id)
action = g.db.get(SubAction, id)
if not action: abort(404)

View File

@ -790,7 +790,7 @@ def mfa_qr(v, secret):
@limiter.limit("100/day", deduct_when=lambda response: response.status_code < 400)
def is_available(name):
name=name.strip()
name = name.strip()
if len(name)<3 or len(name)>25:
return {name:False}
@ -1114,8 +1114,8 @@ def u_username_comments(username, v):
page = get_page()
sort=request.values.get("sort","new")
t=request.values.get("t","all")
sort = request.values.get("sort","new")
t = request.values.get("t","all")
comment_post_author = aliased(User)
comments = g.db.query(Comment).options(load_only(Comment.id)) \
@ -1156,7 +1156,7 @@ def u_username_comments(username, v):
@auth_required
def u_username_info(username, v):
user=get_user(username, v=v, include_blocks=True)
user = get_user(username, v=v, include_blocks=True)
if hasattr(user, 'is_blocking') and user.is_blocking:
abort(401, f"You're blocking @{user.username}")

View File

@ -19,11 +19,11 @@
<p>Python example:</p>
<pre> import requests
headers={"Authorization": "access_token_goes_here"}
headers = {"Authorization": "access_token_goes_here"}
url="{{SITE_FULL}}/?sort=comments"
url = "{{SITE_FULL}}/?sort=comments"
r=requests.get(url, headers=headers)
r = requests.get(url, headers=headers)
print(r.json())
</pre>
@ -34,11 +34,11 @@
<p>Aother python example:</p>
<pre> import requests
headers={"Authorization": "access_token_goes_here"}
headers = {"Authorization": "access_token_goes_here"}
url="{{SITE_FULL}}/unread"
url = "{{SITE_FULL}}/unread"
r=requests.get(url, headers=headers)
r = requests.get(url, headers=headers)
print(r.json())
</pre>
@ -71,11 +71,11 @@
<p>Python example:</p>
<pre> import requests
headers={"Authorization": "access_token_goes_here"}
headers = {"Authorization": "access_token_goes_here"}
url="{{SITE_FULL}}/?sort=comments"
url = "{{SITE_FULL}}/?sort=comments"
r=requests.get(url, headers=headers)
r = requests.get(url, headers=headers)
print(r.json())
</pre>
@ -86,11 +86,11 @@
<p>Aother python example:</p>
<pre> import requests
headers={"Authorization": "access_token_goes_here"}
headers = {"Authorization": "access_token_goes_here"}
url="{{SITE_FULL}}/unread"
url = "{{SITE_FULL}}/unread"
r=requests.get(url, headers=headers)
r = requests.get(url, headers=headers)
print(r.json())
</pre>