From d18b15b76ed394f8468172acebada6a0aac5218a Mon Sep 17 00:00:00 2001 From: quest Date: Wed, 5 Jan 2022 12:22:16 -1000 Subject: [PATCH] Add ecosia provider --- README.md | 1 + providers/ecosia/ecosia.go | 25 +++++++++++++++++++++++++ s.go | 1 + 3 files changed, 27 insertions(+) create mode 100644 providers/ecosia/ecosia.go diff --git a/README.md b/README.md index 4b28077..35118f7 100644 --- a/README.md +++ b/README.md @@ -253,6 +253,7 @@ Custom providers require a few things: * dribbble * duckduckgo * dumpert +* ecosia * engadget * explainshell * facebook diff --git a/providers/ecosia/ecosia.go b/providers/ecosia/ecosia.go new file mode 100644 index 0000000..d59a918 --- /dev/null +++ b/providers/ecosia/ecosia.go @@ -0,0 +1,25 @@ +package ecosia + +import ( + "fmt" + "net/url" + + "github.com/zquestz/s/providers" +) + +func init() { + providers.AddProvider("ecosia", &Provider{}) +} + +// Provider merely implements the Provider interface. +type Provider struct{} + +// BuildURI generates a search URL for Ecosia. +func (p *Provider) BuildURI(q string) string { + return fmt.Sprintf("https://www.ecosia.org/search?q=%s", url.QueryEscape(q)) +} + +// Tags returns the tags relevant to this provider. +func (p *Provider) Tags() []string { + return []string{"search"} +} diff --git a/s.go b/s.go index 1e46b46..635ae80 100644 --- a/s.go +++ b/s.go @@ -39,6 +39,7 @@ import ( _ "github.com/zquestz/s/providers/dribbble" _ "github.com/zquestz/s/providers/duckduckgo" _ "github.com/zquestz/s/providers/dumpert" + _ "github.com/zquestz/s/providers/ecosia" _ "github.com/zquestz/s/providers/engadget" _ "github.com/zquestz/s/providers/explainshell" _ "github.com/zquestz/s/providers/facebook"