add imginn toggle

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-15 19:45:43 +02:00
parent 067eb208a2
commit 8e48728614
5 changed files with 40 additions and 0 deletions

View File

@ -22,6 +22,7 @@ def normalize_urls_runtime(body, v):
if v and v.reddit != 'old.reddit.com':
body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body)
if v.nitter: body = twitter_to_nitter_regex.sub(r'https://nitter.42l.fr/\1', body)
if v.imginn: body = body.replace('https://instagram.com/', 'https://imginn.com/')
return body

View File

@ -82,6 +82,7 @@ class User(Base):
newtabexternal = Column(Boolean, default=True)
reddit = Column(String, default='old.reddit.com')
nitter = Column(Boolean)
imginn = Column(Boolean)
mute = Column(Boolean)
unmutable = Column(Boolean)
eye = Column(Boolean)

View File

@ -100,6 +100,10 @@ def execute_snappy(post, v):
newposturl = newposturl.replace('https://twitter.com/', 'https://nitter.42l.fr/')
gevent.spawn(archiveorg, newposturl)
if newposturl.startswith('https://instagram.com/'):
newposturl = newposturl.replace('https://instagram.com/', 'https://imginn.com/')
gevent.spawn(archiveorg, newposturl)
captured = []
body_for_snappy = post.body_html.replace(' data-src="', ' src="')
@ -138,6 +142,10 @@ def execute_snappy(post, v):
href = href.replace('https://twitter.com/', 'https://nitter.42l.fr/')
gevent.spawn(archiveorg, href)
if href.startswith('https://instagram.com/'):
href = href.replace('https://instagram.com/', 'https://imginn.com/')
gevent.spawn(archiveorg, href)
body = body.strip()
body_html = sanitize(body)

View File

@ -80,6 +80,10 @@ def settings_profile_post(v):
updated = True
v.nitter = request.values.get("nitter") == 'true'
elif request.values.get("imginn", v.imginn) != v.imginn:
updated = True
v.imginn = request.values.get("imginn") == 'true'
elif request.values.get("controversial", v.controversial) != v.controversial:
updated = True
v.controversial = request.values.get("controversial") == 'true'

View File

@ -211,6 +211,32 @@
</div>
<h2 class="h5">Instagram Links</h2>
<div class="settings-section rounded">
<div class="d-lg-flex border-bottom">
<div class="title w-lg-25">
<label for="imginn">Use Imginn</label>
</div>
<div class="body w-lg-100">
<div class="custom-control custom-switch">
<input autocomplete="off" type="checkbox" class="custom-control-input" id="imginn" name="imginn"{% if v.imginn %} checked{% endif %} onchange="post_toast(this,'/settings/profile?imginn='+document.getElementById('imginn').checked);">
<label class="custom-control-label" for="imginn"></label>
</div>
<span class="text-small text-muted">Enable if you would like to automatically convert instagram.com links to imginn.com links.</span>
</div>
</div>
</div>
<h2 class="h5">Reddit Links</h2>
<div class="settings-section rounded">