From 0b70962e0c2cdccbee2768a23f901454473088dc Mon Sep 17 00:00:00 2001 From: nakoo <4975021+nakoo@users.noreply.github.com> Date: Wed, 26 Jan 2022 03:06:46 +0900 Subject: [PATCH 01/18] Fix docker-compose.yml permission errors (#623) --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 84c0502..c26f412 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,15 +11,15 @@ services: mem_limit: 256mb memswap_limit: 256mb # user debian-tor from tor package - user: '102' + user: whoogle security_opt: - no-new-privileges cap_drop: - ALL tmpfs: - - /config/:size=10M,uid=102,gid=102,mode=1700 - - /var/lib/tor/:size=10M,uid=102,gid=102,mode=1700 - - /run/tor/:size=1M,uid=102,gid=102,mode=1700 + - /config/:size=10M,uid=927,gid=927,mode=1700 + - /var/lib/tor/:size=10M,uid=927,gid=927,mode=1700 + - /run/tor/:size=1M,uid=927,gid=927,mode=1700 #environment: # Uncomment to configure environment variables # Basic auth configuration, uncomment to enable #- WHOOGLE_USER= From 6d178342ee3a2be941232f4f7fcf8093d2dfe5ff Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 11:42:29 -0700 Subject: [PATCH 02/18] Refactor Docker CI workflows Split previous docker test CI into one for PRs and one for triggering the main buildx workflow that deploys new images to Docker Hub. Note that this needs to be further refactored soon to use reusable workflows. The main portion of docker/docker-compose tests is duplicated between the new main + test workflows. --- .github/workflows/buildx.yml | 2 +- .github/workflows/docker_main.yml | 27 +++++++++++++++++++++++++++ .github/workflows/docker_tests.yml | 20 ++++++++++++-------- 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/docker_main.yml diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 8d201ce..515ffc9 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -2,7 +2,7 @@ name: buildx on: workflow_run: - workflows: ["docker_tests"] + workflows: ["docker_main"] branches: [main] types: - completed diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml new file mode 100644 index 0000000..754ff44 --- /dev/null +++ b/.github/workflows/docker_main.yml @@ -0,0 +1,27 @@ +name: docker_main + +on: + workflow_run: + workflows: ["tests"] + branches: [main] + types: + - completed + +# TODO: Needs refactoring to use reusable workflows and share w/ docker_tests +jobs: + on-success: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v2 + - name: build and test (docker) + run: | + docker build --tag whoogle-search:test . + docker run --publish 5000:5000 --detach --name whoogle-search whoogle-search:test + sleep 15 + docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 + - name: build and test (docker-compose) + run: | + docker-compose up --detach + sleep 15 + docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 diff --git a/.github/workflows/docker_tests.yml b/.github/workflows/docker_tests.yml index e3a3a2f..f0d7deb 100644 --- a/.github/workflows/docker_tests.yml +++ b/.github/workflows/docker_tests.yml @@ -1,21 +1,25 @@ name: docker_tests on: - workflow_run: - workflows: ["tests"] - branches: [main] - types: - - completed + push: + branches: main + pull_request: + branches: main jobs: - on-success: + docker: runs-on: ubuntu-latest steps: - name: checkout code uses: actions/checkout@v2 - - name: build and test + - name: build and test (docker) run: | docker build --tag whoogle-search:test . - docker run --publish 5000:5000 --detach --name whoogle-search whoogle-search:test + docker run --publish 5000:5000 --detach --name whoogle-search-nocompose whoogle-search:test + sleep 15 + docker exec whoogle-search-nocompose curl -f http://localhost:5000/healthz || exit 1 + - name: build and test (docker-compose) + run: | + docker-compose up --detach sleep 15 docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 From 72e5a227c83a06117257d63a073e0ac8e50ed30e Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 12:28:06 -0700 Subject: [PATCH 03/18] Move bangs init to bg thread Initializing the DDG bangs when running whoogle for the first time creates an indeterminate amount of delay before the app becomes usable, which makes usability tests (particularly w/ Docker) unreliable. This moves the bang json init to a background thread and writes a temporary empty dict to the bangs json file until the full bangs json can be used. --- .github/workflows/docker_main.yml | 5 +++-- .github/workflows/docker_tests.yml | 1 + app/__init__.py | 7 ++++++- app/routes.py | 14 +++++++++++++- app/utils/bangs.py | 1 + 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index 754ff44..c4ab678 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -17,11 +17,12 @@ jobs: - name: build and test (docker) run: | docker build --tag whoogle-search:test . - docker run --publish 5000:5000 --detach --name whoogle-search whoogle-search:test + docker run --publish 5000:5000 --detach --name whoogle-search-nocompose whoogle-search:test sleep 15 - docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 + docker exec whoogle-search-nocompose curl -f http://localhost:5000/healthz || exit 1 - name: build and test (docker-compose) run: | + docker rm -f whoogle-search-nocompose docker-compose up --detach sleep 15 docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 diff --git a/.github/workflows/docker_tests.yml b/.github/workflows/docker_tests.yml index f0d7deb..7eabdd9 100644 --- a/.github/workflows/docker_tests.yml +++ b/.github/workflows/docker_tests.yml @@ -20,6 +20,7 @@ jobs: docker exec whoogle-search-nocompose curl -f http://localhost:5000/healthz || exit 1 - name: build and test (docker-compose) run: | + docker rm -f whoogle-search-nocompose docker-compose up --detach sleep 15 docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 diff --git a/app/__init__.py b/app/__init__.py index 82c66fb..99daa01 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -9,6 +9,7 @@ import json import logging.config import os from stem import Signal +import threading from dotenv import load_dotenv app = Flask(__name__, static_folder=os.path.dirname( @@ -97,7 +98,11 @@ if not os.path.exists(app.config['SESSION_FILE_DIR']): if not os.path.exists(app.config['BANG_PATH']): os.makedirs(app.config['BANG_PATH']) if not os.path.exists(app.config['BANG_FILE']): - gen_bangs_json(app.config['BANG_FILE']) + json.dump({}, open(app.config['BANG_FILE'], 'w')) + bangs_thread = threading.Thread( + target=gen_bangs_json, + args=(app.config['BANG_FILE'],)) + bangs_thread.start() # Build new mapping of static files for cache busting if not os.path.exists(app.config['BUILD_FOLDER']): diff --git a/app/routes.py b/app/routes.py index 0cd9ecb..253db21 100644 --- a/app/routes.py +++ b/app/routes.py @@ -2,6 +2,7 @@ import argparse import base64 import io import json +import os import pickle import urllib.parse as urlparse import uuid @@ -26,7 +27,7 @@ from requests import exceptions, get from requests.models import PreparedRequest # Load DDG bang json files only on init -bang_json = json.load(open(app.config['BANG_FILE'])) +bang_json = json.load(open(app.config['BANG_FILE'])) or {} # Check the newest version of WHOOGLE update = bsoup(get(app.config['RELEASES_URL']).text, 'html.parser') @@ -101,6 +102,8 @@ def session_required(f): @app.before_request def before_request_func(): + global bang_json + g.request_params = ( request.args if request.method == 'GET' else request.form ) @@ -150,6 +153,15 @@ def before_request_func(): g.app_location = g.user_config.url + # Attempt to reload bangs json if not generated yet + if not bang_json and os.path.getsize(app.config['BANG_FILE']) > 4: + try: + bang_json = json.load(open(app.config['BANG_FILE'])) + except json.decoder.JSONDecodeError: + # Ignore decoding error, can occur if file is still + # being written + pass + @app.after_request def after_request_func(resp): diff --git a/app/utils/bangs.py b/app/utils/bangs.py index 23b3c04..4a1a3cb 100644 --- a/app/utils/bangs.py +++ b/app/utils/bangs.py @@ -35,6 +35,7 @@ def gen_bangs_json(bangs_file: str) -> None: } json.dump(bangs_data, open(bangs_file, 'w')) + print('* Finished creating ddg bangs json') def resolve_bang(query: str, bangs_dict: dict) -> str: From 863cbb2b8d75cce15463697ea047f3e99939c5d5 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 12:31:19 -0700 Subject: [PATCH 04/18] Remove trailing whitespace --- app/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/routes.py b/app/routes.py index 253db21..b8ddb45 100644 --- a/app/routes.py +++ b/app/routes.py @@ -158,7 +158,7 @@ def before_request_func(): try: bang_json = json.load(open(app.config['BANG_FILE'])) except json.decoder.JSONDecodeError: - # Ignore decoding error, can occur if file is still + # Ignore decoding error, can occur if file is still # being written pass From 2e3c647591430d6ab6fa2f271df5a8f3f66c314b Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 12:42:24 -0700 Subject: [PATCH 05/18] Use `test` image tag for docker-compose tests Also adds the ability to overwrite the image in docker-compose.yml, which allows the CI build to use the same image for all docker tests. The default is still 'benbusby/whoogle-search' though. --- .github/workflows/docker_main.yml | 2 +- .github/workflows/docker_tests.yml | 2 +- docker-compose.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker_main.yml b/.github/workflows/docker_main.yml index c4ab678..c41b693 100644 --- a/.github/workflows/docker_main.yml +++ b/.github/workflows/docker_main.yml @@ -23,6 +23,6 @@ jobs: - name: build and test (docker-compose) run: | docker rm -f whoogle-search-nocompose - docker-compose up --detach + WHOOGLE_IMAGE="whoogle-search:test" docker-compose up --detach sleep 15 docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 diff --git a/.github/workflows/docker_tests.yml b/.github/workflows/docker_tests.yml index 7eabdd9..52d1222 100644 --- a/.github/workflows/docker_tests.yml +++ b/.github/workflows/docker_tests.yml @@ -21,6 +21,6 @@ jobs: - name: build and test (docker-compose) run: | docker rm -f whoogle-search-nocompose - docker-compose up --detach + WHOOGLE_IMAGE="whoogle-search:test" docker-compose up --detach sleep 15 docker exec whoogle-search curl -f http://localhost:5000/healthz || exit 1 diff --git a/docker-compose.yml b/docker-compose.yml index c26f412..676a03c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ version: "2.4" services: whoogle-search: - image: benbusby/whoogle-search + image: ${WHOOGLE_IMAGE:-benbusby/whoogle-search} container_name: whoogle-search restart: unless-stopped pids_limit: 50 From 9cbd7bd9d36a67c139eca8fae5d58f63d1de6d1a Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 13:07:21 -0700 Subject: [PATCH 06/18] Remove bash dependency Depending on bash wasn't strictly necessary, as the two minimal scripts in the repo were both nearly POSIX anyways. Aside from simplifying the repo's dependencies a little bit, this also helps reduce the overall Docker image size as an added bonus. --- Dockerfile | 15 +++++++++------ misc/tor/start-tor.sh | 2 +- run | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index c9f2f20..b6f6483 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,9 +14,11 @@ RUN pip install --prefix /install --no-warn-script-location --no-cache-dir -r re FROM python:3.8-alpine -RUN apk add --update --no-cache tor curl bash openrc +RUN apk add --update --no-cache tor curl openrc # libcurl4-openssl-dev +RUN apk -U upgrade + ARG DOCKER_USER=whoogle ARG DOCKER_USERID=927 ARG config_dir=/config @@ -69,19 +71,20 @@ COPY app/ app/ COPY run . #COPY whoogle.env . -# Allow writing symlinks to build dir -RUN chown 102:102 app/static/build - # Create user/group to run as -RUN adduser -D -g $DOCKER_USERID -u $DOCKER_USERID $DOCKER_USER +RUN adduser -D -g $DOCKER_USERID -u $DOCKER_USERID $DOCKER_USER + # Fix ownership / permissions RUN chown -R ${DOCKER_USER}:${DOCKER_USER} /whoogle /var/lib/tor +# Allow writing symlinks to build dir +RUN chown $DOCKER_USERID:$DOCKER_USERID app/static/build + USER $DOCKER_USER:$DOCKER_USER EXPOSE $EXPOSE_PORT -HEALTHCHECK --interval=30s --timeout=5s \ +HEALTHCHECK --interval=30s --timeout=5s \ CMD curl -f http://localhost:${EXPOSE_PORT}/healthz || exit 1 CMD misc/tor/start-tor.sh & ./run diff --git a/misc/tor/start-tor.sh b/misc/tor/start-tor.sh index e29241f..7e7e282 100755 --- a/misc/tor/start-tor.sh +++ b/misc/tor/start-tor.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if [ "$(whoami)" != "root" ]; then tor -f /etc/tor/torrc diff --git a/run b/run index 9593201..2cc3cfe 100755 --- a/run +++ b/run @@ -1,11 +1,11 @@ -#!/bin/bash +#!/bin/sh # Usage: # ./run # Runs the full web app # ./run test # Runs the testing suite -set -euo pipefail +set -eu -SCRIPT_DIR="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +SCRIPT_DIR="$(CDPATH= command cd -- "$(dirname -- "$0")" && pwd -P)" # Set directory to serve static content from SUBDIR="${1:-app}" @@ -17,7 +17,7 @@ rm -f "$SCRIPT_DIR"/app/static/build/*.js rm -f "$SCRIPT_DIR"/app/static/build/*.css # Check for regular vs test run -if [[ "$SUBDIR" == "test" ]]; then +if [ "$SUBDIR" = "test" ]; then # Set up static files for testing rm -rf "$STATIC_FOLDER" ln -s "$SCRIPT_DIR/app/static" "$STATIC_FOLDER" From 4dd2c581ac45890c64f0406403370a3f3196364d Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 25 Jan 2022 13:52:43 -0700 Subject: [PATCH 07/18] Add nightly container vuln scan Introduces a new 'scan' workflow for scanning the main branch container for vulnerabilities nightly. By default, this will fail for any 'medium' or higher vulnerability. Fixes #613 --- .github/workflows/scan.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/scan.yml diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml new file mode 100644 index 0000000..8790e89 --- /dev/null +++ b/.github/workflows/scan.yml @@ -0,0 +1,19 @@ +name: scan + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build the container image + run: | + docker build --tag whoogle-search:test . + - name: Initiate grype scan + run: | + curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b . + chmod +x ./grype + ./grype whoogle-search:test --only-fixed From 1af4566991f5248fd0d3576ca4fbcc0a84293004 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 26 Jan 2022 10:41:41 -0700 Subject: [PATCH 08/18] Bump version to 0.7.1 --- app/__init__.py | 2 +- charts/whoogle/Chart.yaml | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 99daa01..ac626fb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -30,7 +30,7 @@ if os.getenv('HTTPS_ONLY'): app.config['SESSION_COOKIE_NAME'] = '__Secure-session' app.config['SESSION_COOKIE_SECURE'] = True -app.config['VERSION_NUMBER'] = '0.7.0' +app.config['VERSION_NUMBER'] = '0.7.1' app.config['APP_ROOT'] = os.getenv( 'APP_ROOT', os.path.dirname(os.path.abspath(__file__))) diff --git a/charts/whoogle/Chart.yaml b/charts/whoogle/Chart.yaml index 41d2a0e..f1561f4 100644 --- a/charts/whoogle/Chart.yaml +++ b/charts/whoogle/Chart.yaml @@ -3,7 +3,7 @@ name: whoogle description: A self hosted search engine on Kubernetes type: application version: 0.1.0 -appVersion: 0.7.0 +appVersion: 0.7.1 icon: https://github.com/benbusby/whoogle-search/raw/main/app/static/img/favicon/favicon-96x96.png diff --git a/setup.py b/setup.py index 8779ca8..f8f22c0 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setuptools.setup( author='Ben Busby', author_email='contact@benbusby.com', name='whoogle-search', - version='0.7.0' + optional_dev_tag, + version='0.7.1' + optional_dev_tag, include_package_data=True, install_requires=requirements, description='Self-hosted, ad-free, privacy-respecting metasearch engine', From 3918c60d87594b4398006cae3f12ac03081cf75a Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 10:11:18 -0700 Subject: [PATCH 09/18] Remove broken public instance [skip ci] search.exonip.de now redirects to startpage Fixes #635 --- README.md | 1 - misc/instances.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 5acef07..357eba2 100644 --- a/README.md +++ b/README.md @@ -517,7 +517,6 @@ A lot of the app currently piggybacks on Google's existing support for fetching | [https://whoogle.sdf.org](https://whoogle.sdf.org) | 🇺🇸 US | Multi-choice | | [https://search.garudalinux.org](https://search.garudalinux.org) | 🇩🇪 DE | Multi-choice | | | [https://whooglesearch.net](https://whooglesearch.net) | 🇩🇪 DE | Spanish | | -| [https://search.exonip.de](https://search.exonip.de) | 🇳🇱 NL | Multi-choice | | | [https://s.alefvanoon.xyz](https://s.alefvanoon.xyz) | 🇺🇸 US | Multi-choice | ✅ | | [https://www.whooglesearch.ml](https://www.whooglesearch.ml) | 🇺🇸 US | English | | | [https://search.sethforprivacy.com](https://search.sethforprivacy.com) | 🇩🇪 DE | English | | diff --git a/misc/instances.txt b/misc/instances.txt index 4d6da01..23694bd 100644 --- a/misc/instances.txt +++ b/misc/instances.txt @@ -1,6 +1,5 @@ https://s.alefvanoon.xyz https://search.albony.xyz -https://search.exonip.de https://search.garudalinux.org https://search.sethforprivacy.com https://whoogle.fossho.st From df6aa59fbf78c488871ba9c290235fdeed532fdd Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 10:55:41 -0700 Subject: [PATCH 10/18] Run buildx workflow on new tag Fixes #630 --- .github/workflows/buildx.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index 515ffc9..a0475e8 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -6,6 +6,9 @@ on: branches: [main] types: - completed + push: + tags: + - '*' jobs: on-success: From fef280a0c9dc69f5b38edf44a8eea8fe9416fe96 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 12:39:10 -0700 Subject: [PATCH 11/18] Add note for fosshost instance [skip ci] The fosshost team decommissioned the region that Whoogle was hosted in, but hasn't provided an option to transfer the domain record to the new VM. Until that is fixed, the instance is inaccessible. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 357eba2..87c0ff1 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ A lot of the app currently piggybacks on Google's existing support for fetching | Website | Country | Language | Cloudflare | |-|-|-|-| -| [https://whoogle.fossho.st](https://whoogle.fossho.st) | 🇺🇸 US | Multi-choice | | +| [https://whoogle.fossho.st](https://whoogle.fossho.st) (down until further notice) | 🇺🇸 US | Multi-choice | | | [https://search.albony.xyz](https://search.albony.xyz/) | 🇮🇳 IN | Multi-choice | | | [https://whoogle.sdf.org](https://whoogle.sdf.org) | 🇺🇸 US | Multi-choice | | [https://search.garudalinux.org](https://search.garudalinux.org) | 🇩🇪 DE | Multi-choice | | From 33f56bb0cb68e5e0d128d8076414aaf775318c48 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 15:29:22 -0700 Subject: [PATCH 12/18] Read `WHOOGLE_CONFIG_DISABLE` var as bool in app init Fixes #636, which pointed out that the var was being interpreted as "active" (config hidden) regardless of the value that was set. --- app/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index ac626fb..8ae241e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -2,7 +2,7 @@ from app.filter import clean_query from app.request import send_tor_signal from app.utils.session import generate_user_key from app.utils.bangs import gen_bangs_json -from app.utils.misc import gen_file_hash +from app.utils.misc import gen_file_hash, read_config_bool from flask import Flask from flask_session import Session import json @@ -58,7 +58,7 @@ app.config['CONFIG_PATH'] = os.getenv( app.config['DEFAULT_CONFIG'] = os.path.join( app.config['CONFIG_PATH'], 'config.json') -app.config['CONFIG_DISABLE'] = os.getenv('WHOOGLE_CONFIG_DISABLE', '') +app.config['CONFIG_DISABLE'] = read_config_bool('WHOOGLE_CONFIG_DISABLE') app.config['SESSION_FILE_DIR'] = os.path.join( app.config['CONFIG_PATH'], 'session') From 9ba73331aad9311d839e23a4e90a0cb4546c9716 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 17:15:48 -0700 Subject: [PATCH 13/18] Override new Google search result formatting There have been some recent formatting changes made by Google for search results that do not look good (especially for dark themes). This mostly overrides those styles to resemble the original Whoogle result formatting. --- app/static/css/dark-theme.css | 20 +++++++++++++------- app/static/css/light-theme.css | 10 +++++++--- app/static/css/search.css | 6 ++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/static/css/dark-theme.css b/app/static/css/dark-theme.css index 38df90a..4634fa0 100644 --- a/app/static/css/dark-theme.css +++ b/app/static/css/dark-theme.css @@ -59,19 +59,25 @@ select { .ZINbbc { overflow: hidden; - background-color: var(--whoogle-dark-result-bg) !important; + box-shadow: 0 0 0 0 !important; + background-color: var(--whoogle-dark-result-bg) !important; +} + +.KP7LCb { + box-shadow: 0 0 0 0 !important; } .BVG0Nb { - background-color: var(--whoogle-dark-result-bg) !important; + box-shadow: 0 0 0 0 !important; + background-color: var(--whoogle-dark-page-bg) !important; +} + +.ZINbbc.luh4tb { + background: var(--whoogle-dark-result-bg) !important; } .bRsWnc { - background-color: var(--whoogle-dark-result-bg) !important; -} - -.BVG0Nb { - background-color: var(--whoogle-dark-page-bg) !important; + background-color: var(--whoogle-dark-result-bg) !important; } .x54gtf { diff --git a/app/static/css/light-theme.css b/app/static/css/light-theme.css index 2562555..56810ed 100644 --- a/app/static/css/light-theme.css +++ b/app/static/css/light-theme.css @@ -34,15 +34,19 @@ select { .ZINbbc { overflow: hidden; - background-color: var(--whoogle-result-bg) !important; + background-color: var(--whoogle-result-bg) !important; } .BVG0Nb { - background-color: var(--whoogle-result-bg) !important; + background-color: var(--whoogle-result-bg) !important; +} + +.ZINbbc.luh4tb { + background: var(--whoogle-result-bg) !important; } .bRsWnc { - background-color: var(--whoogle-result-bg) !important; + background-color: var(--whoogle-result-bg) !important; } .x54gtf { diff --git a/app/static/css/search.css b/app/static/css/search.css index 1e76664..adbb40f 100644 --- a/app/static/css/search.css +++ b/app/static/css/search.css @@ -1,3 +1,9 @@ +body { + display: block !important; + margin: auto !important; + max-width: 736px !important; +} + .autocomplete { position: relative; display: inline-block; From e3394e29ddf10caf4294105c6d468980911abbbd Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 17:24:12 -0700 Subject: [PATCH 14/18] Amend body width formatting in search css `min-width` is a better field to override than `max-width`, since some users prefer full width results. --- app/static/css/search.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/static/css/search.css b/app/static/css/search.css index adbb40f..9434ef9 100644 --- a/app/static/css/search.css +++ b/app/static/css/search.css @@ -1,7 +1,7 @@ body { display: block !important; margin: auto !important; - max-width: 736px !important; + min-width: 736px !important; } .autocomplete { From 63301efb28ca16394f4fd5bd0f9258949f0784ef Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 18:02:59 -0700 Subject: [PATCH 15/18] Push images to ghcr.io Alternative container registries like ghcr.io are a good option for anyone seeking to avoid things like docker hub's latest changes to rate limiting --- .github/workflows/buildx.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml index a0475e8..7cd2767 100644 --- a/.github/workflows/buildx.yml +++ b/.github/workflows/buildx.yml @@ -24,10 +24,17 @@ jobs: uses: crazy-max/ghaction-docker-buildx@v1 with: version: latest - - name: log in to docker hub - run: | - echo "${{ secrets.DOCKER_PASSWORD }}" | \ - docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to ghcr.io + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: build and push the image if: startsWith(github.ref, 'refs/heads/main') && github.actor == 'benbusby' run: | @@ -36,6 +43,9 @@ jobs: docker buildx build --push \ --tag benbusby/whoogle-search:latest \ --platform linux/amd64,linux/arm/v7,linux/arm64 . + docker buildx build --push \ + --tag ghcr.io/benbusby/whoogle-search:latest \ + --platform linux/amd64,linux/arm/v7,linux/arm64 . - name: build and push tag if: startsWith(github.ref, 'refs/tags') run: | @@ -44,3 +54,6 @@ jobs: docker buildx build --push \ --tag benbusby/whoogle-search:${GITHUB_REF#refs/*/v}\ --platform linux/amd64,linux/arm/v7,linux/arm64 . + docker buildx build --push \ + --tag ghcr.io/benbusby/whoogle-search:${GITHUB_REF#refs/*/v}\ + --platform linux/amd64,linux/arm/v7,linux/arm64 . From b393e68d1d361028da8eb41dc06d38a8d8ee5088 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 1 Feb 2022 20:36:53 -0700 Subject: [PATCH 16/18] Fix incorrect min-width for mobile screen sizes min-width was previously set to 736px for all screen sizes, which forced content off screen for smaller devices such as mobile phones. This modifies the search stylesheet to only apply a min-width style to devices > 800px wide. --- app/static/css/search.css | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/static/css/search.css b/app/static/css/search.css index 9434ef9..23484a2 100644 --- a/app/static/css/search.css +++ b/app/static/css/search.css @@ -1,7 +1,10 @@ body { display: block !important; margin: auto !important; - min-width: 736px !important; +} + +.vvjwJb { + font-size: 16px !important; } .autocomplete { @@ -49,3 +52,9 @@ details summary span { .ip-text-div { padding-top: 0 !important; } + +@media (min-width: 801px) { + body { + min-width: 736px !important; + } +} From 500942cb9949d6122862b0bbdb3040feccd65630 Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Wed, 2 Feb 2022 14:57:05 -0500 Subject: [PATCH 17/18] Update minimal mode for new Google formatting (#637) Google's latest formatting changes broke the modifications made when enabling `WHOOGLE_MINIMAL`. This updates the result filtering to work with the new changes. Fixes #634 --- app/filter.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/filter.py b/app/filter.py index df8f243..a5fe928 100644 --- a/app/filter.py +++ b/app/filter.py @@ -12,6 +12,8 @@ import urllib.parse as urlparse from urllib.parse import parse_qs import os +minimal_mode_sections = ['Top stories', 'Images', 'People also ask'] + def extract_q(q_str: str, href: str) -> str: """Extracts the 'q' element from a result link. This is typically @@ -169,7 +171,11 @@ class Filter: for result in self.main_divs: result_children = pull_child_divs(result) if minimal_mode: - if len(result_children) in (1, 3): + if any(f">{x} Date: Sat, 5 Feb 2022 06:16:56 +0700 Subject: [PATCH 18/18] Fix Sinhala translation for farside search (#594) --- app/static/settings/translations.json | 40 +++++++++++++-------------- app/templates/error.html | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/static/settings/translations.json b/app/static/settings/translations.json index 6515af5..94a8889 100644 --- a/app/static/settings/translations.json +++ b/app/static/settings/translations.json @@ -35,7 +35,7 @@ "dark": "dark", "system": "system", "ratelimit": "Instance has been ratelimited", - "continue-search": "Continue your search with " + "continue-search": "Continue your search with Farside" }, "lang_nl": { "search": "Zoeken", @@ -73,7 +73,7 @@ "dark": "donker", "system": "systeeminstellingen", "ratelimit": "Instantie is beperkt in snelheid", - "continue-search": "Ga verder met zoeken met " + "continue-search": "Ga verder met zoeken met Farside" }, "lang_de": { "search": "Suchen", @@ -111,7 +111,7 @@ "dark": "dunkel", "system": "Systemeinstellung", "ratelimit": "Instanz wurde ratenbegrenzt", - "continue-search": "Setzen Sie Ihre Suche fort mit " + "continue-search": "Setzen Sie Ihre Suche fort mit Farside" }, "lang_es": { "search": "Buscar", @@ -149,7 +149,7 @@ "dark": "oscuro", "system": "configuración del sistema", "ratelimit": "La instancia ha sido ratelimited", - "continue-search": "Continúe su búsqueda con " + "continue-search": "Continúe su búsqueda con Farside" }, "lang_it": { "search": "Cerca", @@ -187,7 +187,7 @@ "dark": "notte", "system": "impostazioni di sistema", "ratelimit": "L'istanza è stata limitata alla velocità", - "continue-search": "Continua la tua ricerca con " + "continue-search": "Continua la tua ricerca con Farside" }, "lang_pt": { "search": "Pesquisar", @@ -225,7 +225,7 @@ "dark": "escuro", "system": "configuração de sistema", "ratelimit": "A instância foi limitada pela taxa", - "continue-search": "Continue sua pesquisa com " + "continue-search": "Continue sua pesquisa com Farside" }, "lang_ru": { "search": "Поиск", @@ -263,7 +263,7 @@ "dark": "темное", "system": "системное", "ratelimit": "Число экземпляров ограничено", - "continue-search": "Продолжайте поиск с " + "continue-search": "Продолжайте поиск с Farside" }, "lang_zh-CN": { "search": "搜索", @@ -301,7 +301,7 @@ "dark": "黑暗的", "system": "系统设置", "ratelimit": "实例已被限速", - "continue-search": "继续搜索 " + "continue-search": "继续搜索 Farside" }, "lang_si": { "search": "සොයන්න", @@ -314,13 +314,13 @@ "config-block": "අවහිර", "config-block-help": "අල්ප විරාම වලින් වෙන් වූ අඩවි ලැයිස්තුව", "config-block-title": "මාතෘකාව අනුව අවහිර කරන්න", - "config-block-title-help": "රෙජෙක්ස් භාවිතා කරන්න", - "config-block-url": "යූආර්එල් මඟින් අවහිර කරන්න", + "config-block-title-help": "වාක්‍යවිධි භාවිතා කරන්න", + "config-block-url": "ඒ.ස.නි. මඟින් අවහිර කරන්න", "config-block-url-help": "රෙජෙක්ස් භාවිතා කරන්න", "config-theme": "තේමාව", "config-nojs": "නෝජේඑස් සබැඳි පෙන්වන්න", "config-dark": "අඳුරු ආකාරය", - "config-safe": "ආරක්ෂිත සෙවුම", + "config-safe": "ආරක්‍ෂිත සෙවුම", "config-alts": "සමාජ මාධ්‍ය සබැඳි ප්‍රතිස්ථාපනය කරන්න", "config-alts-help": "ට්විටර්/යූ ටියුබ්/ඉන්ස්ටග්‍රෑම් ආදී සබැඳි පෞද්ගලිකත්වයට ගරු කරන විකල්ප සමඟ ප්‍රතිස්ථාපනය කරයි.", "config-new-tab": "නව තීරුවකින් සබැඳි විවෘත කරන්න", @@ -338,8 +338,8 @@ "light": "දීප්තිමත්", "dark": "අඳුරු", "system": "පද්ධතිය", - "ratelimit": "උදාහරණය අනුපාත කර ඇත", - "continue-search": "සමඟ ඔබේ සෙවීම දිගටම කරගෙන යන්න" + "ratelimit": "සේවාදායකය අනුපාතනය කර ඇත", + "continue-search": "Farside සමඟ ඔබගේ සෙවුම කරගෙන යන්න" }, "lang_fr": { "search": "Chercher", @@ -377,7 +377,7 @@ "dark": "sombre", "system": "système", "ratelimit": "Le débit de l'instance a été limité", - "continue-search": "Continuez votre recherche avec " + "continue-search": "Continuez votre recherche avec Farside" }, "lang_fa": { "search": "جستجو", @@ -415,7 +415,7 @@ "dark": "تیره", "system": "سیستم", "ratelimit": "نمونه با نرخ محدود شده است", - "continue-search": "جستجوی خود را با " + "continue-search": "Farside جستجوی خود را با " }, "lang_cs": { "search": "Hledat", @@ -453,7 +453,7 @@ "dark": "Tmavý", "system": "Systémový", "ratelimit": "Instance byla omezena sazbou", - "continue-search": "Pokračujte ve vyhledávání pomocí " + "continue-search": "Pokračujte ve vyhledávání pomocí Farside" }, "lang_zh-TW": { "search": "搜尋", @@ -491,7 +491,7 @@ "dark": "黑暗的", "system": "依系統", "ratelimit": "實例已被限速", - "continue-search": "繼續搜索 " + "continue-search": "繼續搜索 Farside" }, "lang_bg": { "search": "Търсене", @@ -529,7 +529,7 @@ "dark": "тъмна", "system": "системна", "ratelimit": "Екземплярът е с ограничена скорост", - "continue-search": "Продължете търсенето си с " + "continue-search": "Продължете търсенето си с Farside" }, "lang_hi": { "search": "खोज", @@ -567,7 +567,7 @@ "dark": "अंधेरा", "system": "प्रणाली", "ratelimit": "इंस्टेंस को सीमित कर दिया गया है", - "continue-search": "के साथ अपनी खोज जारी रखें " + "continue-search": "के साथ अपनी खोज जारी रखें Farside" }, "lang_ja": { "search": "検索", @@ -605,6 +605,6 @@ "dark": "ダーク", "system": "自動", "ratelimit": "インスタンスはレート制限されています", - "continue-search": "で検索を続ける " + "continue-search": "で検索を続ける Farside" } } diff --git a/app/templates/error.html b/app/templates/error.html index 687327f..58f7f42 100644 --- a/app/templates/error.html +++ b/app/templates/error.html @@ -21,7 +21,7 @@

{% if blocked is defined %} -

{{ translation['continue-search'] }} Farside!

+

{{ translation['continue-search'] }}

Whoogle: