Skip to content

Commit

Permalink
Added support for GitHub, Docker Hub, and Stack Overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zquestz committed Jan 25, 2016
1 parent 5e52ffb commit d766627
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
appName = "s"
version = "0.1.2"
version = "0.1.3"
)

// Flag variables
Expand Down
21 changes: 21 additions & 0 deletions providers/dockerhub/dockerhub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dockerhub

import (
"fmt"
"net/url"

"github.com/zquestz/s/providers"
)

func init() {
providers.AddProvider("dockerhub", &DockerHubProvider{})
}

// DockerHubProvider adheres to the Provider interface.
type DockerHubProvider struct {
}

// BuildURI generates a search URL for Docker Hub.
func (p *DockerHubProvider) BuildURI(q string) string {
return fmt.Sprintf("https://hub.docker.com/search/?q=%s", url.QueryEscape(q))
}
21 changes: 21 additions & 0 deletions providers/github/github.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package github

import (
"fmt"
"net/url"

"github.com/zquestz/s/providers"
)

func init() {
providers.AddProvider("github", &GitHubProvider{})
}

// GitHubProvider adheres to the Provider interface.
type GitHubProvider struct {
}

// BuildURI generates a search URL for GitHub.
func (p *GitHubProvider) BuildURI(q string) string {
return fmt.Sprintf("https://github.com/search?utf8=✓&q=%s", url.QueryEscape(q))
}
21 changes: 21 additions & 0 deletions providers/stackoverflow/stackoverflow.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package stackoverflow

import (
"fmt"
"net/url"

"github.com/zquestz/s/providers"
)

func init() {
providers.AddProvider("stackoverflow", &StackOverflowProvider{})
}

// StackOverflowProvider adheres to the Provider interface.
type StackOverflowProvider struct {
}

// BuildURI generates a search URL for Stack Overflow.
func (p *StackOverflowProvider) BuildURI(q string) string {
return fmt.Sprintf("http://stackoverflow.com/search?q=%s", url.QueryEscape(q))
}
3 changes: 3 additions & 0 deletions s.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
// Load necessary providers.
_ "github.com/zquestz/s/providers/amazon"
_ "github.com/zquestz/s/providers/bing"
_ "github.com/zquestz/s/providers/dockerhub"
_ "github.com/zquestz/s/providers/duckduckgo"
_ "github.com/zquestz/s/providers/github"
_ "github.com/zquestz/s/providers/google"
_ "github.com/zquestz/s/providers/reddit"
_ "github.com/zquestz/s/providers/stackoverflow"
_ "github.com/zquestz/s/providers/twitter"
_ "github.com/zquestz/s/providers/wikipedia"
_ "github.com/zquestz/s/providers/yahoo"
Expand Down

0 comments on commit d766627

Please sign in to comment.