Ubiquity is a new and experimental Firefox plugin from Mozilla Labs. The project is in its infancy but the goal is the create an easy-to-use, on-the-fly mashup tool that can combine web services using natural language commands.
Ubiquity is basically an attempt to build a user interface for the open web at large. It’s a command-line user interface, which, for most people, may not sound at all like an “easier” way to communicate with an application. But the important thing that Ubiquity does is allow users to manipulate web services by typing commands into the browser using plain language.
In practice Ubiquity works something like Mac OS X app Quicksilver or some of the clones it has inspired on other platforms. Hit the shortcut key (ctrl-space by default) and the Ubiquity overlay pops up. Type the name of a command and hit enter. That's it.
For example there's twitter command. To use it just activate Ubiquity, type twitter, enter your message and press enter -- you just posted a message. Ubiquity gets more useful when you use it interact with the web. For instance, highlight a word you don't know on a webpage. Activate Ubiquity and type wiki this. Ubiquity will then look up the word on Wikipedia.
other built-in commands include the ability to embed a map in an e-mail, select some Craigslist items you're interested in and type map
, Ubiquity will show you the seller's location on a Google Map.
It's a quite powerful idea and, if it catches on, may well change the way you interact with your browser.
But the real power is in the ability to write and share your own custom Ubiquity scripts, which is what we're about to dive in and do.
One thing to keep in mind though is that is a very alpha project. Mozilla has already said the radical changes to the Ubiquity API are not just likely, they're almost certain. That means that what works today, may not tomorrow, but we're early adopters and that's just the price we have to pay.
Plus, since this is wiki page, we can all work together to keep things up-to-date.
Ready to dive in?
== Overview ==
Ubiquity commands are written in JavaScript, so having something of a JavaScript background helps, but as you'll see it's not too hard to pick it up as we go. Before we get started, head over to Mozilla Labs and install Ubiquity.
Also be sure to check out the [https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_Author_Tutorial very thorough tutorial] on the Mozilla site. It covers a number of things that we won't be delving into right now.
The other link you'll find invaluable is the Ubiquity command Editor. You can open it by activating Ubiquity and typing command-editor
or just click this link: [chrome://ubiquity/content/editor.html chrome://ubiquity/content/editor.html]
The command editor is where we'll be writing and testing our scripts. It's no subsistute for a text editor, but it does a good job of showing your scripts in action without needing to restart Firefox.
The last thing we recommend is Firebug, which will be helpful in sorting out any JavaScript error in your scripts.
== Hello World ==
Okay, now that you have Ubiquity installed and the command editor open in your browser, let's start with a simple hello world app. Paste this code into the Ubiquity command editor:
function cmd_hello_world() { displayMessage( "Hello, World!") }Hit the Ubiquity shortcut, type "hello-world", hit return and you should see a hello world notice popup (note that on Mac OS X, the notices are displayed using Growl, so you'll need to have that installed otherwise you won't see anything). Now that we have everything set up and working it's time to dive into more serious code. == ma.gnolia bookmarker == Here's a script that will take the current webpage and send it to ma.gnolia. If you have any text on the page highlighted it will be used for the description and you can input tags at the Ubiquity prompt. Here's the code:
To use the script just activate Ubiquity and type "magnolia." Enter your tags and hit return. You'll be prompted to login and once you do your bookmark will be added.