2019-05-06 10:09:51 -07:00
|
|
|
alias angular='frontend angular'
|
2015-08-31 10:12:05 -07:00
|
|
|
alias angularjs='frontend angularjs'
|
|
|
|
alias aurajs='frontend aurajs'
|
|
|
|
alias bem='frontend bem'
|
|
|
|
alias bootsnipp='frontend bootsnipp'
|
|
|
|
alias caniuse='frontend caniuse'
|
|
|
|
alias codepen='frontend codepen'
|
2016-02-21 06:09:27 -07:00
|
|
|
alias compassdoc='frontend compassdoc'
|
2015-08-31 10:12:05 -07:00
|
|
|
alias cssflow='frontend cssflow'
|
|
|
|
alias dartlang='frontend dartlang'
|
|
|
|
alias emberjs='frontend emberjs'
|
|
|
|
alias fontello='frontend fontello'
|
|
|
|
alias html5please='frontend html5please'
|
|
|
|
alias jquery='frontend jquery'
|
|
|
|
alias lodash='frontend lodash'
|
|
|
|
alias mdn='frontend mdn'
|
|
|
|
alias npmjs='frontend npmjs'
|
|
|
|
alias qunit='frontend qunit'
|
|
|
|
alias reactjs='frontend reactjs'
|
|
|
|
alias smacss='frontend smacss'
|
|
|
|
alias stackoverflow='frontend stackoverflow'
|
|
|
|
alias unheap='frontend unheap'
|
|
|
|
|
2014-06-19 19:27:40 -07:00
|
|
|
function frontend() {
|
2015-08-29 15:09:15 -07:00
|
|
|
emulate -L zsh
|
|
|
|
|
2015-08-31 09:49:05 -07:00
|
|
|
# define search context URLS
|
2015-08-29 15:09:15 -07:00
|
|
|
typeset -A urls
|
|
|
|
urls=(
|
2019-05-05 19:17:45 -07:00
|
|
|
angular 'https://angular.io/?search='
|
|
|
|
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
|
2015-08-29 15:09:15 -07:00
|
|
|
aurajs 'http://aurajs.com/api/#stq='
|
|
|
|
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
|
2018-08-07 11:42:02 -07:00
|
|
|
bootsnipp 'https://bootsnipp.com/search?q='
|
|
|
|
caniuse 'https://caniuse.com/#search='
|
|
|
|
codepen 'https://codepen.io/search?q='
|
2016-02-21 06:09:27 -07:00
|
|
|
compassdoc 'http://compass-style.org/search?q='
|
2015-08-29 15:09:15 -07:00
|
|
|
cssflow 'http://www.cssflow.com/search?q='
|
|
|
|
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
2018-08-07 11:42:02 -07:00
|
|
|
emberjs 'https://emberjs.com/api/#stp=1&stq='
|
2015-08-29 15:09:15 -07:00
|
|
|
fontello 'http://fontello.com/#search='
|
|
|
|
html5please 'http://html5please.com/#'
|
|
|
|
jquery 'https://api.jquery.com/?s='
|
|
|
|
lodash 'https://devdocs.io/lodash/index#'
|
|
|
|
mdn 'https://developer.mozilla.org/search?q='
|
|
|
|
npmjs 'https://www.npmjs.com/search?q='
|
|
|
|
qunit 'https://api.qunitjs.com/?s='
|
|
|
|
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
|
|
|
|
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
|
2018-08-07 11:42:02 -07:00
|
|
|
stackoverflow 'https://stackoverflow.com/search?q='
|
2015-08-29 15:09:15 -07:00
|
|
|
unheap 'http://www.unheap.com/?s='
|
|
|
|
)
|
2014-06-19 19:27:40 -07:00
|
|
|
|
2015-08-31 09:49:05 -07:00
|
|
|
# show help for command list
|
|
|
|
if [[ $# -lt 2 ]]
|
2014-07-03 18:53:00 -07:00
|
|
|
then
|
2015-08-31 09:49:05 -07:00
|
|
|
print -P "Usage: frontend %Ucontext%u %Uterm%u [...%Umore%u] (or just: %Ucontext%u %Uterm%u [...%Umore%u])"
|
2019-05-04 13:42:06 -07:00
|
|
|
print -P ""
|
2015-08-31 09:49:05 -07:00
|
|
|
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
|
|
|
|
print -P "and %Ucontext%u is one of the following:"
|
|
|
|
print -P ""
|
2019-05-06 10:09:51 -07:00
|
|
|
print -P " angular (>= 2.0), angularjs (1.x), aurajs, bem, bootsnipp, caniuse, codepen,"
|
|
|
|
print -P " compassdoc, cssflow, dartlang, emberjs, fontello, html5please, jquery,"
|
|
|
|
print -P " lodash, mdn, npmjs, qunit, reactjs, smacss, stackoverflow, unheap"
|
2015-08-31 09:49:05 -07:00
|
|
|
print -P ""
|
|
|
|
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
|
|
|
|
print -P ""
|
2014-07-03 18:53:00 -07:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2015-08-31 09:49:05 -07:00
|
|
|
# check whether the search context is supported
|
2014-07-03 18:53:00 -07:00
|
|
|
if [[ -z "$urls[$1]" ]]
|
2014-06-19 19:27:40 -07:00
|
|
|
then
|
2015-08-31 09:49:05 -07:00
|
|
|
echo "Search context \"$1\" currently not supported."
|
|
|
|
echo ""
|
|
|
|
echo "Valid contexts are:"
|
|
|
|
echo ""
|
2019-05-06 10:09:51 -07:00
|
|
|
echo " angular (>= 2.0), angularjs (1.x), aurajs, bem, bootsnipp, caniuse, codepen,"
|
|
|
|
echo " compassdoc, cssflow, dartlang, emberjs, fontello, html5please, jquery,"
|
|
|
|
echo " lodash, mdn, npmjs, qunit, reactjs, smacss, stackoverflow, unheap"
|
2014-06-19 19:27:40 -07:00
|
|
|
echo ""
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2015-08-29 15:09:15 -07:00
|
|
|
# build search url:
|
2019-05-06 10:09:51 -07:00
|
|
|
# join arguments passed with '%20', then append to search context URL
|
2015-08-29 15:09:15 -07:00
|
|
|
# TODO substitute for proper urlencode method
|
2019-05-04 13:42:06 -07:00
|
|
|
url="${urls[$1]}${(j:%20:)@[2,-1]}"
|
2014-06-19 19:27:40 -07:00
|
|
|
|
2015-08-31 09:49:05 -07:00
|
|
|
echo "Opening $url ..."
|
2014-06-19 19:27:40 -07:00
|
|
|
|
2015-08-04 15:32:57 -07:00
|
|
|
open_command "$url"
|
2014-06-19 19:27:40 -07:00
|
|
|
}
|