teddit urls

remotes/1693045480750635534/spooky-22
CaringCleaner 2021-11-19 23:05:28 +00:00
parent e1c89e694e
commit 05c33e163f
5 changed files with 41 additions and 7 deletions

View File

@ -312,9 +312,11 @@ class Comment(Base):
body = censor_slurs(body, v)
if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v:
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif 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 v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v and v.controversial:
for i in re.finditer('(/comments/.*?)"', body):

View File

@ -308,7 +308,8 @@ class Submission(Base):
return 'https://secure.actblue.com/donate/ms_blm_homepage_2019'
elif v and self.url and self.url.startswith("https://old.reddit.com/"):
url = self.url
if not v.oldreddit: url = self.url.replace("old.reddit.com", "reddit.com")
if v.teddit: url = self.url.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: url = self.url.replace("old.reddit.com", "reddit.com")
if v.controversial and '/comments/' in url and "sort=" not in url:
if "?" in url: url += "&sort=controversial"
else: url += "?sort=controversial"
@ -324,8 +325,11 @@ class Submission(Base):
body = self.body_html
body = censor_slurs(body, v)
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 v:
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
if v and v.shadowbanned and v.id == self.author_id and 86400 > time.time() - self.created_utc > 600:
rand = random.randint(1,16)
@ -342,8 +346,12 @@ class Submission(Base):
body = self.body
body = censor_slurs(body, v)
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 v:
if v.teddit: body = body.replace("old.reddit.com", "teddit.net")
elif not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com")
if v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net")
return body
@lazy

View File

@ -79,6 +79,7 @@ class User(Base):
newtab = Column(Boolean, default=False)
newtabexternal = Column(Boolean, default=True)
oldreddit = Column(Boolean, default=True)
teddit = Column(Boolean, default=False)
nitter = Column(Boolean)
mute = Column(Boolean)
unmutable = Column(Boolean)

View File

@ -83,6 +83,10 @@ def settings_profile_post(v):
updated = True
v.oldreddit = request.values.get("oldreddit", None) == 'true'
elif request.values.get("teddit", v.teddit) != v.teddit:
updated = True
v.teddit = request.values.get("teddit", None) == 'true'
elif request.values.get("nitter", v.nitter) != v.nitter:
updated = True
v.nitter = request.values.get("nitter", None) == 'true'

View File

@ -176,6 +176,25 @@
<div class="settings-section rounded">
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="oldreddit">Use Teddit.net</label>
</div>
<div class="body w-lg-100">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="teddit" name="teddit"{% if v.teddit %} checked{% endif %} onchange="post_toast('/settings/profile?teddit='+document.getElementById('teddit').checked);">
<label class="custom-control-label" for="teddit"></label>
</div>
<span class="text-small-extra text-muted">Enable if you would like to automatically convert reddit.com links to teddit.net links.</span>
</div>
</div>
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">