Conditionally set env vars from whoogle.env
This allows the user to enable their preferred settings in a variety of ways, depending on their deployment preference. Values added to whoogle.env can be enabled using WHOOGLE_DOTENV=1, in which case all values in the env var file will overwrite defaults or user provided settings.
This commit is contained in:
parent
d6f579dee6
commit
6280728ee5
12
.env
12
.env
|
@ -1,12 +0,0 @@
|
||||||
# This is the only file you have to change for configuring your installation
|
|
||||||
|
|
||||||
# Work done ------------------------
|
|
||||||
# Setting up social media sites
|
|
||||||
# Change the domain as per your requirements. Don't forget to rebuild your Docker or restart the app.
|
|
||||||
twitter=nitter.net
|
|
||||||
youtube=invidious.snopyta.org
|
|
||||||
instagram=bibliogram.art/u
|
|
||||||
reddit=libredd.it
|
|
||||||
|
|
||||||
# Plan
|
|
||||||
# For setting dark, Language, enable Replace Social Media Links etc
|
|
|
@ -37,6 +37,9 @@ ENV WHOOGLE_PROXY_TYPE=$proxytype
|
||||||
ARG proxyloc=''
|
ARG proxyloc=''
|
||||||
ENV WHOOGLE_PROXY_LOC=$proxyloc
|
ENV WHOOGLE_PROXY_LOC=$proxyloc
|
||||||
|
|
||||||
|
ARG whoogle_dotenv=''
|
||||||
|
ENV WHOOGLE_DOTENV=$whoogle_dotenv
|
||||||
|
|
||||||
ARG use_https=''
|
ARG use_https=''
|
||||||
ENV HTTPS_ONLY=$use_https
|
ENV HTTPS_ONLY=$use_https
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ COPY misc/tor/torrc /etc/tor/torrc
|
||||||
COPY misc/tor/start-tor.sh misc/tor/start-tor.sh
|
COPY misc/tor/start-tor.sh misc/tor/start-tor.sh
|
||||||
COPY app/ app/
|
COPY app/ app/
|
||||||
COPY run .
|
COPY run .
|
||||||
|
COPY whoogle.env .
|
||||||
|
|
||||||
EXPOSE $EXPOSE_PORT
|
EXPOSE $EXPOSE_PORT
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ Description=Whoogle
|
||||||
#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
|
#Environment=WHOOGLE_ALT_RD=libredd.it
|
||||||
|
# Load values from dotenv only
|
||||||
|
#Environment=WHOOGLE_DOTENV=1
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=<whoogle_directory>
|
WorkingDirectory=<whoogle_directory>
|
||||||
|
@ -233,10 +235,11 @@ Depending on your preferences, you can also deploy the app yourself on your own
|
||||||
- A bit more experience or willingness to work through issues
|
- A bit more experience or willingness to work through issues
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
There are a few optional environment variables available for customizing a Whoogle instance:
|
There are a few optional environment variables available for customizing a Whoogle instance. These can be set manually, or copied into `whoogle.env` and enabled by setting `WHOOGLE_DOTENV=1`.
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ------------------ | -------------------------------------------------------------- |
|
| ------------------ | -------------------------------------------------------------- |
|
||||||
|
| WHOOGLE_DOTENV | Load environment variables in `whoogle.env` |
|
||||||
| WHOOGLE_USER | The username for basic auth. WHOOGLE_PASS must also be set if used. |
|
| WHOOGLE_USER | The username for basic auth. WHOOGLE_PASS must also be set if used. |
|
||||||
| WHOOGLE_PASS | The password for basic auth. WHOOGLE_USER must also be set if used. |
|
| WHOOGLE_PASS | The password for basic auth. WHOOGLE_USER must also be set if used. |
|
||||||
| WHOOGLE_PROXY_USER | The username of the proxy server. |
|
| WHOOGLE_PROXY_USER | The username of the proxy server. |
|
||||||
|
|
|
@ -6,9 +6,17 @@ from flask_session import Session
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from stem import Signal
|
from stem import Signal
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
app = Flask(__name__, static_folder=os.path.dirname(
|
app = Flask(__name__, static_folder=os.path.dirname(
|
||||||
os.path.abspath(__file__)) + '/static')
|
os.path.abspath(__file__)) + '/static')
|
||||||
|
|
||||||
|
# Load .env file if enabled
|
||||||
|
if os.getenv("WHOOGLE_DOTENV", ''):
|
||||||
|
dotenv_path = '../whoogle.env'
|
||||||
|
load_dotenv(os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
dotenv_path))
|
||||||
|
|
||||||
app.user_elements = {}
|
app.user_elements = {}
|
||||||
app.default_key_set = generate_user_keys()
|
app.default_key_set = generate_user_keys()
|
||||||
app.no_cookie_ips = []
|
app.no_cookie_ips = []
|
||||||
|
|
|
@ -3,9 +3,6 @@ import os
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
# For .env reading
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv(os.path.join(os.path.abspath(os.getcwd()), '.env'))
|
|
||||||
|
|
||||||
SKIP_ARGS = ['ref_src', 'utm']
|
SKIP_ARGS = ['ref_src', 'utm']
|
||||||
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
|
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
|
||||||
|
@ -25,32 +22,13 @@ BLACKLIST = [
|
||||||
'Reklāma', 'Reklaam', 'Διαφήμιση', 'מודעה', 'Hirdetés', 'Anúncio'
|
'Reklāma', 'Reklaam', 'Διαφήμιση', 'מודעה', 'Hirdetés', 'Anúncio'
|
||||||
]
|
]
|
||||||
|
|
||||||
# Setting up ALTs site Links
|
SITE_ALTS = {
|
||||||
SITE_ALTS = {}
|
'twitter.com': os.getenv('WHOOGLE_ALT_TW', 'nitter.net'),
|
||||||
def get_alt_links():
|
'youtube.com': os.getenv('WHOOGLE_ALT_YT', 'invidious.snopyta.org'),
|
||||||
print("Setting up alternative social media site..")
|
'instagram.com': os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u'),
|
||||||
tw,yt,ig,rd = os.getenv("twitter"),os.getenv("youtube"),os.getenv("instagram"),os.getenv("reddit")
|
'reddit.com': os.getenv('WHOOGLE_ALT_RD', 'libredd.it')
|
||||||
if tw != None and tw != "":
|
}
|
||||||
SITE_ALTS['twitter.com']=tw
|
|
||||||
else:
|
|
||||||
SITE_ALTS['twitter.com']=os.getenv('WHOOGLE_ALT_TW', 'nitter.net')
|
|
||||||
|
|
||||||
if yt != None and yt != "":
|
|
||||||
SITE_ALTS['youtube.com']=yt
|
|
||||||
else:
|
|
||||||
SITE_ALTS['youtube.com']=os.getenv('WHOOGLE_ALT_YT', 'invalid.com')
|
|
||||||
|
|
||||||
if ig != None and ig != "":
|
|
||||||
SITE_ALTS['instagram.com']=os.getenv("instagram")
|
|
||||||
else:
|
|
||||||
SITE_ALTS['instagram.com']=os.getenv('WHOOGLE_ALT_IG', 'bibliogram.art/u')
|
|
||||||
|
|
||||||
if rd != None and rd != "":
|
|
||||||
SITE_ALTS['reddit.com']=os.getenv("reddit")
|
|
||||||
else:
|
|
||||||
SITE_ALTS['reddit.com']=os.getenv('WHOOGLE_ALT_RD', 'libredd.it')
|
|
||||||
|
|
||||||
get_alt_links()
|
|
||||||
|
|
||||||
def has_ad_content(element: str) -> bool:
|
def has_ad_content(element: str) -> bool:
|
||||||
"""Inspects an HTML element for ad related content
|
"""Inspects an HTML element for ad related content
|
||||||
|
|
|
@ -37,6 +37,8 @@ services:
|
||||||
#- 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
|
#- WHOOGLE_ALT_RD=libredd.it
|
||||||
|
# Load environment variables from whoogle.env
|
||||||
|
#- WHOOGLE_DOTENV=1
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -31,4 +31,4 @@ urllib3==1.25.9
|
||||||
waitress==1.4.3
|
waitress==1.4.3
|
||||||
wcwidth==0.1.9
|
wcwidth==0.1.9
|
||||||
Werkzeug==0.16.0
|
Werkzeug==0.16.0
|
||||||
python-dotenv
|
python-dotenv==0.16.0
|
||||||
|
|
2
run
2
run
|
@ -22,5 +22,5 @@ else
|
||||||
mkdir -p "$STATIC_FOLDER"
|
mkdir -p "$STATIC_FOLDER"
|
||||||
python3 -um app \
|
python3 -um app \
|
||||||
--host "${ADDRESS:-0.0.0.0}" \
|
--host "${ADDRESS:-0.0.0.0}" \
|
||||||
--port "${PORT:-"${EXPOSE_PORT:-5000}"}"
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}" --debug
|
||||||
fi
|
fi
|
||||||
|
|
14
whoogle.env
Normal file
14
whoogle.env
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# You can set Whoogle environment variables here, but must set
|
||||||
|
# WHOOGLE_DOTENV=1 in your deployment to enable these values
|
||||||
|
|
||||||
|
#WHOOGLE_ALT_TW=nitter.net
|
||||||
|
#WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
|
#WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
|
#WHOOGLE_ALT_RD=libredd.it
|
||||||
|
#WHOOGLE_USER=""
|
||||||
|
#WHOOGLE_PASS=""
|
||||||
|
#WHOOGLE_PROXY_USER=""
|
||||||
|
#WHOOGLE_PROXY_PASS=""
|
||||||
|
#WHOOGLE_PROXY_TYPE=""
|
||||||
|
#WHOOGLE_PROXY_LOC=""
|
||||||
|
#HTTPS_ONLY=1
|
Loading…
Reference in New Issue
Block a user