From 7da6bb8a584b066689458ecdda09b1b8b8f4ce99 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 4 Dec 2021 01:34:03 +0200 Subject: [PATCH] sdfsfd --- files/classes/comment.py | 10 +++++++++- files/routes/comments.py | 14 +++++++++++++- files/routes/posts.py | 11 +++++++++++ files/templates/admins.html | 2 ++ files/templates/comments.html | 9 +-------- files/templates/formatting.html | 5 +++++ 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 8cc74a091..d299cc3bb 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -392,7 +392,15 @@ class Comment(Base): @lazy def ordered_flags(self): return self.flags.order_by(CommentFlag.id).all() - + def options_html(self, v): + html = "" + for o in self.options: + html += f'
'
+		return html
 
 class Notification(Base):
 
diff --git a/files/routes/comments.py b/files/routes/comments.py
index b0f6131d9..c0144f45a 100644
--- a/files/routes/comments.py
+++ b/files/routes/comments.py
@@ -646,6 +646,18 @@ def edit_comment(cid, v):
 			body = body.replace('I ', f'@{v.username} ')
 			body = censor_slurs2(body).upper().replace(' ME ', f' @{v.username} ')
 
+		if not c.options:
+			for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
+				body = body.replace(i.group(0), "")
+				c_option = Comment(author_id=AUTOPOLLER_ID,
+					parent_submission=c.parent_submission,
+					parent_comment_id=c.id,
+					level=c.level+1,
+					body_html=filter_title(i.group(1)),
+					upvotes=0
+					)
+				g.db.add(c_option)
+
 		body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))
 
 		if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403
@@ -816,7 +828,7 @@ def edit_comment(cid, v):
 
 		g.db.commit()
 
-	return c.body_html
+	return c.body_html + c.options_html(v)
 
 
 @app.post("/delete/comment/")
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 4d57c2ac7..24830b2f8 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -275,6 +275,17 @@ def edit_post(pid, v):
 			body = body.replace('I ', f'@{v.username} ')
 			body = censor_slurs2(body).upper().replace(' ME ', f' @{v.username} ')
 
+		if not p.options.count():
+			for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
+				body = body.replace(i.group(0), "")
+				c = Comment(author_id=AUTOPOLLER_ID,
+					parent_submission=p.id,
+					level=1,
+					body_html=filter_title(i.group(1)),
+					upvotes=0
+					)
+				g.db.add(c)
+
 		body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))
 
 		bans = filter_comment_html(body_html)
diff --git a/files/templates/admins.html b/files/templates/admins.html
index 0f76a6630..c0d982ce0 100644
--- a/files/templates/admins.html
+++ b/files/templates/admins.html
@@ -9,12 +9,14 @@
 
+		
 {% for user in admins %}
 	
+		
diff --git a/files/templates/comments.html b/files/templates/comments.html
index d16f0eb85..79e1634db 100644
--- a/files/templates/comments.html
+++ b/files/templates/comments.html
@@ -314,13 +314,7 @@
 			
{{c.realbody(v) | safe}} {% if c.options %} - {% for o in c.options %} -
- - -
- {% endfor %} -

+					{{c.options_html(v) | safe}}
 				{% endif %}
 
 				{% if c.author.sig_html and (c.author_id == 1904 or not (v and v.sigs_disabled)) %}
@@ -844,7 +838,6 @@
 
 {% include "expanded_image_modal.html" %}
 
-{% set commtimes = []}
 
 
 
# Name Score
{{loop.index}} {{user.username}}{% if user.admin_level == 1 and v and v.admin_level > 1 %}{% endif %} {{user.truecoins}}