master
Aevann1 2021-12-04 01:34:03 +02:00
parent e30fa3bbea
commit 7da6bb8a58
6 changed files with 41 additions and 10 deletions

View File

@ -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'<div class="custom-control"><input type="checkbox" class="custom-control-input" id="{o.id}" name="option"'
if o.poll_voted(v): html += " checked"
html += f''' onchange="poll_vote('{o.id}', '{self.id}')"><label class="custom-control-label" for="{o.id}">{o.body_html}<span class="presult-{self.id}'''
if not self.total_poll_voted(v): html += ' d-none'
html += f'"> - <a href="/votes?link=t3_{o.id}"><span id="poll-{o.id}">{o.upvotes}</span> votes</a></span></label></div><pre></pre>'
return html
class Notification(Base):

View File

@ -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/<cid>")

View File

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

View File

@ -9,12 +9,14 @@
<table class="table table-striped mb-5">
<thead class="bg-primary text-white">
<tr>
<th style="font-weight:bold;">#</th>
<th style="font-weight:bold;">Name</th>
<th style="font-weight:bold; text-align:right;">Score</th>
</tr>
</thead>
{% for user in admins %}
<tr>
<td style="font-weight:bold;">{{loop.index}}</td>
<td><a style="color:#{{user.namecolor}};font-weight:bold;" href="/@{{user.username}}"><img loading="lazy" src="/uid/{{user.id}}/pic" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.namecolor}};"{% endif %}>{{user.username}}</span></a>{% if user.admin_level == 1 and v and v.admin_level > 1 %}<i class="fas fa-broom align-middle ml-2 color-white" data-bs-toggle="tooltip" data-bs-placement="bottom" data-bs-original-title="Meme Admin"></i>{% endif %}</td>
<td style="font-weight:bold; text-align:right;">{{user.truecoins}}</td>
</tr>

View File

@ -314,13 +314,7 @@
<div id="comment-text-{{c.id}}" class="comment-text mb-0">
{{c.realbody(v) | safe}}
{% if c.options %}
{% for o in c.options %}
<div class="custom-control">
<input type="checkbox" class="custom-control-input" id="{{o.id}}" name="option" {% if o.poll_voted(v) %}checked{% endif %} onchange="poll_vote('{{o.id}}', '{{c.id}}')">
<label class="custom-control-label" for="{{o.id}}">{{o.body_html | safe}}<span class="presult-{{c.id}} {% if not c.total_poll_voted(v) %}d-none{% endif %}"> - <a href="/votes?link=t3_{{o.id}}"><span id="poll-{{o.id}}">{{o.upvotes}}</span> votes</a></span></label>
</div>
{% endfor %}
<pre></pre>
{{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 = []}
<script defer src="/assets/js/popover.js?v=9"></script>
<script>

View File

@ -63,6 +63,11 @@ On {{'SITE_NAME' | app_config}}, you can use Markdown formatting.
<td>:!marseylove:</td>
<td><img loading="lazy" data-bs-toggle="tooltip" class="mirrored" alt=":!marseylove:" data-bs-original-title=":!marseylove:" delay="0" height="20" src="/assets/images/emojis/marseylove.webp?v=1"></td>
</tr>
<tr>
<td>Large Emojis</td>
<td>:#marseylove:</td>
<td><img loading="lazy" data-bs-toggle="tooltip" class="mirrored" alt=":!marseylove:" data-bs-original-title=":!marseylove:" delay="0" src="/assets/images/emojis/marseylove.webp?v=1"></td>
</tr>
<tr>
<td>Poll Options</td>
<td>$$bussy$$</td>