Commit 4dbd903b authored by AdminXVII's avatar AdminXVII

Frontend search

parent 360e11ec
Pipeline #5433 passed with stages
in 1 minute and 2 seconds
......@@ -171,7 +171,7 @@ Since Ion does not support autocompletion via plugins, a lot of oh-my-zsh plugin
|--------------------------+--------------------------------|
| fossil | Not sure |
|--------------------------+--------------------------------|
| frontend-search | Planned |
| frontend-search | Done |
|--------------------------+--------------------------------|
| fzf | Planned, missing features |
|--------------------------+--------------------------------|
......
alias angular='frontend angular'
alias angularjs='frontend angularjs'
alias bem='frontend bem'
alias bootsnipp='frontend bootsnipp'
alias bundlephobia='frontend bundlephobia'
alias caniuse='frontend caniuse'
alias codepen='frontend codepen'
alias compassdoc='frontend compassdoc'
alias cssflow='frontend cssflow'
alias dartlang='frontend dartlang'
alias emberjs='frontend emberjs'
alias flowtype='frontend flowtype'
alias fontello='frontend fontello'
alias github='frontend github'
alias html5please='frontend html5please'
alias jestjs='frontend jestjs'
alias jquery='frontend jquery'
alias lodash='frontend lodash'
alias mdn='frontend mdn'
alias nodejs='frontend nodejs'
alias npmjs='frontend npmjs'
alias qunit='frontend qunit'
alias reactjs='frontend reactjs'
alias smacss='frontend smacss'
alias stackoverflow='frontend stackoverflow'
alias typescript='frontend typescript'
alias unheap='frontend unheap'
alias vuejs='frontend vuejs'
# define search context URLS
let _frontend_urls:hmap[str] = [
angular = 'https://angular.io/?search=' \
angularjs = 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' \
bem = 'https://google.com/search?as_sitesearch=bem.info&as_q=' \
bootsnipp = 'https://bootsnipp.com/search?q=' \
bundlephobia = 'https://bundlephobia.com/result?p=' \
caniuse = 'https://caniuse.com/#search=' \
codepen = 'https://codepen.io/search?q=' \
compassdoc = 'http://compass-style.org/search?q=' \
cssflow = 'http://www.cssflow.com/search?q=' \
dartlang = 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' \
emberjs = 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=' \
flowtype = 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=' \
fontello = 'http://fontello.com/#search=' \
github = 'https://github.com/search?q=' \
html5please = 'https://html5please.com/#' \
jestjs = 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q=' \
jquery = 'https://api.jquery.com/?s=' \
lodash = 'https://devdocs.io/lodash/index#' \
mdn = 'https://developer.mozilla.org/search?q=' \
nodejs = 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_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=' \
stackoverflow = 'https://stackoverflow.com/search?q=' \
typescript = 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=' \
unheap = 'http://www.unheap.com/?s=' \
vuejs = 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q=' \
]
fn frontend engine:str terms:[str]
# check whether the search context is supported
if test -z @_frontend_urls[$engine]
echo "Search context \"$engine\" currently not supported."
echo ""
echo "Valid contexts are:"
echo ""
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
echo ""
return 1
end
# build search url:
# join arguments passed with '%20', then append to search context URL
# TODO substitute for proper urlencode method
let url = "@_frontend_urls[$engine]$join(@terms '%20')"
echo "Opening $url ..."
# TODO: open_command like zsh
xdg-open "$url"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment