Merge branch 'master' into feature/basic-auth
This commit is contained in:
commit
8372dd16f7
|
@ -15,8 +15,14 @@ ENV WHOOGLE_USER=$username
|
||||||
ARG password=''
|
ARG password=''
|
||||||
ENV WHOOGLE_PASS=$password
|
ENV WHOOGLE_PASS=$password
|
||||||
|
|
||||||
|
ARG use_https=''
|
||||||
|
ENV HTTPS_ONLY=$use_https
|
||||||
|
|
||||||
|
ARG whoogle_port=5000
|
||||||
|
ENV EXPOSE_PORT=$whoogle_port
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE $EXPOSE_PORT
|
||||||
|
|
||||||
CMD ["./whoogle-search"]
|
CMD ["./whoogle-search"]
|
||||||
|
|
13
README.md
13
README.md
|
@ -72,6 +72,7 @@ Sandboxed temporary instance:
|
||||||
```bash
|
```bash
|
||||||
$ whoogle-search --help
|
$ whoogle-search --help
|
||||||
usage: whoogle-search [-h] [--port <port number>] [--host <ip address>] [--debug]
|
usage: whoogle-search [-h] [--port <port number>] [--host <ip address>] [--debug]
|
||||||
|
[--https-only]
|
||||||
|
|
||||||
Whoogle Search console runner
|
Whoogle Search console runner
|
||||||
|
|
||||||
|
@ -79,7 +80,8 @@ optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--port <port number> Specifies a port to run on (default 5000)
|
--port <port number> Specifies a port to run on (default 5000)
|
||||||
--host <ip address> Specifies the host address to use (default 127.0.0.1)
|
--host <ip address> Specifies the host address to use (default 127.0.0.1)
|
||||||
--debug Activates debug mode for the Flask server (default False)
|
--debug Activates debug mode for the server (default False)
|
||||||
|
--https-only Enforces HTTPS redirects for all requests (default False)
|
||||||
```
|
```
|
||||||
|
|
||||||
### D) Manual
|
### D) Manual
|
||||||
|
@ -124,7 +126,7 @@ docker build --tag whoogle-search:1.0 .
|
||||||
docker run --publish 5000:5000 --detach --name whoogle-search whoogle-search:1.0
|
docker run --publish 5000:5000 --detach --name whoogle-search whoogle-search:1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
And kill with: `docker rm --force whooglesearch`
|
And kill with: `docker rm --force whoogle-search`
|
||||||
|
|
||||||
#### Using [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)
|
#### Using [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)
|
||||||
```bash
|
```bash
|
||||||
|
@ -171,6 +173,13 @@ Update browser settings:
|
||||||
- Click the 3 dot menu in the top right
|
- Click the 3 dot menu in the top right
|
||||||
- Navigate to the settings menu and select the "search" sub-menu
|
- Navigate to the settings menu and select the "search" sub-menu
|
||||||
- Select Whoogle and press "Set as default"
|
- Select Whoogle and press "Set as default"
|
||||||
|
- [Alfred](https://www.alfredapp.com/) (Mac OS X)
|
||||||
|
1. Go to `Alfred Preferences` > `Features` > `Web Search` and click `Add Custom Search`. Then configure these settings
|
||||||
|
- Search URL: `https://\<your whoogle url\>/search?q={query}
|
||||||
|
- Title: `Whoogle for '{query}'` (or whatever you want)
|
||||||
|
- Keyword: `whoogle`
|
||||||
|
|
||||||
|
2. Go to `Default Results` and click the `Setup fallback results` button. Click `+` and add Whoogle, then drag it to the top.
|
||||||
- Others (TODO)
|
- Others (TODO)
|
||||||
|
|
||||||
### Customizing and Configuration
|
### Customizing and Configuration
|
||||||
|
|
|
@ -22,6 +22,7 @@ class Filter:
|
||||||
self.near = config['near'] if 'near' in config else ''
|
self.near = config['near'] if 'near' in config else ''
|
||||||
self.dark = config['dark'] if 'dark' in config else False
|
self.dark = config['dark'] if 'dark' in config else False
|
||||||
self.nojs = config['nojs'] if 'nojs' in config else False
|
self.nojs = config['nojs'] if 'nojs' in config else False
|
||||||
|
self.new_tab = config['new_tab'] if 'new_tab' in config else False
|
||||||
self.mobile = mobile
|
self.mobile = mobile
|
||||||
self.secret_key = secret_key
|
self.secret_key = secret_key
|
||||||
|
|
||||||
|
@ -78,7 +79,7 @@ class Filter:
|
||||||
# Special rebranding for image search results
|
# Special rebranding for image search results
|
||||||
if img_src.startswith(LOGO_URL):
|
if img_src.startswith(LOGO_URL):
|
||||||
img['src'] = '/static/img/logo.png'
|
img['src'] = '/static/img/logo.png'
|
||||||
img['height'] = 40
|
img['style'] = 'height:40px;width:162px'
|
||||||
else:
|
else:
|
||||||
img['src'] = BLANK_B64
|
img['src'] = BLANK_B64
|
||||||
|
|
||||||
|
@ -114,9 +115,15 @@ class Filter:
|
||||||
|
|
||||||
# Set up dark mode if active
|
# Set up dark mode if active
|
||||||
if self.dark:
|
if self.dark:
|
||||||
soup.find('html')['style'] = 'scrollbar-color: #333 #111;'
|
soup.find('html')['style'] = 'scrollbar-color: #333 #111;color:#fff !important;background:#000 !important'
|
||||||
for input_element in soup.findAll('input'):
|
for input_element in soup.findAll('input'):
|
||||||
input_element['style'] = 'color:#fff;'
|
input_element['style'] = 'color:#fff;background:#000;'
|
||||||
|
|
||||||
|
for span_element in soup.findAll('span'):
|
||||||
|
span_element['style'] = 'color: white;'
|
||||||
|
|
||||||
|
for href_element in soup.findAll('a'):
|
||||||
|
href_element['style'] = 'color: white' if href_element['href'].startswith('/search') else ''
|
||||||
|
|
||||||
def update_links(self, soup):
|
def update_links(self, soup):
|
||||||
# Replace hrefs with only the intended destination (no "utm" type tags)
|
# Replace hrefs with only the intended destination (no "utm" type tags)
|
||||||
|
@ -125,6 +132,8 @@ class Filter:
|
||||||
if '/advanced_search' in href:
|
if '/advanced_search' in href:
|
||||||
a.decompose()
|
a.decompose()
|
||||||
continue
|
continue
|
||||||
|
elif self.new_tab:
|
||||||
|
a['target'] = '_blank'
|
||||||
|
|
||||||
result_link = urlparse.urlparse(href)
|
result_link = urlparse.urlparse(href)
|
||||||
query_link = parse_qs(result_link.query)['q'][0] if '?q=' in href else ''
|
query_link = parse_qs(result_link.query)['q'][0] if '?q=' in href else ''
|
||||||
|
|
|
@ -57,6 +57,7 @@ class Config:
|
||||||
self.dark = False
|
self.dark = False
|
||||||
self.nojs = False
|
self.nojs = False
|
||||||
self.near = ''
|
self.near = ''
|
||||||
|
self.new_tab = False
|
||||||
self.get_only = False
|
self.get_only = False
|
||||||
|
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
|
|
|
@ -36,6 +36,12 @@ def auth_required(f):
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def before_request_func():
|
def before_request_func():
|
||||||
|
# Always redirect to https if HTTPS_ONLY is set
|
||||||
|
if os.getenv('HTTPS_ONLY', False) and request.url.startswith('http://'):
|
||||||
|
url = request.url.replace('http://', 'https://', 1)
|
||||||
|
code = 301
|
||||||
|
return redirect(url, code=code)
|
||||||
|
|
||||||
json_config = json.load(open(CONFIG_PATH)) if os.path.exists(CONFIG_PATH) else {'url': request.url_root}
|
json_config = json.load(open(CONFIG_PATH)) if os.path.exists(CONFIG_PATH) else {'url': request.url_root}
|
||||||
g.user_config = Config(**json_config)
|
g.user_config = Config(**json_config)
|
||||||
|
|
||||||
|
@ -186,6 +192,8 @@ def run_app():
|
||||||
help='Specifies the host address to use (default 127.0.0.1)')
|
help='Specifies the host address to use (default 127.0.0.1)')
|
||||||
parser.add_argument('--debug', default=False, action='store_true',
|
parser.add_argument('--debug', default=False, action='store_true',
|
||||||
help='Activates debug mode for the server (default False)')
|
help='Activates debug mode for the server (default False)')
|
||||||
|
parser.add_argument('--https-only', default=False, action='store_true',
|
||||||
|
help='Enforces HTTPS redirects for all requests')
|
||||||
parser.add_argument('--userpass', default='', metavar='<username:password>',
|
parser.add_argument('--userpass', default='', metavar='<username:password>',
|
||||||
help='Sets a username/password basic auth combo (default None)')
|
help='Sets a username/password basic auth combo (default None)')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -195,6 +203,8 @@ def run_app():
|
||||||
os.environ['WHOOGLE_USER'] = user_pass[0]
|
os.environ['WHOOGLE_USER'] = user_pass[0]
|
||||||
os.environ['WHOOGLE_PASS'] = user_pass[1]
|
os.environ['WHOOGLE_PASS'] = user_pass[1]
|
||||||
|
|
||||||
|
os.environ['HTTPS_ONLY'] = '1' if args.https_only else ''
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
app.run(host=args.host, port=args.port, debug=args.debug)
|
app.run(host=args.host, port=args.port, debug=args.debug)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -21,6 +21,7 @@ const fillConfigValues = () => {
|
||||||
const noJS = document.getElementById("config-nojs");
|
const noJS = document.getElementById("config-nojs");
|
||||||
const dark = document.getElementById("config-dark");
|
const dark = document.getElementById("config-dark");
|
||||||
const url = document.getElementById("config-url");
|
const url = document.getElementById("config-url");
|
||||||
|
const newTab = document.getElementById("config-new-tab");
|
||||||
const getOnly = document.getElementById("config-get-only");
|
const getOnly = document.getElementById("config-get-only");
|
||||||
|
|
||||||
// Request existing config info
|
// Request existing config info
|
||||||
|
@ -39,6 +40,7 @@ const fillConfigValues = () => {
|
||||||
noJS.checked = !!configSettings["nojs"];
|
noJS.checked = !!configSettings["nojs"];
|
||||||
dark.checked = !!configSettings["dark"];
|
dark.checked = !!configSettings["dark"];
|
||||||
getOnly.checked = !!configSettings["get_only"];
|
getOnly.checked = !!configSettings["get_only"];
|
||||||
|
newTab.checked = !!configSettings["new_tab"];
|
||||||
|
|
||||||
// Addresses the issue of incorrect URL being used behind reverse proxy
|
// Addresses the issue of incorrect URL being used behind reverse proxy
|
||||||
url.value = configSettings["url"] ? configSettings["url"] : "";
|
url.value = configSettings["url"] ? configSettings["url"] : "";
|
||||||
|
|
|
@ -66,6 +66,10 @@
|
||||||
<label for="config-dark">Dark Mode: </label>
|
<label for="config-dark">Dark Mode: </label>
|
||||||
<input type="checkbox" name="dark" id="config-dark">
|
<input type="checkbox" name="dark" id="config-dark">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="config-div">
|
||||||
|
<label for="config-new-tab">Open Links in New Tab: </label>
|
||||||
|
<input type="checkbox" name="new_tab" id="config-new-tab">
|
||||||
|
</div>
|
||||||
<div class="config-div">
|
<div class="config-div">
|
||||||
<label for="config-get-only">GET Requests Only: </label>
|
<label for="config-get-only">GET Requests Only: </label>
|
||||||
<input type="checkbox" name="get_only" id="config-get-only">
|
<input type="checkbox" name="get_only" id="config-get-only">
|
||||||
|
|
|
@ -7,7 +7,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
||||||
|
|
||||||
# Set default port if unavailable
|
# Set default port if unavailable
|
||||||
if [[ -z "${PORT}" ]]; then
|
if [[ -z "${PORT}" ]]; then
|
||||||
PORT=5000
|
PORT="${EXPOSE_PORT:-5000}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set directory to serve static content from
|
# Set directory to serve static content from
|
||||||
|
|
Loading…
Reference in New Issue
Block a user