teddit urls
This commit is contained in:
parent
ae5c3125ee
commit
8569450f10
5 changed files with 41 additions and 7 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue