diff --git a/README.md b/README.md index 94a81c5..577ef73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Whoogle Search](https://raw.githubusercontent.com/benbusby/whoogle-search/main/docs/banner.png) +![Whoogle Search](docs/banner.png) [![Latest Release](https://img.shields.io/github/v/release/benbusby/whoogle-search)](https://github.com/benbusby/shoogle/releases) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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 -![Whoogle Desktop](https://raw.githubusercontent.com/benbusby/whoogle-search/main/docs/screenshot_desktop.jpg) +![Whoogle Desktop](docs/screenshot_desktop.jpg) #### Mobile -![Whoogle Mobile](https://raw.githubusercontent.com/benbusby/whoogle-search/main/docs/screenshot_mobile.jpg) +![Whoogle Mobile](docs/screenshot_mobile.jpg) 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 090753b..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 @@ -8,7 +9,6 @@ import re import urllib.parse as urlparse from urllib.parse import parse_qs import os -from app.utils.misc import read_config_bool def extract_q(q_str: str, href: str) -> str: @@ -173,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( @@ -188,7 +190,7 @@ 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 read_config_bool('WHOOGLE_MINIMAL'): + if minimal_mode: if len(result_children) in (1, 3): continue else: @@ -212,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