In our last open source class Dave asked us to work through a lab where we worked with Ubiquity, a Firefox extension. So, I had a go at it. I installed it and read the articles that introduce the add-on to a new user. I have to say that it it quite useful and intuitive. Although the extension is not yet at version 1.0 I think I will still use it. I have to say I’m a bit eccentric about extensions. I love using them and playing around with them. I can’t live without them, to be honest. Ubiquity is just another addition to my ever growing add-on list.
Ubiquity adds great convenience to your browser. It’s basically a command line tool for performing browser tasks. Anybody that likes working with an easily accessible command line will greatly enjoy this extension. All one has to do is press ctrl-space (on Windows) and ubiquity will appear in the top left corner of your browser, ready to use. Now, all you have to do is enter the right command and it will do your bidding.
One feature that I’m particularly impressed with is the ability to email your selection. This can include links, pictures and anything else. To do this all one has to do is select whatever you desire, press ctrl-space and then type “email this to [recipient's email]” or “email selection to [recipient's email]” or “email it to [recipient's email]“. Very useful if you ask me.
Ubiquity has many built-in commands that come with the add-on but it also allows users to put on their programming hats and do a bit of coding themselves to create their own commands. This feature is great since the users are no longer limited by what the developers put into ubiquity. If you feel that there should be some command in ubiquity that isn’t there currently, then you can code it yourself. This is a great example of how open source works. Users can very easily become developers and hats off to the Ubiquity development team for making this transition as seamless as possible.
I tried my hand at making my own commands. I began by coding a simple user search for our zenit/wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 | CmdUtils.CreateCommand({ name: "zenit/wiki user search:", takes: {"search zenit/wiki user": noun_arb_text}, preview: function( pblock, wikiquery ) { pblock.innerHTML = "Searching For: " + wikiquery.text; }, execute: function( wikiquery ) { var url = "http://zenit.senecac.on.ca/wiki/index.php/Special:Search?ns2=1&search={QUERY}&searchx=Search"; var query = wikiquery.text; var urlString = url.replace("{QUERY}", query); Utils.openUrlInBrowser(urlString); } }) |
The Ubiquity development team has made it quite easy for the users to create new commands. All we have to do is follow the command structure. So as you can see here for example in the name section you type the name of the command, in the execute section you code what the command is exactly suppose to do. So in this case the function receives the name of the user and performs some URL manipulation and opens the new URL in a new tab. Very simple stuff. Other students also created their on commands. You can have a peak at them here.
I also tried to create another command for jslint. Basically the idea was to select any text (hopefully JavaScript code) and then type jslint into the Ubiquity command line. This should open up jslint in a new tab with the selected text being displayed in the main textarea of jslint (where one is suppose to paste the JavaScript code). Unfortunately, after a few hours of struggle I couldn’t get it to work. One of things that make it quite hard is that jslint is coded in Ajax and it’s URL doesn’t change, which means that I cannot perform any URL manipulation. I attempted to use html.replace and even looked into using jQuery‘s append function but all in vain. Eventually I gave up. I’m sure I could have figured it out given more time. Just a shout out to Tiago for spending the time with me to try to figure this out, he was very helpful.
Below is the code we came up with, which obviously does not work but if anybody wants to take this as a starting point and go from there please be my guest. Just make sure to post your results on here good or bad. I would love to know.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | CmdUtils.CreateCommand({ name: "jslint", takes: {"word": noun_arb_text}, execute: function(directObj) { var selectedCode = directObj.text; var urlString = "http://www.jslint.com"; Utils.openUrlInBrowser(urlString); var params = { }; jQuery.post( urlString, params, function( html ) { var old = "<textarea id="input"></textarea>"; var newHtml = "<textarea id="input">" + $selectedCode + "</textarea>"; html = html.replace( old, newHtml ); }); }, }) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | CmdUtils.CreateCommand({ name: "jslint", takes: {"word": noun_arb_text}, execute: function(directObj) { var selectedCode = directObj.text; var urlString = "http://www.jslint.com"; Utils.openUrlInBrowser(urlString); var params = { }; jQuery.post( urlString, params, function( html ) { ("textarea").append(selectedCode); }); }, }) |
Hi Sid,
I was trying to get the jslint command to work. I was gonna create a hidden iframe that holds the jslint then pass it the text to be tested and return the results in the preview pane.
But….ubiquity kept crashing when I tried to add an iframe that had a source so I got on the ubiquity irc channel, was able to get a few guys to reproduce it and now I have submitted a ticket about it.
I’ll be blogging about it more at my blog.
http://dee132.blogspot.com/