Skip to content

Instantly share code, notes, and snippets.



Created Feb 12, 2009
What would you like to do?
search 0-21 with google
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="" xml:lang="en" lang="en"
<title>Ubiquity 0-21 Google Search Command</title>
<p>This page contains a Ubiquity command for Googling's archives.</p>
<script src="fake-infrastructure.js"></script>
div[id] {display: none}
script {display: block; white-space: pre; font-family: monospace}
<div id="google-search">
{if results.length}
{for result in results}
<div class="gresult">
${result.key}: <a href="${result.unescapedUrl}" accesskey="${result.key}">${result.title}</a>
<xul:description class="gresult-content">${result.content}</xul:description>
<div class="gresult-url">${result.visibleUrl}</div>
<script class="commands"><![CDATA[
names: ["0-21"],
url: "{QUERY}",
icon: "",
description: "Searches 0-21 (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 = " "+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 = "";
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(
{ results: results,
noResultsMessage: noResultsMessage,
tipsMessage: tipsMessage });
}, "json");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.