diff --git a/README.md b/README.md index d8b7455..a8d0e4c 100644 --- a/README.md +++ b/README.md @@ -263,6 +263,7 @@ These environment variables allow setting default config values, but can be over | WHOOGLE_CONFIG_COUNTRY | Filter results by hosting country | | WHOOGLE_CONFIG_LANGUAGE | Set interface language | | WHOOGLE_CONFIG_SEARCH_LANGUAGE | Set search result language | +| WHOOGLE_CONFIG_BLOCK | Block websites from search results (use comma-separated list) | | WHOOGLE_CONFIG_DARK | Enable dark theme | | WHOOGLE_CONFIG_SAFE | Enable safe searches | | WHOOGLE_CONFIG_ALTS | Use social media site alternatives (nitter, invidious, etc) | diff --git a/app.json b/app.json index b39a930..47f4ca0 100644 --- a/app.json +++ b/app.json @@ -80,6 +80,16 @@ "value": "", "required": false }, + "WHOOGLE_CONFIG_DISABLE": { + "description": "[CONFIG] Disable ability for client to change config (set to 1 or leave blank)", + "value": "", + "required": false + }, + "WHOOGLE_CONFIG_BLOCK": { + "description": "[CONFIG] Block websites from search results (comma-separated list)", + "value": "", + "required": false + }, "WHOOGLE_CONFIG_DARK": { "description": "[CONFIG] Enable dark mode (set to 1 or leave blank)", "value": "", diff --git a/app/models/config.py b/app/models/config.py index 846740b..5b2f192 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -18,6 +18,7 @@ class Config: 'WHOOGLE_CONFIG_STYLE', open(os.path.join(app_config['STATIC_FOLDER'], 'css/variables.css')).read()) + self.block = os.getenv('WHOOGLE_CONFIG_BLOCK', '') self.ctry = os.getenv('WHOOGLE_CONFIG_COUNTRY', '') self.safe = read_config_bool('WHOOGLE_CONFIG_SAFE') self.dark = read_config_bool('WHOOGLE_CONFIG_DARK') diff --git a/app/request.py b/app/request.py index 91abdc0..c93aa96 100644 --- a/app/request.py +++ b/app/request.py @@ -120,6 +120,10 @@ def gen_query(query, args, config, near_city=None) -> str: ) if config.lang_interface else '' param_dict['safe'] = '&safe=' + ('active' if config.safe else 'off') + # Block all sites specified in the user config + for blocked in config.block.split(','): + query += (' -site:' + blocked) if blocked else '' + for val in param_dict.values(): if not val: continue diff --git a/app/routes.py b/app/routes.py index ff915ca..71a927c 100644 --- a/app/routes.py +++ b/app/routes.py @@ -2,7 +2,6 @@ import argparse import base64 import io import json -import os import pickle import urllib.parse as urlparse import uuid @@ -17,7 +16,7 @@ from app import app from app.models.config import Config from app.request import Request, TorError from app.utils.bangs import resolve_bang -from app.utils.session import valid_user_session +from app.utils.session import generate_user_key, valid_user_session from app.utils.search import * # Load DDG bang json files only on init diff --git a/app/templates/header.html b/app/templates/header.html index 4eb7822..b353d92 100644 --- a/app/templates/header.html +++ b/app/templates/header.html @@ -22,7 +22,7 @@ style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important; color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }}; type="text" - value="{{ query }}"> + value="{{ query[:query.find('-site:')] }}"> @@ -54,7 +54,7 @@ name="q" spellcheck="false" type="text" - value="{{ query }}" + value="{{ query[:query.find('-site:')] }}" style="background-color: {{ 'var(--whoogle-dark-result-bg)' if config.dark else 'var(--whoogle-result-bg)' }} !important; color: {{ 'var(--whoogle-dark-text)' if config.dark else 'var(--whoogle-text)' }}; border-bottom: {{ '2px solid var(--whoogle-dark-element-bg)' if config.dark else '0px' }};"> diff --git a/app/templates/index.html b/app/templates/index.html index fa2b2ab..37f753c 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -56,117 +56,123 @@ -
- -
-
-
-
- - -
— Note: If enabled, a website will only appear in the results if it is *hosted* in the selected country.
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
— Replaces Twitter/YouTube/Instagram/Reddit links - with Nitter/Invidious/Bibliogram/Libreddit links.
-
-
- - -
-
- - -
— Adds the "View Image" option to image search results. - Note: This will cause image result thumbnails to be lower resolution.
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-   -   - -
-
+ {% if not config_disabled %} +
+ +
+
+
+
+ + +
— Note: If enabled, a website will only appear in the results if it is *hosted* in the selected country.
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
-
-
+
+ + +
+
+ + +
+
+ + +
+
+ + +
— Replaces Twitter/YouTube/Instagram/Reddit links + with Nitter/Invidious/Bibliogram/Libreddit links.
+
+
+ + +
+
+ + +
— Adds the "View Image" option to image search results. + Note: This will cause image result thumbnails to be lower resolution.
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+   +   + +
+ +
+
+ {% endif %} +