Merge branch 'master' into mistletoe

remotes/1693045480750635534/spooky-22
kek7198 2021-12-05 10:49:14 -06:00
commit 1d30e85d98
8 changed files with 26 additions and 37 deletions

View File

@ -148,8 +148,6 @@ if SITE == 'rdrama.net':
LLM_ID = 253
DAD_ID = 2513
MOM_ID = 4588
BUG_THREAD = 18459
EMOJI_THREAD = 22479
elif SITE == "pcmemes.net":
BASEDBOT_ID = 800
KIPPY_ID = 1592
@ -170,8 +168,6 @@ elif SITE == "pcmemes.net":
LLM_ID = 0
DAD_ID = 0
MOM_ID = 0
BUG_THREAD = 4103
EMOJI_THREAD = 0
else:
BASEDBOT_ID = 0
KIPPY_ID = 0
@ -192,8 +188,6 @@ else:
LLM_ID = 0
DAD_ID = 0
MOM_ID = 0
BUG_THREAD = 0
EMOJI_THREAD = 0
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()

View File

@ -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")
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)
yt_id = i.group(2).split('&')[0]
replacing = f'<a href="{url}" rel="nofollow noopener noreferrer" target="_blank">{url}</a>'
url = url.replace("watch?v=", "embed/").replace("&amp;t", "?start").replace("?t", "?start")
url = re.sub('(\?start=([0-9]*?))s', r'\1', url)
htmlsource = f'<iframe class="embedvid" loading="lazy" src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
params = parse_qs(urlparse(url).query)
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)
for i in re.finditer('<a href="(https://streamable\.com/e/.*?)"', sanitized):

File diff suppressed because one or more lines are too long

View File

@ -101,8 +101,7 @@ def post_id(pid, anything=None, v=None):
try: pid = int(pid)
except Exception as e: pass
if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD]: defaultsortingcomments = 'new'
elif v: defaultsortingcomments = v.defaultsortingcomments
if v: defaultsortingcomments = v.defaultsortingcomments
else: defaultsortingcomments = "top"
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)
pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all()
if v:
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):
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.c.comment_id == Comment.id,
isouter=True
@ -157,7 +154,9 @@ def post_id(pid, anything=None, v=None):
comment.is_blocked = c[3] or 0
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":
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()]
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)
if sort == "new":
@ -207,8 +208,6 @@ def post_id(pid, anything=None, v=None):
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
g.db.add(post)
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)
t = params.get('t', params.get('start', [0]))[0]
if isinstance(t, str): t = t.replace('s','')
if t: embed = f"https://youtube.com/embed/{yt_id}?start={t}"
else: embed = f"https://youtube.com/embed/{yt_id}"
embed = f'<lite-youtube videoid="{yt_id}" params="controls=0&modestbranding=1'
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:
id = url.split("/post/")[1]
if "/" in id: id = id.split("/")[0]

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -84,7 +84,7 @@
</div>
</div>
<script src="/assets/js/emoji_modal.js?v=128"></script>
<script src="/assets/js/emoji_modal.js?v=129"></script>
<style>
a.emojitab {