6da59ff046d7a81483345d0e16333a69eb96ccc6

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

frontend-search: add Angular 2 context (#7830)

* Add search URL for angular 2
* Convert + to %20 encoding

Diff

 1diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
 2index f06e7910207da2736ea53936723d453d191bd4a3..24f82b26264dd7e0cd3b1dda59d1f3747782a176 100644
 3--- a/plugins/frontend-search/README.md
 4+++ b/plugins/frontend-search/README.md
 5@@ -32,7 +32,8 @@ Available search contexts are:
 6 
 7 | context       | URL                                                                      |
 8 |---------------|--------------------------------------------------------------------------|
 9-| angularjs     | `https://google.com/search?as_sitesearch=angularjs.org&as_q=`            |
10+| angular(>=2.0)| `https://angular.io/?search=`                                             |
11+| angularjs(1.x)| `https://google.com/search?as_sitesearch=angularjs.org&as_q=`
12 | aurajs        | `http://aurajs.com/api/#stq=`                                            |
13 | bem           | `https://google.com/search?as_sitesearch=bem.info&as_q=`                 |
14 | bootsnipp     | `https://bootsnipp.com/search?q=`                                         |
15diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh
16index 9aad76f762d6c6201cb65d8b66479588f19fe944..573aa3aaef8c01c7d952b7b2c39cdbe19d754a52 100644
17--- a/plugins/frontend-search/_frontend-search.sh
18+++ b/plugins/frontend-search/_frontend-search.sh
19@@ -33,7 +33,8 @@ function _frontend() {
20     'unheap: Search in unheap website'
21     'bem: Search in BEM website'
22     'smacss: Search in SMACSS website'
23-    'angularjs: Search in Angular website'
24+    'angular: Search in Angular website for Angular 2.x'
25+    'angularjs: Search in Angular website for Angular 1.x'
26     'reactjs: Search in React website'
27     'emberjs: Search in Ember website'
28     'stackoverflow: Search in StackOverflow website'
29@@ -99,6 +100,9 @@ function _frontend() {
30         smacss)
31           _describe -t points "Warp points" frontend_points && ret=0
32           ;;
33+        angular)
34+          _describe -t points "Warp points" frontend_points && ret=0
35+        ;;
36         angularjs)
37           _describe -t points "Warp points" frontend_points && ret=0
38           ;;
39diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
40index 14877fb0d396f9fe0bdd915e7e4d080705742499..bef5992a32ce7ff48098c851c1794024b8f9f600 100644
41--- a/plugins/frontend-search/frontend-search.plugin.zsh
42+++ b/plugins/frontend-search/frontend-search.plugin.zsh
43@@ -1,3 +1,4 @@
44+alias angular='frontend angular'
45 alias angularjs='frontend angularjs'
46 alias aurajs='frontend aurajs'
47 alias bem='frontend bem'
48@@ -26,6 +27,7 @@ function frontend() {
49   # define search context URLS
50   typeset -A urls
51   urls=(
52+    angular        'https://angular.io/?search='
53     angularjs      'https://google.com/search?as_sitesearch=angularjs.org&as_q='
54     aurajs         'http://aurajs.com/api/#stq='
55     bem            'https://google.com/search?as_sitesearch=bem.info&as_q='
56@@ -57,9 +59,9 @@ function frontend() {
57       print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
58       print -P "and %Ucontext%u is one of the following:"
59       print -P ""
60-      print -P "  angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
61-      print -P "  dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
62-      print -P "  qunit, reactjs, smacss, stackoverflow, unheap"
63+      print -P "  angular (>= 2.0), angularjs (1.x), aurajs, bem, bootsnipp, caniuse, codepen,"
64+      print -P "  compassdoc, cssflow, dartlang, emberjs, fontello, html5please, jquery,"
65+      print -P "  lodash, mdn, npmjs, qunit, reactjs, smacss, stackoverflow, unheap"
66       print -P ""
67       print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
68       print -P ""
69@@ -73,17 +75,17 @@ function frontend() {
70     echo ""
71     echo "Valid contexts are:"
72     echo ""
73-    echo "  angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, "
74-    echo "  dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,  "
75-    echo "  qunit, reactjs, smacss, stackoverflow, unheap"
76+    echo "  angular (>= 2.0), angularjs (1.x), aurajs, bem, bootsnipp, caniuse, codepen,"
77+    echo "  compassdoc, cssflow, dartlang, emberjs, fontello, html5please, jquery,"
78+    echo "  lodash, mdn, npmjs, qunit, reactjs, smacss, stackoverflow, unheap"
79     echo ""
80     return 1
81   fi
82 
83   # build search url:
84-  # join arguments passed with '+', then append to search context URL
85+  # join arguments passed with '%20', then append to search context URL
86   # TODO substitute for proper urlencode method
87-  url="${urls[$1]}${(j:+:)@[2,-1]}"
88+  url="${urls[$1]}${(j:%20:)@[2,-1]}"
89 
90   echo "Opening $url ..."
91