forked from rDrama/rDrama
Merge branch 'master' of https://github.com/Aevann1/Drama
commit
823b297ecf
|
@ -25,6 +25,7 @@ class User(Base, Stndrd, Age_times):
|
||||||
theme = Column(String, default='dark')
|
theme = Column(String, default='dark')
|
||||||
themecolor = Column(String, default='ff66ac')
|
themecolor = Column(String, default='ff66ac')
|
||||||
song = Column(String)
|
song = Column(String)
|
||||||
|
highres = Column(String)
|
||||||
profileurl = Column(String)
|
profileurl = Column(String)
|
||||||
bannerurl = Column(String)
|
bannerurl = Column(String)
|
||||||
patron = Column(Boolean, default=False)
|
patron = Column(Boolean, default=False)
|
||||||
|
|
|
@ -17,7 +17,6 @@ from drama.classes import *
|
||||||
from drama.classes.domains import reasons as REASONS
|
from drama.classes.domains import reasons as REASONS
|
||||||
from flask import *
|
from flask import *
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from .front import frontlist
|
|
||||||
from drama.__main__ import app, cache
|
from drama.__main__ import app, cache
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ def flagged_posts(v):
|
||||||
|
|
||||||
listing = [p.id for p in posts]
|
listing = [p.id for p in posts]
|
||||||
next_exists = (len(listing) == 26)
|
next_exists = (len(listing) == 26)
|
||||||
listing = listing[0:25]
|
listing = listing[:25]
|
||||||
|
|
||||||
listing = get_posts(listing, v=v)
|
listing = get_posts(listing, v=v)
|
||||||
|
|
||||||
|
@ -75,7 +74,7 @@ def image_posts_listing(v):
|
||||||
|
|
||||||
posts = [x.id for x in posts]
|
posts = [x.id for x in posts]
|
||||||
next_exists = (len(posts) == 26)
|
next_exists = (len(posts) == 26)
|
||||||
posts = posts[0:25]
|
posts = posts[:25]
|
||||||
|
|
||||||
posts = get_posts(posts, v=v)
|
posts = get_posts(posts, v=v)
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ def flagged_comments(v):
|
||||||
|
|
||||||
listing = [p.id for p in posts]
|
listing = [p.id for p in posts]
|
||||||
next_exists = (len(listing) == 26)
|
next_exists = (len(listing) == 26)
|
||||||
listing = listing[0:25]
|
listing = listing[:25]
|
||||||
|
|
||||||
listing = get_comments(listing, v=v)
|
listing = get_comments(listing, v=v)
|
||||||
|
|
||||||
|
@ -221,7 +220,7 @@ def users_list(v):
|
||||||
users = [x for x in users]
|
users = [x for x in users]
|
||||||
|
|
||||||
next_exists = (len(users) == 26)
|
next_exists = (len(users) == 26)
|
||||||
users = users[0:25]
|
users = users[:25]
|
||||||
|
|
||||||
return render_template("admin/new_users.html",
|
return render_template("admin/new_users.html",
|
||||||
v=v,
|
v=v,
|
||||||
|
@ -408,7 +407,7 @@ def admin_removed(v):
|
||||||
|
|
||||||
next_exists = len(ids) == 26
|
next_exists = len(ids) == 26
|
||||||
|
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
|
||||||
|
@ -568,7 +567,7 @@ def shadowban(user_id, v):
|
||||||
target_user_id=user.id,
|
target_user_id=user.id,
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
||||||
|
@ -590,7 +589,7 @@ def unshadowban(user_id, v):
|
||||||
target_user_id=user.id,
|
target_user_id=user.id,
|
||||||
)
|
)
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
||||||
|
@ -739,7 +738,7 @@ def ban_post(post_id, v):
|
||||||
|
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
ma=ModAction(
|
ma=ModAction(
|
||||||
kind="ban_post",
|
kind="ban_post",
|
||||||
|
@ -773,7 +772,7 @@ def unban_post(post_id, v):
|
||||||
|
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
@ -810,7 +809,7 @@ def api_sticky_post(post_id, v):
|
||||||
post.stickied = not (post.stickied)
|
post.stickied = not (post.stickied)
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ def feeds_user(sort='hot', t='all'):
|
||||||
page=page,
|
page=page,
|
||||||
t=t,
|
t=t,
|
||||||
v=None,
|
v=None,
|
||||||
ids_only=False)
|
)
|
||||||
|
|
||||||
domain = environ.get(
|
domain = environ.get(
|
||||||
"domain", environ.get(
|
"domain", environ.get(
|
||||||
|
|
|
@ -69,8 +69,8 @@ def notifications(v):
|
||||||
render_replies=True,
|
render_replies=True,
|
||||||
is_notification_page=True)
|
is_notification_page=True)
|
||||||
|
|
||||||
@cache.memoize(timeout=1500)
|
|
||||||
def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words='', **kwargs):
|
def frontlist(v=None, sort="hot", page=1,t="all", filter_words='', **kwargs):
|
||||||
|
|
||||||
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
|
posts = g.db.query(Submission).options(lazyload('*')).filter_by(is_banned=False,stickied=False,private=False).filter(Submission.deleted_utc == 0)
|
||||||
if v and v.admin_level == 0:
|
if v and v.admin_level == 0:
|
||||||
|
@ -169,12 +169,7 @@ def frontlist(v=None, sort="hot", page=1,t="all", ids_only=True, filter_words=''
|
||||||
post.views = post.views + random.randint(7,10)
|
post.views = post.views + random.randint(7,10)
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
posts = [x for x in posts if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)][:26]
|
return [x for x in posts if not (x.author and x.author.shadowbanned) or (v and v.id == x.author_id)][:26]
|
||||||
|
|
||||||
if ids_only:
|
|
||||||
posts = [x.id for x in posts]
|
|
||||||
return posts
|
|
||||||
return posts
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
@app.get("/api/v1/listing")
|
@app.get("/api/v1/listing")
|
||||||
|
@ -198,7 +193,7 @@ def front_all(v):
|
||||||
sort=request.args.get("sort", defaultsorting)
|
sort=request.args.get("sort", defaultsorting)
|
||||||
t=request.args.get('t', defaulttime)
|
t=request.args.get('t', defaulttime)
|
||||||
|
|
||||||
ids = frontlist(sort=sort,
|
posts = frontlist(sort=sort,
|
||||||
page=page,
|
page=page,
|
||||||
t=t,
|
t=t,
|
||||||
v=v,
|
v=v,
|
||||||
|
@ -208,11 +203,8 @@ def front_all(v):
|
||||||
)
|
)
|
||||||
|
|
||||||
# check existence of next page
|
# check existence of next page
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(posts) == 26)
|
||||||
ids = ids[0:25]
|
posts = posts[:25]
|
||||||
|
|
||||||
# check if ids exist
|
|
||||||
posts = get_posts(ids, v=v)
|
|
||||||
|
|
||||||
if request.path == "/": return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)
|
if request.path == "/": return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page)
|
||||||
else: return jsonify({"data": [x.json for x in posts], "next_exists": next_exists})
|
else: return jsonify({"data": [x.json for x in posts], "next_exists": next_exists})
|
||||||
|
@ -311,7 +303,7 @@ def changelog(v):
|
||||||
|
|
||||||
# check existence of next page
|
# check existence of next page
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(ids) == 26)
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
# check if ids exist
|
# check if ids exist
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
@ -426,7 +418,7 @@ def all_comments(v):
|
||||||
|
|
||||||
next_exists = len(idlist) == 26
|
next_exists = len(idlist) == 26
|
||||||
|
|
||||||
idlist = idlist[0:25]
|
idlist = idlist[:25]
|
||||||
|
|
||||||
return {"html": lambda: render_template("home_comments.html",
|
return {"html": lambda: render_template("home_comments.html",
|
||||||
v=v,
|
v=v,
|
||||||
|
|
|
@ -229,7 +229,7 @@ def request_api_keys(v):
|
||||||
app_name=request.form.get('name'),
|
app_name=request.form.get('name'),
|
||||||
redirect_uri=request.form.get('redirect_uri'),
|
redirect_uri=request.form.get('redirect_uri'),
|
||||||
author_id=v.id,
|
author_id=v.id,
|
||||||
description=request.form.get("description")[0:256]
|
description=request.form.get("description")[:256]
|
||||||
)
|
)
|
||||||
|
|
||||||
g.db.add(new_app)
|
g.db.add(new_app)
|
||||||
|
@ -267,7 +267,7 @@ def edit_oauth_app(v, aid):
|
||||||
|
|
||||||
app.redirect_uri = request.form.get('redirect_uri')
|
app.redirect_uri = request.form.get('redirect_uri')
|
||||||
app.app_name = request.form.get('name')
|
app.app_name = request.form.get('name')
|
||||||
app.description = request.form.get("description")[0:256]
|
app.description = request.form.get("description")[:256]
|
||||||
|
|
||||||
g.db.add(app)
|
g.db.add(app)
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ from drama.helpers.thumbs import *
|
||||||
from drama.helpers.alerts import send_notification
|
from drama.helpers.alerts import send_notification
|
||||||
from drama.helpers.discord import send_message
|
from drama.helpers.discord import send_message
|
||||||
from drama.classes import *
|
from drama.classes import *
|
||||||
from .front import frontlist
|
|
||||||
from flask import *
|
from flask import *
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from drama.__main__ import app, limiter, cache
|
from drama.__main__ import app, limiter, cache
|
||||||
|
@ -60,7 +59,7 @@ def publish(pid, v):
|
||||||
if not post.author_id == v.id: abort(403)
|
if not post.author_id == v.id: abort(403)
|
||||||
post.private = False
|
post.private = False
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
@ -941,7 +940,7 @@ def submit_post(v):
|
||||||
# spin off thumbnail generation and csam detection as new threads
|
# spin off thumbnail generation and csam detection as new threads
|
||||||
if (new_post.url or request.files.get('file')) and (v.is_activated or request.headers.get('cf-ipcountry')!="T1"): thumbs(new_post)
|
if (new_post.url or request.files.get('file')) and (v.is_activated or request.headers.get('cf-ipcountry')!="T1"): thumbs(new_post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
cache.delete_memoized(User.userpagelisting)
|
cache.delete_memoized(User.userpagelisting)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
|
@ -1061,7 +1060,7 @@ def delete_post_pid(pid, v):
|
||||||
|
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
|
@ -1075,7 +1074,7 @@ def undelete_post_pid(pid, v):
|
||||||
if not post.author_id == v.id: abort(403)
|
if not post.author_id == v.id: abort(403)
|
||||||
post.deleted_utc =0
|
post.deleted_utc =0
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
@app.get("/embed/post/<pid>")
|
@app.get("/embed/post/<pid>")
|
||||||
|
|
|
@ -215,7 +215,7 @@ def searchposts(v, search_type="posts"):
|
||||||
total, ids = searchlisting(criteria, v=v, page=page, t=t, sort=sort)
|
total, ids = searchlisting(criteria, v=v, page=page, t=t, sort=sort)
|
||||||
|
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(ids) == 26)
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
posts = get_posts(ids, v=v)
|
posts = get_posts(ids, v=v)
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ def searchcomments(v):
|
||||||
total, ids = searchcommentlisting(criteria, v=v, page=page, t=t, sort=sort)
|
total, ids = searchcommentlisting(criteria, v=v, page=page, t=t, sort=sort)
|
||||||
|
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(ids) == 26)
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
comments = get_comments(ids, v=v)
|
comments = get_comments(ids, v=v)
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ def searchusers(v, search_type="posts"):
|
||||||
|
|
||||||
users=[x for x in users.offset(25 * (page-1)).limit(26)]
|
users=[x for x in users.offset(25 * (page-1)).limit(26)]
|
||||||
next_exists=(len(users)==26)
|
next_exists=(len(users)==26)
|
||||||
users=users[0:25]
|
users=users[:25]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,7 @@ from drama.helpers.filters import filter_comment_html
|
||||||
from drama.helpers.markdown import *
|
from drama.helpers.markdown import *
|
||||||
from drama.helpers.discord import remove_user, set_nick
|
from drama.helpers.discord import remove_user, set_nick
|
||||||
from drama.mail import *
|
from drama.mail import *
|
||||||
from .front import frontlist
|
=from drama.__main__ import app, cache
|
||||||
from drama.__main__ import app, cache
|
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
|
|
||||||
valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$")
|
valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$")
|
||||||
|
@ -159,7 +158,7 @@ def settings_profile_post(v):
|
||||||
def changelogsub(v):
|
def changelogsub(v):
|
||||||
v.changelogsub = not v.changelogsub
|
v.changelogsub = not v.changelogsub
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
@app.post("/settings/namecolor")
|
@app.post("/settings/namecolor")
|
||||||
|
@ -460,7 +459,7 @@ def settings_block_user(v):
|
||||||
)
|
)
|
||||||
g.db.add(new_block)
|
g.db.add(new_block)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(blocksender=v.id, user_id=user.id).first()
|
existing = g.db.query(Notification).filter_by(blocksender=v.id, user_id=user.id).first()
|
||||||
if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!")
|
if not existing: send_block_notif(v.id, user.id, f"@{v.username} has blocked you!")
|
||||||
|
@ -482,7 +481,7 @@ def settings_unblock_user(v):
|
||||||
|
|
||||||
g.db.delete(x)
|
g.db.delete(x)
|
||||||
|
|
||||||
cache.delete_memoized(frontlist)
|
|
||||||
|
|
||||||
existing = g.db.query(Notification).filter_by(unblocksender=v.id, user_id=user.id).first()
|
existing = g.db.query(Notification).filter_by(unblocksender=v.id, user_id=user.id).first()
|
||||||
if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!")
|
if not existing: send_unblock_notif(v.id, user.id, f"@{v.username} has unblocked you!")
|
||||||
|
|
|
@ -291,7 +291,7 @@ def u_username(username, v=None):
|
||||||
|
|
||||||
# we got 26 items just to see if a next page exists
|
# we got 26 items just to see if a next page exists
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(ids) == 26)
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
# If page 1, check for sticky
|
# If page 1, check for sticky
|
||||||
if page == 1:
|
if page == 1:
|
||||||
|
@ -391,7 +391,7 @@ def u_username_comments(username, v=None):
|
||||||
|
|
||||||
# we got 26 items just to see if a next page exists
|
# we got 26 items just to see if a next page exists
|
||||||
next_exists = (len(ids) == 26)
|
next_exists = (len(ids) == 26)
|
||||||
ids = ids[0:25]
|
ids = ids[:25]
|
||||||
|
|
||||||
listing = get_comments(ids, v=v)
|
listing = get_comments(ids, v=v)
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ def saved_posts(v, username):
|
||||||
|
|
||||||
next_exists=len(ids)==26
|
next_exists=len(ids)==26
|
||||||
|
|
||||||
ids=ids[0:25]
|
ids=ids[:25]
|
||||||
|
|
||||||
listing = get_posts(ids, v=v)
|
listing = get_posts(ids, v=v)
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ def saved_comments(v, username):
|
||||||
|
|
||||||
next_exists=len(ids)==26
|
next_exists=len(ids)==26
|
||||||
|
|
||||||
ids=ids[0:25]
|
ids=ids[:25]
|
||||||
|
|
||||||
listing = get_comments(ids, v=v, sort="new")
|
listing = get_comments(ids, v=v, sort="new")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue