sigs toggle

master
Aevann1 2021-11-04 19:24:43 +02:00
parent 1c9f308a6f
commit 16032ec1aa
5 changed files with 31 additions and 4 deletions

View File

@ -316,7 +316,7 @@ class Comment(Base):
url_noquery = url.split('?')[0]
body = body.replace(url, f"{url_noquery}?{urlencode(p, True)}")
if self.author.sig_html: return body + '<hr>' + self.author.sig_html
if self.author.sig_html and not (v and v.sigs_disabled): return body + '<hr>' + self.author.sig_html
return body
def plainbody(self, v):

View File

@ -316,7 +316,7 @@ class Submission(Base):
if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if self.author.sig_html: return body + '<hr>' + self.author.sig_html
if self.author.sig_html and not (v and v.sigs_disabled): return body + '<hr>' + self.author.sig_html
return body
def plainbody(self, v):

View File

@ -86,6 +86,7 @@ class User(Base):
bio_html = Column(String)
sig = Column(String)
sig_html = Column(String)
sigs_disabled = Column(Boolean)
friends = Column(String)
friends_html = Column(String)
is_banned = Column(Integer, default=0)

View File

@ -89,6 +89,10 @@ def settings_profile_post(v):
updated = True
v.controversial = request.values.get("controversial", None) == 'true'
if request.values.get("sigs_disabled", v.sigs_disabled) != v.sigs_disabled:
updated = True
v.sigs_disabled = request.values.get("sigs_disabled", None) == 'true'
if request.values.get("over18", v.over_18) != v.over_18:
updated = True
v.over_18 = request.values.get("over18", None) == 'true'

View File

@ -219,6 +219,28 @@
<div class="settings-section rounded">
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="sigs_disabled">Disable signatures</label>
</div>
<div class="body w-lg-100">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="sigs_disabled" name="sigs_disabled"{% if v.sigs_disabled %} checked{% endif %} onchange="post_toast('/settings/profile?sigs_disabled='+document.getElementById('sigs_disabled').checked);">
<label class="custom-control-label" for="sigs_disabled"></label>
</div>
<span class="text-small-extra text-muted">Disable seeing user signatures.</span>
</div>
</div>
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
@ -228,7 +250,7 @@
<div class="body w-lg-100">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="over18" name="over18"{% if v.over_18 %} checked{% endif %} onchange="post_toast('/settings/profile?over18='+document.getElementById('over18').checked);document.getElementById('filter-nsfw-option').classList.toggle('d-none')">
<input type="checkbox" class="custom-control-input" id="over18" name="over18"{% if v.over_18 %} checked{% endif %} onchange="post_toast('/settings/profile?over18='+document.getElementById('over18').checked);">
<label class="custom-control-label" for="over18"></label>
</div>
@ -292,7 +314,7 @@
<div class="input-group mb-2">
<textarea class="form-control rounded" id="filters-text" aria-label="With textarea"
placeholder="Add your own custom content filters."
rows="3" name="filters" form="custom-filter" maxlength="1000">{{v.custom_filter_list}}</textarea>
rows="3" name="filters" form="custom-filter" maxlength="1000">{% if v.custom_filter_list %}{{v.custom_filter_list}}{% endif %}</textarea>
</div>
<div class="d-flex">
<small>Use a new line for each filter entry. Limit of 1000 characters.</small>