Created
April 8, 2010 11:34
-
-
Save eversonl/359999 to your computer and use it in GitHub Desktop.
Google Lifhacker search
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
<?xml version="1.0" encoding="UTF-8"?> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" | |
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> | |
<head> | |
<title>Ubiquity Lifehacker Google Search Command</title> | |
</head> | |
<body> | |
<p>This page contains a Ubiquity command for Googling lifehackers archives.</p> | |
<script src="fake-infrastructure.js"></script> | |
<style> | |
div[id] {display: none} | |
script {display: block; white-space: pre; font-family: monospace} | |
</style> | |
<div id="google-search"> | |
{if results.length} | |
{for result in results} | |
<div class="gresult"> | |
<div> | |
${result.key}: <a href="${result.unescapedUrl}" accesskey="${result.key}">${result.title}</a> | |
</div> | |
<xul:description class="gresult-content">${result.content}</xul:description> | |
<div class="gresult-url">${result.visibleUrl}</div> | |
</div> | |
{/for} | |
<small>${tipsMessage}</small> | |
{else} | |
${noResultsMessage} | |
{/if} | |
</div> | |
<script class="commands"><![CDATA[ | |
CmdUtils.makeSearchCommand({ | |
names: ["lifehacker"], | |
url: "http://www.google.com/search?q=site:0-21.co.uk+{QUERY}", | |
icon: "http://www.lifehacker.com/favicon.ico", | |
description: "Searches LifeHacker(via Google) for your words.", | |
help: "You can use the keyboard shortcut ctrl + alt + number to open one " + | |
"of the Google results shown in the preview.", | |
preview: function google_preview(pblock, {object}) { | |
var searchTerm = object.text; | |
var searchTerm = "site:lifehacker.com "+object.text; | |
// Don't even display any text before fetching search results, | |
// since the results come back nearly instantaneously. In the | |
// future, we can display a throbber. | |
if (!searchTerm) return void this.previewDefault(pblock); | |
var url = "http://ajax.googleapis.com/ajax/services/search/web"; | |
var params = {v: "1.0", q: searchTerm}; | |
CmdUtils.previewGet(pblock, url, params, function google_get(data) { | |
var {results} = data.responseData; | |
results.forEach(function (r, i) { r.key = i + 1 }); | |
var noResultsMessage = _( | |
"Your search - ${searchTerm} - did not match any documents.", | |
{searchTerm: object.html.bold()}); | |
var tipsMessage = _( | |
"Tip: You can go to any result in this preview by pressing " + | |
"control, alt, and the result number at the same time."); | |
pblock.innerHTML = CmdUtils.renderTemplate( | |
feed.dom.getElementById("google-search").innerHTML, | |
{ results: results, | |
noResultsMessage: noResultsMessage, | |
tipsMessage: tipsMessage }); | |
}, "json"); | |
} | |
}); | |
]]></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment