From 21012f5265dcc1541e5e296bcbb6ff54661f95a7 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Sun, 24 May 2020 14:03:11 -0600 Subject: [PATCH] Feature: autocomplete/search suggestions (#72) Basic autocomplete/search suggestion functionality added * Adds new GET and POST routes for '/autocomplete' that accept a string query and returns an array of suggestions * Adds new autoscript.js file for handling queries on the main page and results view * Updated requests class to include autocomplete method * Updated opensearch template to handle search suggestions * Added header template to allow for autocomplete on results view * Updated readme to mention autocomplete feature --- README.md | 7 +-- app/filter.py | 6 ++- app/request.py | 21 ++++++-- app/routes.py | 24 ++++++++- app/static/css/header.css | 55 ++++++++++++++++++++ app/static/css/search.css | 34 ++++++++++++ app/static/js/autocomplete.js | 98 +++++++++++++++++++++++++++++++++++ app/static/js/controller.js | 2 + app/templates/display.html | 4 ++ app/templates/header.html | 53 +++++++++++++++++++ app/templates/index.html | 8 ++- app/templates/opensearch.xml | 4 +- requirements.txt | 1 + test/test_autocomplete.py | 12 +++++ 14 files changed, 315 insertions(+), 14 deletions(-) create mode 100644 app/static/css/header.css create mode 100644 app/static/css/search.css create mode 100644 app/static/js/autocomplete.js create mode 100644 app/templates/header.html create mode 100644 test/test_autocomplete.py diff --git a/README.md b/README.md index f1876a0..a344f56 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Contents - No AMP links - No URL tracking tags (i.e. utm=%s) - No referrer header -- POST request search queries (when possible) +- Autocomplete/search suggestions +- POST request search and suggestion queries (when possible) - View images at full res without site redirect (currently mobile only) - Dark mode - Randomly generated User Agent @@ -107,7 +108,7 @@ Description=Whoogle Type=simple User=root WorkingDirectory= -ExecStart=/venv/bin/python3 -um app --host 0.0.0.0 --port 5000 +ExecStart=/venv/bin/python3 -um app --host 0.0.0.0 --port 5000 ExecReload=/bin/kill -HUP $MAINPID Restart=always RestartSec=3 @@ -185,7 +186,7 @@ To filter by a range of time, append ":past