Merge remote-tracking branch 'origin/main' into heroku-app
This commit is contained in:
commit
69488c9f3b
45
README.md
45
README.md
|
@ -15,11 +15,12 @@ Contents
|
||||||
3. [Install/Deploy](#install)
|
3. [Install/Deploy](#install)
|
||||||
1. [Heroku Quick Deploy](#a-heroku-quick-deploy)
|
1. [Heroku Quick Deploy](#a-heroku-quick-deploy)
|
||||||
2. [Repl.it](#b-replit)
|
2. [Repl.it](#b-replit)
|
||||||
3. [pipx](#c-pipx)
|
3. [Fly.io](#c-flyio)
|
||||||
4. [pip](#d-pip)
|
4. [pipx](#d-pipx)
|
||||||
5. [Manual](#e-manual)
|
5. [pip](#e-pip)
|
||||||
6. [Docker](#f-manual-docker)
|
6. [Manual](#f-manual)
|
||||||
7. [Arch/AUR](#arch-linux--arch-based-distributions)
|
7. [Docker](#g-manual-docker)
|
||||||
|
8. [Arch/AUR](#arch-linux--arch-based-distributions)
|
||||||
4. [Environment Variables and Configuration](#environment-variables)
|
4. [Environment Variables and Configuration](#environment-variables)
|
||||||
5. [Usage](#usage)
|
5. [Usage](#usage)
|
||||||
6. [Extra Steps](#extra-steps)
|
6. [Extra Steps](#extra-steps)
|
||||||
|
@ -90,7 +91,33 @@ Provides:
|
||||||
- Supports custom domains
|
- Supports custom domains
|
||||||
- Downtime after periods of inactivity \([solution 1](https://repl.it/talk/ask/use-this-pingmat1replco-just-enter/28821/101298), [solution 2](https://repl.it/talk/learn/How-to-use-and-setup-UptimeRobot/9003)\)
|
- Downtime after periods of inactivity \([solution 1](https://repl.it/talk/ask/use-this-pingmat1replco-just-enter/28821/101298), [solution 2](https://repl.it/talk/learn/How-to-use-and-setup-UptimeRobot/9003)\)
|
||||||
|
|
||||||
### C) [pipx](https://github.com/pipxproject/pipx#install-pipx)
|
### C) [Fly.io](https://fly.io)
|
||||||
|
|
||||||
|
You will need a [Fly.io](https://fly.io) account to do this. Fly requires a credit card to deploy anything, but you can have up to 3 shared-CPU VMs running full-time each month for free.
|
||||||
|
|
||||||
|
#### Install the CLI:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -L https://fly.io/install.sh | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Deploy your app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
fly apps create --org personal --port 5000
|
||||||
|
# Choose a name and the Image builder
|
||||||
|
# Enter `benbusby/whoogle-search:latest` as the image name
|
||||||
|
fly deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
Your app is now available at `https://<app-name>.fly.dev`.
|
||||||
|
|
||||||
|
You can customize the `fly.toml`:
|
||||||
|
- Remove the non-https service
|
||||||
|
- Add environment variables under the `[env]` key
|
||||||
|
- Use `fly secrets set NAME=value` for more sensitive values like `WHOOGLE_PASS` and `WHOOGLE_PROXY_PASS`.
|
||||||
|
|
||||||
|
### D) [pipx](https://github.com/pipxproject/pipx#install-pipx)
|
||||||
Persistent install:
|
Persistent install:
|
||||||
|
|
||||||
`pipx install git+https://github.com/benbusby/whoogle-search.git`
|
`pipx install git+https://github.com/benbusby/whoogle-search.git`
|
||||||
|
@ -99,7 +126,7 @@ Sandboxed temporary instance:
|
||||||
|
|
||||||
`pipx run --spec git+https://github.com/benbusby/whoogle-search.git whoogle-search`
|
`pipx run --spec git+https://github.com/benbusby/whoogle-search.git whoogle-search`
|
||||||
|
|
||||||
### D) pip
|
### E) pip
|
||||||
`pip install whoogle-search`
|
`pip install whoogle-search`
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -126,7 +153,7 @@ optional arguments:
|
||||||
```
|
```
|
||||||
See the [available environment variables](#environment-variables) for additional configuration.
|
See the [available environment variables](#environment-variables) for additional configuration.
|
||||||
|
|
||||||
### E) Manual
|
### F) Manual
|
||||||
Clone the repo and run the following commands to start the app in a local-only environment:
|
Clone the repo and run the following commands to start the app in a local-only environment:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -183,7 +210,7 @@ sudo systemctl enable whoogle
|
||||||
sudo systemctl start whoogle
|
sudo systemctl start whoogle
|
||||||
```
|
```
|
||||||
|
|
||||||
### F) Manual (Docker)
|
### G) Manual (Docker)
|
||||||
1. Ensure the Docker daemon is running, and is accessible by your user account
|
1. Ensure the Docker daemon is running, and is accessible by your user account
|
||||||
- To add user permissions, you can execute `sudo usermod -aG docker yourusername`
|
- To add user permissions, you can execute `sudo usermod -aG docker yourusername`
|
||||||
- Running `docker ps` should return something besides an error. If you encounter an error saying the daemon isn't running, try `sudo systemctl start docker` (Linux) or ensure the docker tool is running (Windows/macOS).
|
- Running `docker ps` should return something besides an error. If you encounter an error saying the daemon isn't running, try `sudo systemctl start docker` (Linux) or ensure the docker tool is running (Windows/macOS).
|
||||||
|
|
|
@ -22,7 +22,7 @@ app.default_key = generate_user_key()
|
||||||
app.no_cookie_ips = []
|
app.no_cookie_ips = []
|
||||||
app.config['SECRET_KEY'] = os.urandom(32)
|
app.config['SECRET_KEY'] = os.urandom(32)
|
||||||
app.config['SESSION_TYPE'] = 'filesystem'
|
app.config['SESSION_TYPE'] = 'filesystem'
|
||||||
app.config['VERSION_NUMBER'] = '0.5.1'
|
app.config['VERSION_NUMBER'] = '0.5.2'
|
||||||
app.config['APP_ROOT'] = os.getenv(
|
app.config['APP_ROOT'] = os.getenv(
|
||||||
'APP_ROOT',
|
'APP_ROOT',
|
||||||
os.path.dirname(os.path.abspath(__file__)))
|
os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
|
@ -22,6 +22,21 @@ def strip_blocked_sites(query: str) -> str:
|
||||||
return query[:query.find('-site:')] if '-site:' in query else query
|
return query[:query.find('-site:')] if '-site:' in query else query
|
||||||
|
|
||||||
|
|
||||||
|
def extract_q(q_str: str, href: str) -> str:
|
||||||
|
"""Extracts the 'q' element from a result link. This is typically
|
||||||
|
either the link to a result's website, or a string.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
q_str: The result link to parse
|
||||||
|
href: The full url to check for standalone 'q' elements first,
|
||||||
|
rather than parsing the whole query string and then checking.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: The 'q' element of the link, or an empty string
|
||||||
|
"""
|
||||||
|
return parse_qs(q_str)['q'][0] if ('&q=' in href or '?q=' in href) else ''
|
||||||
|
|
||||||
|
|
||||||
class Filter:
|
class Filter:
|
||||||
def __init__(self, user_key: str, mobile=False, config=None) -> None:
|
def __init__(self, user_key: str, mobile=False, config=None) -> None:
|
||||||
if config is None:
|
if config is None:
|
||||||
|
@ -223,20 +238,18 @@ class Filter:
|
||||||
link['target'] = '_blank'
|
link['target'] = '_blank'
|
||||||
|
|
||||||
result_link = urlparse.urlparse(href)
|
result_link = urlparse.urlparse(href)
|
||||||
query = parse_qs(
|
q = extract_q(result_link.query, href)
|
||||||
result_link.query
|
|
||||||
)['q'][0] if 'q=' in href else ''
|
|
||||||
|
|
||||||
if query.startswith('/'):
|
if q.startswith('/'):
|
||||||
# Internal google links (i.e. mail, maps, etc) should still
|
# Internal google links (i.e. mail, maps, etc) should still
|
||||||
# be forwarded to Google
|
# be forwarded to Google
|
||||||
link['href'] = 'https://google.com' + query
|
link['href'] = 'https://google.com' + q
|
||||||
elif '/search?q=' in href:
|
elif '/search?q=' in href:
|
||||||
# "li:1" implies the query should be interpreted verbatim,
|
# "li:1" implies the query should be interpreted verbatim,
|
||||||
# which is accomplished by wrapping the query in double quotes
|
# which is accomplished by wrapping the query in double quotes
|
||||||
if 'li:1' in href:
|
if 'li:1' in href:
|
||||||
query = '"' + query + '"'
|
q = '"' + q + '"'
|
||||||
new_search = 'search?q=' + self.encrypt_path(query)
|
new_search = 'search?q=' + self.encrypt_path(q)
|
||||||
|
|
||||||
query_params = parse_qs(urlparse.urlparse(href).query)
|
query_params = parse_qs(urlparse.urlparse(href).query)
|
||||||
for param in VALID_PARAMS:
|
for param in VALID_PARAMS:
|
||||||
|
@ -247,7 +260,7 @@ class Filter:
|
||||||
link['href'] = new_search
|
link['href'] = new_search
|
||||||
elif 'url?q=' in href:
|
elif 'url?q=' in href:
|
||||||
# Strip unneeded arguments
|
# Strip unneeded arguments
|
||||||
link['href'] = filter_link_args(query)
|
link['href'] = filter_link_args(q)
|
||||||
|
|
||||||
# Add no-js option
|
# Add no-js option
|
||||||
if self.nojs:
|
if self.nojs:
|
||||||
|
@ -255,7 +268,7 @@ class Filter:
|
||||||
else:
|
else:
|
||||||
if href.startswith(MAPS_URL):
|
if href.startswith(MAPS_URL):
|
||||||
# Maps links don't work if a site filter is applied
|
# Maps links don't work if a site filter is applied
|
||||||
link['href'] = MAPS_URL + "?q=" + strip_blocked_sites(query)
|
link['href'] = MAPS_URL + "?q=" + strip_blocked_sites(q)
|
||||||
else:
|
else:
|
||||||
link['href'] = href
|
link['href'] = href
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ setuptools.setup(
|
||||||
author='Ben Busby',
|
author='Ben Busby',
|
||||||
author_email='benbusby@protonmail.com',
|
author_email='benbusby@protonmail.com',
|
||||||
name='whoogle-search',
|
name='whoogle-search',
|
||||||
version='0.5.1',
|
version='0.5.2',
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=requirements,
|
install_requires=requirements,
|
||||||
description='Self-hosted, ad-free, privacy-respecting metasearch engine',
|
description='Self-hosted, ad-free, privacy-respecting metasearch engine',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user