~samhh/bangin-server-node

A basic web server around bangin written in Node.js.
e9be91e7 — Sam A. Horvath-Hunt 7 months ago
0.2.0
67c7ecf0 — Sam A. Horvath-Hunt 7 months ago
Support a custom fallback location
ad599c1b — Sam A. Horvath-Hunt 7 months ago
Document custom search engines in Safari

clone

read-only
https://git.sr.ht/~samhh/bangin-server-node
read/write
git@git.sr.ht:~samhh/bangin-server-node

You can also use your local clone with git send-email.

#bangin-server-node

A basic web server around bangin written in Node.js.

#Prerequisites

  • Node.js 10+
  • bangin (in your $PATH)

#Usage

Run the server with:

node index.js [port] [fallback]

If no port is provided then it will default to 1234.

If no fallback is provided it will default to DuckDuckGo. The fallback syntax mirrors that of bangin, replacing any {{{s}}} with the search value.

Requests must include a non-empty value at querystring q. The string will first be routed to bangin before yielding to the fallback.

The response if successful will be a 303 redirect that browsers can handle.

Examples:

$ curl -I 'http://localhost:1234?q=x!aw'
HTTP/1.1 303 See Other
Location: https://wiki.archlinux.org/index.php?search=x
[...]

$ curl -I 'http://localhost:1234?q=x'
HTTP/1.1 303 See Other
Location: https://duckduckgo.com/?q=x
[...]

#Setting as the browser search engine

#Chrome/similar

  1. Go to chrome://settings/searchEngines.
  2. Add a new search engine with the URL pointing to http://localhost:<port>/?q=%s.

#Firefox

Firefox does not yet support fully custom search engines. You can track the relevant issue here.

#Safari

Safari does not support custom search engines. Some search engines such as Kagi workaround this with a WebExtension.