diff options
| author | Stephen Blott | 2015-05-03 11:29:43 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-03 11:31:29 +0100 |
| commit | 07a62680008b6c86b0cf8a12969334bd7c1e389c (patch) | |
| tree | 5a02dc65993489f86c197ecaed0e1cb9086d192a /background_scripts | |
| parent | 7ecc8805053cfe32549136412d16d5c62d6949c7 (diff) | |
| download | vimium-07a62680008b6c86b0cf8a12969334bd7c1e389c.tar.bz2 | |
Search completion; DuckDuckGo.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 9 | ||||
| -rw-r--r-- | background_scripts/search_engines.coffee | 8 | ||||
| -rw-r--r-- | background_scripts/settings.coffee | 3 |
3 files changed, 14 insertions, 6 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index e678b2f7..4d2546fc 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -51,11 +51,10 @@ completionSources = completers = omni: new MultiCompleter([ - completionSources.searchEngines - # completionSources.bookmarks, - # completionSources.history, - # completionSources.domains - ]) + completionSources.searchEngines, + completionSources.bookmarks, + completionSources.history, + completionSources.domains]) bookmarks: new MultiCompleter([completionSources.bookmarks]) tabs: new MultiCompleter([completionSources.tabs]) diff --git a/background_scripts/search_engines.coffee b/background_scripts/search_engines.coffee index 362de3cc..043e3268 100644 --- a/background_scripts/search_engines.coffee +++ b/background_scripts/search_engines.coffee @@ -88,6 +88,13 @@ class Amazon extends RegexpEngine getUrl: (queryTerms) -> "https://completion.amazon.com/search/complete?method=completion&search-alias=aps&client=amazon-search-ui&mkt=1&q=#{Utils.createSearchQuery queryTerms}" parse: (xhr) -> JSON.parse(xhr.responseText)[1] +class DuckDuckGo extends RegexpEngine + # Example search URL: https://duckduckgo.com/?q=%s + constructor: -> super [ new RegExp "^https?://([a-z]+\.)?duckduckgo\.com/" ] + getUrl: (queryTerms) -> "https://duckduckgo.com/ac/?q=#{Utils.createSearchQuery queryTerms}" + parse: (xhr) -> + suggestion.phrase for suggestion in JSON.parse xhr.responseText + # A dummy search engine which is guaranteed to match any search URL, but never produces completions. This # allows the rest of the logic to be written knowing that there will be a search engine match. class DummySearchEngine @@ -99,6 +106,7 @@ class DummySearchEngine completionEngines = [ Youtube Google + DuckDuckGo Wikipedia Bing Amazon diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index 06b59af8..07db3a89 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -91,11 +91,12 @@ root.Settings = Settings = searchUrl: "http://www.google.com/search?q=" # put in an example search engine searchEngines: [ - # FIXME(smblott) Comment out these before merge. + # FIXME(smblott) Comment these out before merge. "w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia" "t: http://www.youtube.com/results?search_query=%s Youtube" "m: https://www.google.com/maps/search/%s Google Maps" "b: https://www.bing.com/search?q=%s Bing" + "d: https://duckduckgo.com/?q=%s DuckDuckGo" "y: http://www.youtube.com/results?search_query=%s Youtube" "az: http://www.amazon.com/s/?field-keywords=%s Amazon" ].join "\n\n" |
