From ed863f6fa4cd1006c31f60edb3ad0639c6983e37 Mon Sep 17 00:00:00 2001 From: Michael SALIHI Date: Thu, 10 Sep 2015 07:34:00 +0200 Subject: Search completion; add support for Qwant completion --- background_scripts/completion_engines.coffee | 12 ++++++++++++ lib/settings.coffee | 1 + 2 files changed, 13 insertions(+) diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index b572375d..6c2fbf8d 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -140,6 +140,17 @@ class Webster extends BaseEngine parse: (xhr) -> JSON.parse(xhr.responseText).suggestions +class Qwant extends BaseEngine + constructor: -> + super + engineUrl: "https://api.qwant.com/api/suggest?q=%s" + regexps: "^https?://www\\.qwant\\.com/" + example: + searchUrl: "https://www.qwant.com/?q=%s" + keyword: "qw" + + parse: (xhr) -> JSON.parse(xhr.responseText)[1] + # 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 always be a completion engine match. class DummyCompletionEngine extends BaseEngine @@ -158,6 +169,7 @@ CompletionEngines = [ Bing Amazon Webster + Qwant DummyCompletionEngine ] diff --git a/lib/settings.coffee b/lib/settings.coffee index 99a20963..0d787036 100644 --- a/lib/settings.coffee +++ b/lib/settings.coffee @@ -156,6 +156,7 @@ Settings = # b: https://www.bing.com/search?q=%s Bing # d: https://duckduckgo.com/?q=%s DuckDuckGo # az: http://www.amazon.com/s/?field-keywords=%s Amazon + # qw: https://www.qwant.com/?q=%s Qwant """ newTabUrl: "chrome://newtab" grabBackFocus: false -- cgit v1.2.3 From 238717fe4f3997389bc1f7ac35cb2cd86abdca25 Mon Sep 17 00:00:00 2001 From: Michael SALIHI Date: Thu, 10 Sep 2015 07:55:23 +0200 Subject: Update CREDITS with new contributors --- CREDITS | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS b/CREDITS index 539b998c..e05a1c6a 100644 --- a/CREDITS +++ b/CREDITS @@ -43,5 +43,6 @@ Contributors: Timo Sand (github: deiga) Shiyong Chen (github: UncleBill) Utkarsh Upadhyay (github: PrestanceDesign) Feel free to add real names in addition to GitHub usernames. -- cgit v1.2.3 From 3c1c4d44b0b7aec174f4d952c0a0d0bb2babf64c Mon Sep 17 00:00:00 2001 From: Michael SALIHI Date: Thu, 10 Sep 2015 10:54:22 +0200 Subject: Fix JSON incorrect parsing for Qwant autocompletion --- background_scripts/completion_engines.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 6c2fbf8d..3e3f772c 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -149,7 +149,8 @@ class Qwant extends BaseEngine searchUrl: "https://www.qwant.com/?q=%s" keyword: "qw" - parse: (xhr) -> JSON.parse(xhr.responseText)[1] + parse: (xhr) -> + suggestion.value for suggestion in JSON.parse(xhr.responseText).data.items # 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 always be a completion engine match. -- cgit v1.2.3