Skip to content

Instantly share code, notes, and snippets.

@andykent
Last active December 15, 2015 09:38
Show Gist options
  • Save andykent/5239448 to your computer and use it in GitHub Desktop.
Save andykent/5239448 to your computer and use it in GitHub Desktop.
# name: Google Search
# description: Search Google for stuff.
# keyword: google
# homepage: http://google.com
bolt.run ->
if command.hasQuery
url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+command.query+"&callback=?"
http.getJSON url, (data) ->
if data.responseData
for item in data.responseData.results
result
title: utils.sanitize(item.title)
description: utils.sanitize(item.content)
action: actions.open(item.url)
else
result
title: "Query Failed!"
description: "Google Failed to serve this query. Try Again?"
action: actions.repeat()
else
result
title: meta.name
description: "Type your query to continue"
// name: Google Search
// description: Search Google for stuff.
// keyword: google
// homepage: http://google.com
bolt.run(function(){
if(command.hasQuery) {
var url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q="+command.query+"&callback=?"
http.getJSON(url, function(data) {
if(data.responseData) {
for(i in data.responseData.results) {
var item = data.responseData.results[i];
result({
title: utils.sanitize(item.title),
description: utils.sanitize(item.content),
action: actions.open(item.url)
});
}
} else {
result({
title: "Query Failed!",
description: "Google Failed to serve this query. Try Again?",
action: actions.repeat()
});
}
});
} else {
result({
title: meta.name,
description: "Type your query to continue"
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment