Created
February 17, 2009 19:04
-
-
Save morozowski/65907 to your computer and use it in GitHub Desktop.
Ubiquity Command "lyrics" or "letra(s)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.makeSearchCommand({ | |
name: "lyrics", | |
description: "Searches lyrics at letras.mus.br (powered by Google).", | |
url: "http://www.google.com/search?q=site:letras.terra.com.br+{QUERY}", | |
icon: "http://letras.terra.com.br/favicon.ico", | |
homepage: "http://gist.github.com/65907", | |
author: { name: "Morozowski", email: "morozowski+ubiquity [at] gmail [dot] com"}, | |
license: "GPL", | |
synonyms: ["letra", "letras"], | |
preview: function(pblock, directObject) { | |
var searchTerm = directObject.text; | |
if(searchTerm.length < 1) { | |
pblock.innerHTML = "Searches lyrics at letras.mus.br."; | |
return; | |
} | |
var url = "http://ajax.googleapis.com/ajax/services/search/web"; | |
var params = { v: "1.0", q: "site:letras.terra.com.br " + searchTerm }; | |
CmdUtils.previewGet( pblock, url, params, function(data) { | |
var numToDisplay = 10; | |
var results = data.responseData.results; | |
var html = ''; | |
for(var i=0;i<results.length && i<numToDisplay;i++){ | |
html += "<p>"+(i+1)+": <u><a href=\""+results[i].url+"\" accesskey=\""+(i+1)+"\">"+results[i].title+"</a></u></p>"; | |
} | |
html += "<small>Tip: You can go to any result in this preview by using its number as an access key. (Linux and Windows: alt-number, Mac: control-number)</small>\n"; | |
pblock.innerHTML = html; | |
}, "json"); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment