Merge branch 'master' into mistletoe
This commit is contained in:
commit
efa9d669c3
9 changed files with 743 additions and 300 deletions
File diff suppressed because one or more lines are too long
|
@ -148,8 +148,6 @@ if SITE == 'rdrama.net':
|
||||||
LLM_ID = 253
|
LLM_ID = 253
|
||||||
DAD_ID = 2513
|
DAD_ID = 2513
|
||||||
MOM_ID = 4588
|
MOM_ID = 4588
|
||||||
BUG_THREAD = 18459
|
|
||||||
EMOJI_THREAD = 22479
|
|
||||||
elif SITE == "pcmemes.net":
|
elif SITE == "pcmemes.net":
|
||||||
BASEDBOT_ID = 800
|
BASEDBOT_ID = 800
|
||||||
KIPPY_ID = 1592
|
KIPPY_ID = 1592
|
||||||
|
@ -170,8 +168,6 @@ elif SITE == "pcmemes.net":
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
MOM_ID = 0
|
MOM_ID = 0
|
||||||
BUG_THREAD = 4103
|
|
||||||
EMOJI_THREAD = 0
|
|
||||||
else:
|
else:
|
||||||
BASEDBOT_ID = 0
|
BASEDBOT_ID = 0
|
||||||
KIPPY_ID = 0
|
KIPPY_ID = 0
|
||||||
|
@ -192,8 +188,6 @@ else:
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
MOM_ID = 0
|
MOM_ID = 0
|
||||||
BUG_THREAD = 0
|
|
||||||
EMOJI_THREAD = 0
|
|
||||||
|
|
||||||
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
||||||
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
||||||
|
|
|
@ -210,12 +210,21 @@ def sanitize(sanitized, noimages=False):
|
||||||
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.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
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.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
|
||||||
|
|
||||||
|
|
||||||
for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=.*?)</a>', sanitized):
|
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||||
|
|
||||||
|
for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))</a>', sanitized):
|
||||||
url = i.group(1)
|
url = i.group(1)
|
||||||
|
yt_id = i.group(2).split('&')[0]
|
||||||
replacing = f'<a href="{url}" rel="nofollow noopener noreferrer" target="_blank">{url}</a>'
|
replacing = f'<a href="{url}" rel="nofollow noopener noreferrer" target="_blank">{url}</a>'
|
||||||
url = url.replace("watch?v=", "embed/").replace("&t", "?start").replace("?t", "?start")
|
|
||||||
url = re.sub('(\?start=([0-9]*?))s', r'\1', url)
|
params = parse_qs(urlparse(url).query)
|
||||||
htmlsource = f'<iframe class="embedvid" loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
t = params.get('t', params.get('start', [0]))[0]
|
||||||
|
if isinstance(t, str): t = t.replace('s','')
|
||||||
|
|
||||||
|
htmlsource = f'<lite-youtube videoid="{yt_id}" params="controls=0&modestbranding=1'
|
||||||
|
if t: htmlsource += f'&start={t}'
|
||||||
|
htmlsource += '"></lite-youtube>'
|
||||||
|
|
||||||
sanitized = sanitized.replace(replacing, htmlsource)
|
sanitized = sanitized.replace(replacing, htmlsource)
|
||||||
|
|
||||||
for i in re.finditer('<a href="(https://streamable\.com/e/.*?)"', sanitized):
|
for i in re.finditer('<a href="(https://streamable\.com/e/.*?)"', sanitized):
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -101,8 +101,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
try: pid = int(pid)
|
try: pid = int(pid)
|
||||||
except Exception as e: pass
|
except Exception as e: pass
|
||||||
|
|
||||||
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
|
if v: defaultsortingcomments = v.defaultsortingcomments
|
||||||
elif v: defaultsortingcomments = v.defaultsortingcomments
|
|
||||||
else: defaultsortingcomments = "top"
|
else: defaultsortingcomments = "top"
|
||||||
|
|
||||||
sort = request.values.get("sort", defaultsortingcomments)
|
sort = request.values.get("sort", defaultsortingcomments)
|
||||||
|
@ -116,8 +115,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
|
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
|
||||||
|
|
||||||
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
|
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
|
@ -135,7 +132,7 @@ def post_id(pid, anything=None, v=None):
|
||||||
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
if not (v and v.shadowbanned) and not (v and v.admin_level > 1):
|
||||||
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
comments = comments.join(User, User.id == Comment.author_id).filter(User.shadowbanned == None)
|
||||||
|
|
||||||
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.is_pinned == None).join(
|
comments=comments.filter(Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID).join(
|
||||||
votes,
|
votes,
|
||||||
votes.c.comment_id == Comment.id,
|
votes.c.comment_id == Comment.id,
|
||||||
isouter=True
|
isouter=True
|
||||||
|
@ -157,7 +154,9 @@ def post_id(pid, anything=None, v=None):
|
||||||
comment.is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
comments = comments.filter(Comment.level == 1)
|
pinned = [c[0] for c in comments.filter(Comment.is_pinned != None).all()]
|
||||||
|
|
||||||
|
comments = comments.filter(Comment.level == 1, Comment.is_pinned == None)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
comments = comments.order_by(Comment.created_utc.desc())
|
comments = comments.order_by(Comment.created_utc.desc())
|
||||||
|
@ -175,6 +174,8 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
comments = [c[0] for c in comments.all()]
|
comments = [c[0] for c in comments.all()]
|
||||||
else:
|
else:
|
||||||
|
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
|
||||||
|
|
||||||
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
|
comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
|
@ -207,8 +208,6 @@ def post_id(pid, anything=None, v=None):
|
||||||
|
|
||||||
post.replies = pinned + comments
|
post.replies = pinned + comments
|
||||||
|
|
||||||
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD] and not request.values.get("sort"): post.replies = post.replies[:10]
|
|
||||||
|
|
||||||
post.views += 1
|
post.views += 1
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0
|
||||||
|
@ -638,8 +637,10 @@ def submit_post(v):
|
||||||
params = parse_qs(urlparse(url).query)
|
params = parse_qs(urlparse(url).query)
|
||||||
t = params.get('t', params.get('start', [0]))[0]
|
t = params.get('t', params.get('start', [0]))[0]
|
||||||
if isinstance(t, str): t = t.replace('s','')
|
if isinstance(t, str): t = t.replace('s','')
|
||||||
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
|
embed = f'<lite-youtube videoid="{yt_id}" params="controls=0&modestbranding=1'
|
||||||
else: embed = f"https://youtube.com/embed/{yt_id}"
|
if t: embed += f'&start={t}'
|
||||||
|
embed += '"></lite-youtube>'
|
||||||
|
|
||||||
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
|
elif app.config['SERVER_NAME'] in domain and "/post/" in url and "context" not in url:
|
||||||
id = url.split("/post/")[1]
|
id = url.split("/post/")[1]
|
||||||
if "/" in id: id = id.split("/")[0]
|
if "/" in id: id = id.split("/")[0]
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{p.embed_url | safe}}
|
|
||||||
<script src="/assets/js/twitter.js" charset="utf-8">
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
|
|
||||||
</script>
|
|
|
@ -1,6 +0,0 @@
|
||||||
{{p.embed_url | safe}}
|
|
||||||
<script src="https://platform.twitter.com/widgets.js" charset="utf-8">
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
document.getElementById('twitter-widget-0').setAttribute('sandbox','')
|
|
||||||
</script>
|
|
|
@ -1,3 +0,0 @@
|
||||||
<div class="embed-responsive embed-responsive-16by9 mb-3">
|
|
||||||
<iframe loading="lazy" src="{{p.embed_url}}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
||||||
</div>
|
|
|
@ -84,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/emoji_modal.js?v=128"></script>
|
<script src="/assets/js/emoji_modal.js?v=129"></script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
a.emojitab {
|
a.emojitab {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue