Commit Graph

462 Commits (main)

Author SHA1 Message Date
Ben Busby e6db3112f7
Fix pagination bug for pages > 3
The pagination footer on the results page after page 2 has three actions
(beginning, next, previous). The footer filter was updated to remove
items with more than three actions to fix this.

See #131
4 years ago
Ben Busby 6c429e6dd1
Allow setting site alts using environment vars (#155)
* Add ability to configure site alts w/ env vars

Site alternatives (i.e. twitter.com -> nitter.net) can now be configured
using environment variables:

WHOOGLE_ALT_TW='nitter.net' # twitter alt
WHOOGLE_ALT_YT='invidio.us' # youtube alt
WHOOGLE_ALT_IG='bibliogram.art/u' # instagram alt

Updated testing to confirm results have been modified.

* Add site alt vars to docker settings and readme
4 years ago
Ben Busby 44a5da1895
Fix heroku https upgrade, add funding options
Heroku app instances have been notoriously bad at having the instance
automatically upgraded to https. This adds a step in the before request
decorator to always upgrade heroku apps, since they're always deployed
with the certificate, but never configured to upgrade automatically.

Fixes #153
4 years ago
Ben Busby 54109874fb
Move screenshots/branding to separate docs folder 4 years ago
Ben Busby 2d0823b012
Hotfix: Remove mobile subdomain for invidious redirect
See #151
4 years ago
Ben Busby 0afd59056f
Hotfix: update invidious url, remove www from link
The invidious instance has been updated to invidious.snopyta.org, since
this instance is more reliable and has more users according to
instances.invidio.us

All site alternative redirects now redirect without the 'www' subdomain,
since most of the alternative sites don't have this subdomain set up.
4 years ago
Ben Busby 0d0f32d108
Hotfix: update ad filter for portugese config 4 years ago
Ben Busby a519de90af
Enforce GET-only in opensearch for Chrome
The resolution for enabling full support for search + suggestions in
Chrome is to remove the "method" tag altogether for any Chrome based
browser. Any inclusion of this tag seems to break the search suggestion
feature, and makes the user add the search engine manually.
4 years ago
Ben Busby 72cbc342af Add ability to set temp config in search query
Dark mode, country, interface language, and search language configs
can now be set in the search query by appending each option as a
url parameter.

Supported args are: 'dark', 'lang_search', 'lang_interface', and 'ctry'

Ex: /search?q=%s&dark=1&lang_search=lang_en...

These config settings persist across page navigation and switching
result type, but will be reset if the main search bar is used.

See #144
4 years ago
Ben Busby f88d1fbb66 Fix main page visibility for noscript users
The body tag of the home page was previously hidden until the page was
finished loading to prevent a flash of unstyled content, but this broke
functionality for users who disallow javascript. This adds in a new
noscript tag to manually enable visibility of the body element, as well
as automatically displaying the config section (since its visibility is
also typically handled by javascript).
4 years ago
bugbounce 1148a7fb8d
Use relative links instead of absolute (#139)
* Use relative links instead of absolute

This allows for hosting under a subpath. For example if you want to host
whoogle at example.com/whoogle, it should work better with a reverse proxy.

* Use relative link for opensearch.xml
4 years ago
Ben Busby 933ce7e068 Handle FF sending bad search suggestion param
Occasionally, Firefox will send the search suggestion
string to the server without a mimetype, resulting in the suggestion
only appearing in Flask's `request.data` field. This field is typically
not used for parsing arguments, as the documentation states:

Contains the incoming request data as string in case it came with a
mimetype Flask does not handle.

This fix captures the bytes object sent to the server and parses it into
a normal query to be used in forming suggestions.
4 years ago
Ben Busby 0ef098069e
Add tor and http/socks proxy support (#137)
* Add tor and http/socks proxy support

Allows users to enable/disable tor from the config menu, which will
forward all requests through Tor.

Also adds support for setting environment variables for alternative
proxy support. Setting the following variables will forward requests
through the proxy:
    - WHOOGLE_PROXY_USER (optional)
    - WHOOGLE_PROXY_PASS (optional)
    - WHOOGLE_PROXY_TYPE (required)
      - Can be "http", "socks4", or "socks5"
    - WHOOGLE_PROXY_LOC  (required)
      - Format: "<ip address>:<port>"

See #30

* Refactor acquire_tor_conn -> acquire_tor_identity

Also updated travis CI to set up tor

* Add check for Tor socket on init, improve Tor error handling

Initializing the app sends a heartbeat request to Tor to check for
availability, and updates the home page config options accordingly. This
heartbeat is sent on every request, to ensure Tor support can be
reconfigured without restarting the entire app.

If Tor support is enabled, and a subsequent request fails, then a new
TorError exception is raised, and the Tor feature is disabled until a
valid connection is restored.

The max attempts has been updated to 10, since 5 seemed a bit too low
for how quickly the attempts go by.

* Change send_tor_signal arg type, update function doc

send_tor_signal now accepts a stem.Signal arg (a bit cleaner tbh). Also
added the doc string for the "disable" attribute in TorError.

* Fix tor identity logic in Request.send

* Update proxy init, change proxyloc var name

Proxy is now only initialized if both type and location are specified,
as neither have a default fallback and both are required. I suppose the
type could fall back to http, but seems safer this way.

Also refactored proxyurl -> proxyloc for the runtime args in order to
match the Dockerfile args.

* Add tor/proxy support for Docker builds, fix opensearch/init

The Dockerfile is now updated to include support for Tor configuration,
with a working torrc file included in the repo.

An issue with opensearch was fixed as well, which was uncovered during
testing and was simple enough to fix here. Likewise, DDG bang gen was
updated to only ever happen if the file didn't exist previously, as
testing with the file being regenerated every time was tedious.

* Add missing "@" for socks proxy requests
4 years ago
Ben Busby f3bb1e22b4 Fix improper header styling, remove shopping tab links
The header template was using Google's classes for the "Whoogle" logo,
which meant keeping up with their list of colors used in the logo. The
template was updated to only ever use the Whoogle logo color.
Accordingly, the logo specific styling in filter.py was removed, since
it is no longer needed.

Also removes all links to the shopping tab, as it seems that the
majority of the links to items are Google specific links (usually
google.com/aclk links without any discernible param for determining the
true location for the link). The shopping page should be addressed
separately with unique filtering/formatting. Further tracking of this
task will be followed in #136.
4 years ago
Ben Busby ae05e8ff8b Finished basic implementation of DDG bang feature
Initialization of the app now includes generation of a ddg-bang json
file, which is used for all bang style searches afterwards.

Also added search suggestion handling for bang json lookup. Queries
beginning with "!" now reference the bang json file to pull all keys
that match.

Updated test suite to include basic tests for bang functionality.

Updated gitignore to exclude bang subdir.
4 years ago
Ben Busby 2126742b76
Merge branch 'develop' into develop 4 years ago
Ben Busby b01b6d8c69 Minor change to wording of language config 4 years ago
curlpipe 558e3e1514
Fixed annoying browser autocomplete (#128) 4 years ago
Ben Busby dfb1e81fa1 Added search input auto focus, updated README
The javascript controller has been updated to include a call to focus
the cursor on the search field. This previously had only been seen on
Firefox, and was assumed to be a weird FF-specific bug. Adding in a
timeout to allow elements to finish loading allows the field to be
focused as expected.

Also updated the README to include clarification for IP address
tracking.
4 years ago
Ben Busby 9a03b4111d Clarified country filter, updated invidious result URL (closes #123)
Improves clarity of the meaning behind the "Country" filter -- Google
seemingly uses this value to only return results that are hosted in a
particular country, as evidenced in the search differences highlighted
in #123. It now mentions that the results are filtered by website
hosting location.

Also, now that invidio.us is shut down, the fallback URL (invidiou.site)
is now used instead.
4 years ago
Ben Busby 9afe5f81bd
Updated dark theme (#121)
* Implemented new dark theme

Now uses a dedicated css file for all dark theme color changes, rather
than replacing color codes directly.

Color theme is from discussion in #60.

* Minor link color update
4 years ago
Ben Busby e471b012a0 Updated opensearch template
Reconfigured template to only use method parameter if set to search via
POST request (which is the default).

Apparently Chrome/Chromium based browsers don't like non-GET request
searches, and specifying a method caused Chrome to reject the template
altogether.
4 years ago
Ben Busby 0c0a01b83f Minor opensearch route and description updates
Bumped version to 0.2.1 for next release

Updated image in opensearch template to use base64 image

Updated opensearch route to serve file as attachment
4 years ago
Ben Busby b2ecd8dc78 Updated search suggestion behavior (closes #115)
Arrow key navigation through search suggestions now populates the input
field with text content from the active selection. Navigating "down"
past the end of the suggestions list returns the active cursor to position 0,
while navigating "up" before the list of suggestions restores the
original search query and removes the active highlight from element 0.
4 years ago
Ben Busby 975ece8cd0
Privacy respecting alternatives in results view (#106)
Full implementation of social media alt redirects (twitter/youtube/instagram -> nitter/invidious/bibliogram) depending on configuration.

Verbatim search and option to ignore search autocorrect are now supported as well.

Also cleaned up the javascript side of whoogle config so that it now
uses arrays of available fields for parsing config values instead of manually assigning each
one to a variable.

This doesn't include support for Google Maps -> Open Street Maps, that
seems a bit more involved than the social media redirects were, so it
should likely be a separate effort.
4 years ago
Marvin Borner 5575bcd0af
Merge branch 'develop' into develop 4 years ago
Joao A. Candido Ramos bf4bf1ff2c
Split interface and results language config (#89)
Adding support to choose separately the language of search and the one for the interface (allowing a default givent by google).

Co-authored-by: Joao <ramos.joao@protonmail.com>
4 years ago
Marvin Borner dd9d87d25b
Added ddg-style !bang-operators
This is a proof of concept! The code works, but uses hardcoded operators
and may be placed in the wrong file/class.
The best-case scenario would be the possibility to use the 13.000+ ddg
operators, but I don't know if that's possible without having to
redirect to duckduckgo first.
4 years ago
Ben Busby ebfa87f561
Fixed dark mode footer text color
Updated to use config accessor rather than boolean value
4 years ago
Ben Busby b2133edaa3
Session refactoring and improved filter (#86)
* Project refactor (#85)

* Major refactor of requests and session management

- Switches from pycurl to requests library
  - Allows for less janky decoding, especially with non-latin character
  sets
- Adds session level management of user configs
  - Allows for each session to set its own config -- users with blocked cookies fall back to the "default" profile (same usage as before)
- Updates key gen/regen to more aggressively swap out keys after each
request

* Added ability to save/load configs by name

- New PUT method for config allows changing config with specified name
- New methods in js controller to handle loading/saving of configs

* Result formatting and removal of unused elements

- Fixed question section formatting from results page (added appropriate
padding and made questions styled as italic)
- Removed user agent display from main config settings

* Minor change to save config button label (now "Save As...")

* Fixed issue with "de-pickling" of flask session

Having a gitignore-everything ("*") file within a flask session folder seems to cause a
weird bug where the state of the app becomes unusable from continuously
trying to prune files listed in the gitignore (and it can't prune '*').

* Switched to pickling saved configs

* Updated ad/sponsored content filter and conf naming

Configs are now named with a .conf extension to allow for easier manual
cleanup/modification of named config files

Sponsored content now removed by basic string matching of span content

* Version bump to 0.2.0

* Fixed request.send return style

* Moved custom conf files to their own directory

* Refactored whoogle session mgmt

Now allows a fallback "default" session to be used if a user's browser
is blocking cookies

* Reworked pytest client fixture to support new session mgmt

* Added better multilingual support, updated filter

Results page now includes method for switching to "All Languages" from
whichever language is specified as the primary in the config (see #74).

Also removes the non-Whoogle links from the page footer, leaving only
the page navigation controls

Added support for the date range filter on the results page, though I'd
still recommend using the ":past <unit>" query instead.

* Removed no-cache enforcement, minor styling/formatting improvements

* Improving ad filtering for non-English languages

* Added footer to results page
4 years ago
Ben Busby 71ba00785f Quick improvement to ad removal 4 years ago
Ben Busby cb18bc6ccc Updated autocomplete styling
Added dark theme specific stylesheet to use if dark mode is active
4 years ago
Ben Busby 78939e7fb4 Reworked google url routing 4 years ago
Ben Busby 98d639883c Fixing styling/url/safe mode inconsistencies 4 years ago
Ben Busby 9212f9921a Fixed #76
Added enter key submit on results page

Added results type carryover for subsequent searches on results page

Removed redundant header on image search results
4 years ago
Ben Busby d1f38cf924 Fixed styling of footer in dark mode 4 years ago
Ben Busby 21012f5265
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
4 years ago
Ben Busby 3dbe51e9e7 Removing google's filter card from results 4 years ago
Ben Busby 09c53b52af
Feature: country and safe search config options (#71)
* Added country and safe search config options

* Updated handling of parser error in results test

* Improved handling of default country

* Added 1px empty gif fallback as a replacement for images that fail to load
4 years ago
Ben Busby 699aa4f2e7 Bumped version to 0.1.4 4 years ago
Ben Busby b131f47641 Bumped version to v0.1.3
(forgot to update pip package version)
4 years ago
Ben Busby f1e17d8119
Bumped version to v0.1.2 4 years ago
Ben Busby c51f186419 Added version footer, minor PEP 8 refactoring 4 years ago
Ben Busby 38b7b19e2a
Added basic authentication (#51)
Username/password can be set either as Dockerfile build arguments or
passed into the run script as "--userpass <username:password>"
4 years ago
Paul Rothrock 0e39b8f97b
Added "I'm feeling lucky" function (#46)
* Putting '! ' at the beginning of the query now redirects to the first search result

Signed-off-by: Paul Rothrock <paul@movetoiceland.com>

* Moved get_first_url outside of filter class

Signed-off-by: Paul Rothrock <paul@movetoiceland.com>
4 years ago
Ben Busby a4382d59f6
Updated redirect code used in https redirects
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections

301 redirections do not keep the request method intact, and can occasionally be changed from POST to GET

308 redirections always keep the request method, which is necessary for all POST search requests
4 years ago
Ben Busby b4165f9957 Minor improvement to https enforcement 4 years ago
Ben Busby 3123789584
Added config option for opening links in new tab (#49) 4 years ago
Ben Busby 1ed6178e9a
Feature: https only -- adds option to enforce https on running instances (#48)
* Adding HTTPS enforcement

Command line runs of Whoogle Search through pip/pipx/etc will need the
`--https-only` flag appended to the run command.

Docker runs require the `use_https` build arg applied.

* Update README.md

Moved https-only note to top of docker run command, updated pip runner help output

* Dockerfile: removed HTTPS enforcement, updated PORT setting

Dockerfile no longer enforces an HTTPS connection, but still allows for
setting via a build arg. The Flask server port is now configurable as a
build arg as well, by setting a port number to "whoogle_port"

* Fixed incorrect port assignment
4 years ago
Ben Busby afd5b9aa83 Minor fix to dark mode on img results 4 years ago
Ben Busby 87f0a8d496
Added volume mounted config to Dockerfile (#39) 4 years ago
Ben Busby f4bd3df2bb
Added option to search only via GET request (#36)
This addresses #18, which brought up the issue of searching with Whoogle
with the search instance set to always use a specific container in
Firefox Container Tabs.

Could also be useful if you want to share your search results or
something, I guess. Though nobody likes when people do that.
4 years ago
Ben Busby a11ceb0a57
Feature: language config (#27)
* Added language configuration support

Main page now has a dropdown for selecting preferred language of
results.

Refactored config to be its own model with language constants.

* Added more language support

Interface language is now updated using the "hl" arg

Fixed chinese traditional and simplified values

Updated decoding of characters to gb2312

* Updated to use conditional decoding dependent on language

* Updated filter to not rely on valid config to work properly
4 years ago
Jake Howard f700ed88e7
Swap out Flask's default web server for Waitress (#32)
* Ignore venv when building docker file

* Remove reference to 8888 port

It wasn't really used anywhere, and setting it to 5000 everywhere removes ambiguity, and makes things easier to track and reason about

* Use waitress rather than Flask's built in web server

It's not production grade

* Actually add waitress to requirements

Woops!
4 years ago
Ben Busby 445019d204 Fixed RAM usage bug
Pushing straight to master since this is an extremely simple fix, with
a pretty large performance benefit.

The Phyme library used for generating a User Agent rhyme was consuming
an absolute unit of memory. Now that it's removed, it's using about 10x
less memory, at the cost of User Agents being not as funny anymore.
4 years ago
Ben Busby 1798b6094d
Merge pull request #16 from Kombustor/patch-1
Add autofocus to input field
4 years ago
Ben Busby 7ccad2799e Added config option to address instance behind reverse proxy
Config options now allow setting a "root url", which defaults to the
request url root. Saving a new url in this field will allow for proper
redirects and usage of the opensearch element.

Also provides a possible solution for #17, where the default flask redirect method redirects to
http instead of https.
4 years ago
Fabian Schliski 743caf6cc7
Updating autofocus value 4 years ago
Fabian Schliski 0fc5fa9d99
Add autofocus to input field
Supported in all major browsers, allows the user to immediately start typing after loading the page.
4 years ago
Ben Busby 130ac4532e Refactored handling of user config
Now implemented as a flask global variable reads from the same json file
as before, but doesn't crash if it does not find an existing file.

Removed user config creation from run script
4 years ago
Ben Busby d316fd77c6 Updated setup and routes for pipx compatibility 4 years ago
Ben Busby d01f56ea03 Removed referrer from links, refacored routes
Added <meta name="referrer" content="no-referrer"> to all whoogle
templates

Refactored search route to use conditionally use either request.args or
request.form, depending on rest call (get vs post respectively)
4 years ago
Ben Busby 708769f682 Minor styling refactor, updated app name 4 years ago
Ben Busby 0300eab6df Updated formatting and setup instructions
Switched encoding from utf-8 to unicode-escape in an effort to support multiple
languages besides English.

Updated image results page formatting to fix bad image links (added TODO
for adding full res image link for each image result).

Updated README to include libcurl and libssl install instructions for
manual setup.
4 years ago
Ben Busby 39c475af21 Using urlencode "doseq" option for url args 4 years ago
Ben Busby 3e404cb524 Restructured valid params checking, added empty query redirect 4 years ago
Ben Busby c30f21f950 Minor conditional fix in filter 4 years ago
Ben Busby b83f14be26 Fixed image href filter
Needed to be checking against img attrs, not just the img object itself
4 years ago
Ben Busby 6d38abd1b4 Removed debug from opensearch template 4 years ago
Ben Busby dcd93d4869 Fixed filter params, updated search button text 4 years ago
Ben Busby 5fe308956b Cleaned up filter class, updated js config tool 4 years ago
Ben Busby 0a3da5cea4 Updated js controller and config api route
Controller was refactored to be a bit less monolithic.

Config route was updated to accept an html form data POST rather than
just a json object.
4 years ago
Ben Busby 1cbe394e6f Updated tests, fixed a few bugs
Added opensearch routes test and individual tests for searching via GET
and POST separately.

Fixed incorrect assignment in gen_query.
4 years ago
Ben Busby 0c0ebb8917 Added POST search, encrypted query strings, refactoring
The implementation of POST search support comes with a few benefits. The
most apparent is the avoidance of search queries appearing in web server
logs -- instead of the prior GET approach (i.e.
/search?q=my+search+query), using POST requests with the query stored in
the request body creates logs that simply appear as "/search".

Since a lot of relative links are generated in the results page, I came
up with a way to generate a unique key at run time that is used to
encrypt any query strings before sending to the user. This benefits both
regular text queries as well as fetching of image links and means that
web logs will only show an encrypted string where a link or query
string might slip through.

Unfortunately, GET search requests still need to be supported, as it
doesn't seem that Firefox (on iOS) supports loading search engines by
their opensearch.xml file, but instead relies on manual entry of a
search query string. Once this is updated, I'll probably remove GET
request search support.
4 years ago
Ben Busby 4180aedd87 Added image proxying, refactored filter class
Images were previously directly fetched from google search results,
which was a potential privacy hazard. All image sources are now modified
to be passed through shoogle's routing first, which will then fetch raw
image data and pass it through to the user.

Filter class was refactored to split the primary clean method into
smaller, more manageable submethods.
4 years ago
Ben Busby b0e6167733 Improved bad url arg filtering 4 years ago
Ben Busby 3bc58b64be Small update to filter class
The image results page seems to have different formatting from non-image
results pages. Should probably revisit this at some point and try to
style the image results page to be more in line with other result types.
4 years ago
Ben Busby 38c0f56322 Fixed gitignore, added required files 4 years ago
Ben Busby 1f6bfa092e Complete refactoring of opensearch
Refactored opensearch.xml to only exist as a template that is
served by a flask route, which is then populated with the
necessary url root.
4 years ago
Ben Busby 525f7adf22 Merge branch 'master' of github.com:benbusby/shoogle 4 years ago
Ben Busby e21341d6f4 Deployment related refactoring, fixes to Dockerfile
- Updated Dockerfile to include chmod of run script
- Added app.json for Heroku quick deploy
- Removed unused function var in js controller
- Moved requirements back to root of repo
- Added Codebeat report to readme
4 years ago
Ben Busby a7005c012e Refactoring of user requests and routing
Curl requests and user agent related functionality was moved to its own
request class.

Routes was refactored to only include strictly routing related
functionality.

Filter class was cleaned up (had routing/request related logic in here,
which didn't make sense)
4 years ago
Ben Busby 31b9e19af7 Fixed main banner in readme 4 years ago
Ben Busby 67e3c788c7 Updated readme, added screenshots 4 years ago
Ben Busby 6a150092a2 Fixed config bug in filter, updated run script to work on mac os 4 years ago
Ben Busby 2631335dbf Updated README 4 years ago
Ben Busby bd773ec5ff Small update to js config request 4 years ago
Ben Busby e72ccc4988 Small change to mobile styling 4 years ago
Ben Busby 024552f2df Minor refactor of filter class, updated tests, fixed html/css, added ua to config 4 years ago
Ben Busby b5b6e64177 Added testing and ci build, refactored filter class, refactored project structure 4 years ago
Ben Busby 67d8b0d99d Updated favicons 4 years ago
Ben Busby 48b9f66490 Fixed incorrect opensearch template, updated readme 4 years ago
Ben Busby 20fce34db3 Added opensearch setup 4 years ago
Ben Busby ea7ddce7b3 Updated dockerfile and run script to work with heroku deployment 4 years ago
Ben Busby 850a46aea1 Refactored routes, added filter class for returned results, added dockerignore 4 years ago
Ben Busby 08a8a3e064 Fixed missing page title 4 years ago
Ben Busby 5bfc4d9a74 Added user config for nojs links and dark mode, minor styling updates 4 years ago
Ben Busby a00ccb1da8 Small fix for viewing images on mobile, updated document title formatting 4 years ago
Ben Busby 2411f9de8d Fixed bug in nojs config setting, updated pages to use new favicon and proper headers 4 years ago
Ben Busby 5687c87a65 Adding optional nojs links to results page, changed nojs to a user setting 4 years ago
Ben Busby 6a82f6e1ad Added filtering of sponsored content 4 years ago
Ben Busby 066c253c4d Added ability to update config from home page 4 years ago
Ben Busby 9c0b4a7f58 Minor fix for filtering by time range 4 years ago
Ben Busby 254c987254 Added filter by date range, minor aesthetic changes 4 years ago
Ben Busby 9fbaa1d6cf Added run script, updated to use config json file for general location, general restyling 4 years ago
Ben Busby d90468c667 Updated to remove ads, minor renaming refactor 4 years ago
Ben Busby 24aa4367d3 Added optional no-js functionality, added location based searching (hardcoded), updated html 4 years ago
Ben Busby 4636b0f695 Added html parsing to remove returned scripts, added logo 4 years ago
Ben Busby b11fc5fe67 Improved homepage styling 4 years ago
Ben Busby a922b42cbd Added desktop/mobile agent switching, updated gitignore 4 years ago
Ben Busby 1e1bb4a55a Added tbm (images/news/etc) handling, updated front page and search controls 4 years ago
Ben Busby 6e7eef165e Initial commit 4 years ago