Add ability to redirect reddit.com to libredd.it (#180)
* Adds the ability to redirect reddit.com to libredd.it using the existing "site alts" config setting. This adds the WHOOGLE_ALT_RD environment variable for optionally redirecting reddit links to libreddit (https://github.com/spikecodes/libreddit). * Include libreddit in home page site alt notemain
parent
b57c86a1d0
commit
6600d8580c
|
@ -45,6 +45,8 @@ ARG youtube_alt='invidious.snopyta.org'
|
||||||
ENV WHOOGLE_ALT_YT=$youtube_alt
|
ENV WHOOGLE_ALT_YT=$youtube_alt
|
||||||
ARG instagram_alt='bibliogram.art/u'
|
ARG instagram_alt='bibliogram.art/u'
|
||||||
ENV WHOOGLE_ALT_YT=$instagram_alt
|
ENV WHOOGLE_ALT_YT=$instagram_alt
|
||||||
|
ARG reddit_alt='libredd.it'
|
||||||
|
ENV WHOOGLE_ALT_RD=$reddit_alt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ Description=Whoogle
|
||||||
#Environment=WHOOGLE_ALT_TW=nitter.net
|
#Environment=WHOOGLE_ALT_TW=nitter.net
|
||||||
#Environment=WHOOGLE_ALT_YT=invidious.snopyta.org
|
#Environment=WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
#Environment=WHOOGLE_ALT_IG=bibliogram.art/u
|
#Environment=WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
|
#Environment=WHOOGLE_ALT_RD=libredd.it
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=<whoogle_directory>
|
WorkingDirectory=<whoogle_directory>
|
||||||
|
|
11
app.json
11
app.json
|
@ -47,17 +47,22 @@
|
||||||
},
|
},
|
||||||
"WHOOGLE_ALT_TW": {
|
"WHOOGLE_ALT_TW": {
|
||||||
"description": "The site to use as a replacement for twitter.com when site alternatives are enabled in the config.",
|
"description": "The site to use as a replacement for twitter.com when site alternatives are enabled in the config.",
|
||||||
"value": "",
|
"value": "nitter.net",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
"WHOOGLE_ALT_YT": {
|
"WHOOGLE_ALT_YT": {
|
||||||
"description": "The site to use as a replacement for youtube.com when site alternatives are enabled in the config.",
|
"description": "The site to use as a replacement for youtube.com when site alternatives are enabled in the config.",
|
||||||
"value": "",
|
"value": "invidious.snopyta.org",
|
||||||
"required": false
|
"required": false
|
||||||
},
|
},
|
||||||
"WHOOGLE_ALT_IG": {
|
"WHOOGLE_ALT_IG": {
|
||||||
"description": "The site to use as a replacement for instagram.com when site alternatives are enabled in the config.",
|
"description": "The site to use as a replacement for instagram.com when site alternatives are enabled in the config.",
|
||||||
"value": "",
|
"value": "bibliogram.art/u",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
"WHOOGLE_ALT_RD": {
|
||||||
|
"description": "The site to use as a replacement for reddit.com when site alternatives are enabled in the config.",
|
||||||
|
"value": "libredd.it",
|
||||||
"required": false
|
"required": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@
|
||||||
<div class="config-div">
|
<div class="config-div">
|
||||||
<label class="tooltip" for="config-alts">Replace Social Media Links: </label>
|
<label class="tooltip" for="config-alts">Replace Social Media Links: </label>
|
||||||
<input type="checkbox" name="alts" id="config-alts">
|
<input type="checkbox" name="alts" id="config-alts">
|
||||||
<div><span class="info-text"> — Replaces Twitter/YouTube/Instagram links
|
<div><span class="info-text"> — Replaces Twitter/YouTube/Instagram/Reddit links
|
||||||
with Nitter/Invidious/Bibliogram links.</span></div>
|
with Nitter/Invidious/Bibliogram/Libreddit links.</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="config-div">
|
<div class="config-div">
|
||||||
<label for="config-new-tab">Open Links in New Tab: </label>
|
<label for="config-new-tab">Open Links in New Tab: </label>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import urllib.parse as urlparse
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
SKIP_ARGS = ['ref_src', 'utm']
|
SKIP_ARGS = ['ref_src', 'utm']
|
||||||
|
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
|
||||||
FULL_RES_IMG = '<br/><a href="{}">Full Image</a>'
|
FULL_RES_IMG = '<br/><a href="{}">Full Image</a>'
|
||||||
GOOG_IMG = '/images/branding/searchlogo/1x/googlelogo'
|
GOOG_IMG = '/images/branding/searchlogo/1x/googlelogo'
|
||||||
LOGO_URL = GOOG_IMG + '_desk'
|
LOGO_URL = GOOG_IMG + '_desk'
|
||||||
|
@ -22,7 +23,8 @@ BLACKLIST = [
|
||||||
SITE_ALTS = {
|
SITE_ALTS = {
|
||||||
'twitter.com': os.getenv('WHOOGLE_ALT_TW', 'nitter.net'),
|
'twitter.com': os.getenv('WHOOGLE_ALT_TW', 'nitter.net'),
|
||||||
'youtube.com': os.getenv('WHOOGLE_ALT_YT', 'invidious.snopyta.org'),
|
'youtube.com': os.getenv('WHOOGLE_ALT_YT', 'invidious.snopyta.org'),
|
||||||
'instagram.com': os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u')
|
'instagram.com': os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u'),
|
||||||
|
'reddit.com': os.getenv('WHOOGLE_ALT_RD', 'libredd.it')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +49,10 @@ def get_site_alt(link: str):
|
||||||
link = link.replace(site_key, SITE_ALTS[site_key])
|
link = link.replace(site_key, SITE_ALTS[site_key])
|
||||||
break
|
break
|
||||||
|
|
||||||
return link.replace('www.', '').replace('//m.', '//')
|
for prefix in SKIP_PREFIX:
|
||||||
|
link = link.replace(prefix, '//')
|
||||||
|
|
||||||
|
return link
|
||||||
|
|
||||||
|
|
||||||
def filter_link_args(query_link):
|
def filter_link_args(query_link):
|
||||||
|
|
|
@ -19,6 +19,7 @@ services:
|
||||||
#- WHOOGLE_ALT_TW=nitter.net
|
#- WHOOGLE_ALT_TW=nitter.net
|
||||||
#- WHOOGLE_ALT_YT=invidious.snopyta.org
|
#- WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
#- WHOOGLE_ALT_IG=bibliogram.art/u
|
#- WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
|
#- WHOOGLE_ALT_RD=libredd.it
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
Loading…
Reference in New Issue