diff --git a/README.md b/README.md
index 94a81c5..577ef73 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+
[](https://github.com/benbusby/shoogle/releases)
[](https://opensource.org/licenses/MIT)
@@ -321,6 +321,7 @@ There are a few optional environment variables available for customizing a Whoog
| WHOOGLE_ALT_TL | The Google Translate alternative to use. This is used for all "translate ____" searches. |
| WHOOGLE_ALT_MD | The medium.com alternative to use when site alternatives are enabled in the config. |
| 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. |
### 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.
@@ -505,7 +506,7 @@ A lot of the app currently piggybacks on Google's existing support for fetching
## Screenshots
#### Desktop
-
+
#### Mobile
-
+
diff --git a/app.json b/app.json
index af3aad2..c3d2dc3 100644
--- a/app.json
+++ b/app.json
@@ -75,6 +75,11 @@
"value": "scribe.rip",
"required": false
},
+ "WHOOGLE_MINIMAL": {
+ "description": "Remove everything except basic result cards from all search queries (set to 1 or leave blank)",
+ "value": "",
+ "required": false
+ },
"WHOOGLE_CONFIG_COUNTRY": {
"description": "[CONFIG] The country to use for restricting search results (use values from https://raw.githubusercontent.com/benbusby/whoogle-search/develop/app/static/settings/countries.json)",
"value": "",
diff --git a/app/filter.py b/app/filter.py
index 8f241e5..fa45136 100644
--- a/app/filter.py
+++ b/app/filter.py
@@ -1,4 +1,5 @@
from app.request import VALID_PARAMS, MAPS_URL
+from app.utils.misc import read_config_bool
from app.utils.results import *
from bs4 import BeautifulSoup
from bs4.element import ResultSet, Tag
@@ -7,6 +8,7 @@ from flask import render_template
import re
import urllib.parse as urlparse
from urllib.parse import parse_qs
+import os
def extract_q(q_str: str, href: str) -> str:
@@ -171,6 +173,8 @@ class Filter:
Returns:
None (The soup object is modified directly)
"""
+ minimal_mode = read_config_bool('WHOOGLE_MINIMAL')
+
def pull_child_divs(result_div: BeautifulSoup):
try:
return result_div.findChildren(
@@ -186,8 +190,12 @@ class Filter:
# Loop through results and check for the number of child divs in each
for result in self.main_divs:
result_children = pull_child_divs(result)
- if len(result_children) < self.RESULT_CHILD_LIMIT:
- continue
+ if minimal_mode:
+ if len(result_children) in (1, 3):
+ continue
+ else:
+ if len(result_children) < self.RESULT_CHILD_LIMIT:
+ continue
# Find and decompose the first element with an inner HTML text val.
# This typically extracts the title of the section (i.e. "Related
@@ -206,13 +214,18 @@ class Filter:
while not parent and idx < len(result_children):
parent = result_children[idx].parent
idx += 1
+
details = BeautifulSoup(features='html.parser').new_tag('details')
summary = BeautifulSoup(features='html.parser').new_tag('summary')
summary.string = label
details.append(summary)
- if parent:
+ if parent and not minimal_mode:
parent.wrap(details)
+ elif parent and minimal_mode:
+ # Remove parent element from document if "minimal mode" is
+ # enabled
+ parent.decompose()
def update_element_src(self, element: Tag, mime: str) -> None:
"""Encrypts the original src of an element and rewrites the element src
diff --git a/app/request.py b/app/request.py
index 9bb9bd0..0c80f9b 100644
--- a/app/request.py
+++ b/app/request.py
@@ -9,7 +9,8 @@ import os
from stem import Signal, SocketError
from stem.control import Controller
-SEARCH_URL = 'https://www.google.com/search?gbv=1&q='
+SEARCH_URL = 'https://www.google.com/search?gbv=1&num=' + str(
+ os.getenv('WHOOGLE_RESULTS_PER_PAGE', 10)) + '&q='
MAPS_URL = 'https://maps.google.com/maps'
AUTOCOMPLETE_URL = ('https://suggestqueries.google.com/'
'complete/search?client=toolbar&')
diff --git a/app/routes.py b/app/routes.py
index 3cba939..92f445c 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -1,5 +1,6 @@
import argparse
import base64
+import html
import io
import json
import pickle
@@ -15,6 +16,7 @@ from app.request import Request, TorError
from app.utils.bangs import resolve_bang
from app.utils.misc import read_config_bool
from app.utils.results import add_ip_card
+from app.utils.results import bold_search_terms
from app.utils.search import *
from app.utils.session import generate_user_key, valid_user_session
from bs4 import BeautifulSoup as bsoup
@@ -298,7 +300,7 @@ def search():
# Return 503 if temporarily blocked by captcha
resp_code = 503 if has_captcha(str(response)) else 200
-
+ response = bold_search_terms(response, query)
# Feature to display IP address
if search_util.check_kw_ip():
html_soup = bsoup(response, "html.parser")
@@ -320,7 +322,7 @@ def search():
is_translation=any(
_ in query.lower() for _ in [translation['translate'], 'translate']
) and not search_util.search_type, # Standard search queries only
- response=response,
+ response=html.unescape(str(response)),
version_number=app.config['VERSION_NUMBER'],
search_header=(render_template(
'header.html',
diff --git a/app/templates/display.html b/app/templates/display.html
index 288f24d..e9ec20b 100644
--- a/app/templates/display.html
+++ b/app/templates/display.html
@@ -7,7 +7,6 @@
-
{% if config.theme %}
{% if config.theme == 'system' %}
diff --git a/app/templates/index.html b/app/templates/index.html
index 27b1f1b..18f2bcf 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -21,7 +21,6 @@
-
{% if config.theme %}
{% if config.theme == 'system' %}