From 119437a07cff549305baa73abbe7518d0c20f5b1 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Sun, 19 Dec 2021 11:22:47 -0700 Subject: [PATCH 1/4] Fix test for blocking site from results Previously the logic for testing site blocking was essentially "assert blocked_site not part of result_site". This caused test failures, since site blocking does not extend to subdomains for the blocked site. The reversed logic makes more sense with what the test was trying to accomplish. --- test/test_results.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_results.py b/test/test_results.py index 8327973..f8036d8 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -75,7 +75,7 @@ def test_block_results(client): assert has_pinterest - demo_config['block'] = 'pinterest.com,help.pinterest.com' + demo_config['block'] = 'pinterest.com' rv = client.post(f'/{Endpoint.config}', data=demo_config) assert rv._status_code == 302 @@ -83,7 +83,10 @@ def test_block_results(client): assert rv._status_code == 200 for link in BeautifulSoup(rv.data, 'html.parser').find_all('a', href=True): - assert 'pinterest.com' not in urlparse(link['href']).netloc + result_site = urlparse(link['href']).netloc + if not result_site: + continue + assert result_site not in 'pinterest.com' def test_recent_results(client): From c637eb28dd31653283d07bfeef9c581486984326 Mon Sep 17 00:00:00 2001 From: glitsj16 Date: Sun, 19 Dec 2021 18:42:52 +0000 Subject: [PATCH 2/4] Add missing env vars to readme [skip ci] (#584) --- README.md | 1 + whoogle.template.env | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index c7b09d9..bccba99 100644 --- a/README.md +++ b/README.md @@ -331,6 +331,7 @@ There are a few optional environment variables available for customizing a Whoog | WHOOGLE_AUTOCOMPLETE | Controls visibility of autocomplete/search suggestions. Default on -- use '0' to disable | | WHOOGLE_MINIMAL | Remove everything except basic result cards from all search queries. | | WHOOGLE_CSP | Sets a default set of 'Content-Security-Policy' headers | +| WHOOGLE_RESULTS_PER_PAGE | Set the number of results per page | ### Config Environment Variables These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time. diff --git a/whoogle.template.env b/whoogle.template.env index ae9c9a4..0fb97ad 100644 --- a/whoogle.template.env +++ b/whoogle.template.env @@ -61,6 +61,18 @@ # Search using GET requests only (exposes query in logs) #WHOOGLE_CONFIG_GET_ONLY=1 +# Remove everything except basic result cards from all search queries +#WHOOGLE_MINIMAL=0 + +# Set the number of results per page +#WHOOGLE_RESULTS_PER_PAGE=10 + +# Controls visibility of autocomplete/search suggestions +#WHOOGLE_AUTOCOMPLETE=1 + +# The port where Whoogle will be exposed +#EXPOSE_PORT=5000 + # Set instance URL #WHOOGLE_CONFIG_URL=https:/// From f6c084318390c3852b64e2a9f43a654b88638185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C3=B1o=20Sempere?= Date: Sun, 19 Dec 2021 19:52:15 +0100 Subject: [PATCH 3/4] Update systemd instructions [skip ci] (#571) --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bccba99..e04e82d 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ pip install -r requirements.txt See the [available environment variables](#environment-variables) for additional configuration. #### systemd Configuration -After building the virtual environment, you can add the following to `/lib/systemd/system/whoogle.service` to set up a Whoogle Search systemd service: +After building the virtual environment, you can add something like the following to `/lib/systemd/system/whoogle.service` to set up a Whoogle Search systemd service: ```ini [Unit] @@ -207,8 +207,14 @@ Description=Whoogle #Environment=WHOOGLE_DOTENV=1 Type=simple User= -WorkingDirectory= -ExecStart=/venv/bin/python3 -um app --host 0.0.0.0 --port 5000 +# If installed as a package, add: +ExecStart=/python3 /whoogle-search --host 127.0.0.1 --port 5000 +# For example: +# ExecStart=/usr/bin/python3 /home/my_username/.local/bin/whoogle-search --host 127.0.0.1 --port 5000 +# Otherwise if running the app from source, add: +ExecStart=/run +# For example: +# ExecStart=/var/www/whoogle-search/run ExecReload=/bin/kill -HUP $MAINPID Restart=always RestartSec=3 From dec6d80ddaa106efba45285e082b0fea847c7120 Mon Sep 17 00:00:00 2001 From: Roy Zuo <62289+roylez@users.noreply.github.com> Date: Mon, 20 Dec 2021 04:59:06 +1000 Subject: [PATCH 4/4] Use alpine docker image (#573) --- Dockerfile | 57 +++++++++++++++++++------------------------ misc/tor/start-tor.sh | 6 ++++- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index cbfb305..8205987 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,57 @@ -FROM python:3.8-slim as builder +FROM python:3.8-alpine as builder -RUN apt-get update && apt-get install -y \ - build-essential \ +RUN apk --update add \ + build-base \ libxml2-dev \ libxslt-dev \ - libssl-dev \ + openssl-dev \ libffi-dev - + COPY requirements.txt . RUN pip install --prefix /install --no-warn-script-location --no-cache-dir -r requirements.txt -FROM python:3.8-slim +FROM python:3.8-alpine -RUN apt-get update && apt-get install -y \ - libcurl4-openssl-dev \ - tor \ - curl \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --update --no-cache tor curl bash openrc +# libcurl4-openssl-dev ARG config_dir=/config RUN mkdir -p $config_dir VOLUME $config_dir -ENV CONFIG_VOLUME=$config_dir ARG username='' -ENV WHOOGLE_USER=$username ARG password='' -ENV WHOOGLE_PASS=$password - ARG proxyuser='' -ENV WHOOGLE_PROXY_USER=$proxyuser ARG proxypass='' -ENV WHOOGLE_PROXY_PASS=$proxypass ARG proxytype='' -ENV WHOOGLE_PROXY_TYPE=$proxytype ARG proxyloc='' -ENV WHOOGLE_PROXY_LOC=$proxyloc - ARG whoogle_dotenv='' -ENV WHOOGLE_DOTENV=$whoogle_dotenv - ARG use_https='' -ENV HTTPS_ONLY=$use_https - ARG whoogle_port=5000 -ENV EXPOSE_PORT=$whoogle_port - ARG twitter_alt='farside.link/nitter' -ENV WHOOGLE_ALT_TW=$twitter_alt ARG youtube_alt='farside.link/invidious' -ENV WHOOGLE_ALT_YT=$youtube_alt ARG instagram_alt='farside.link/bibliogram' -ENV WHOOGLE_ALT_IG=$instagram_alt ARG reddit_alt='farside.link/libreddit' -ENV WHOOGLE_ALT_RD=$reddit_alt ARG medium_alt='farside.link/scribe' -ENV WHOOGLE_ALT_MD=$medium_alt ARG translate_alt='lingva.ml' -ENV WHOOGLE_ALT_TL=$translate_alt + +ENV CONFIG_VOLUME=$config_dir \ + WHOOGLE_USER=$username \ + WHOOGLE_PASS=$password \ + WHOOGLE_PROXY_USER=$proxyuser \ + WHOOGLE_PROXY_PASS=$proxypass \ + WHOOGLE_PROXY_TYPE=$proxytype \ + WHOOGLE_PROXY_LOC=$proxyloc \ + WHOOGLE_DOTENV=$whoogle_dotenv \ + HTTPS_ONLY=$use_https \ + EXPOSE_PORT=$whoogle_port \ + WHOOGLE_ALT_TW=$twitter_alt \ + WHOOGLE_ALT_YT=$youtube_alt \ + WHOOGLE_ALT_IG=$instagram_alt \ + WHOOGLE_ALT_RD=$reddit_alt \ + WHOOGLE_ALT_MD=$medium_alt \ + WHOOGLE_ALT_TL=$translate_alt WORKDIR /whoogle diff --git a/misc/tor/start-tor.sh b/misc/tor/start-tor.sh index 19be24a..e29241f 100755 --- a/misc/tor/start-tor.sh +++ b/misc/tor/start-tor.sh @@ -3,5 +3,9 @@ if [ "$(whoami)" != "root" ]; then tor -f /etc/tor/torrc else - service tor start + if (grep alpine /etc/os-release >/dev/null); then + rc-service tor start + else + service tor start + fi fi