Sharing Ubiquity Commands

I recently spoke with Aza Raskin at FOWA on Ubi­quity commands/​annotations shar­ing. I prom­ised I’ll pro­to­type some­thing, here it is…


(If the video is clipped, try it here)

When someone applies an Ubi­quity com­mand to a piece of con­tent that tells us what’s the type of that con­tent. The user is mak­ing an annota­tion which is not made for the annota­tion sake, but made for solv­ing a real need. That annota­tion if shared could be use­ful in vari­ous ways.

But first let’s look at all the data involved, con­sider that Alice is select­ing some text on a web page, invokes Ubi­quity and types ‘trans­late to japan­ese’. We have the folow­ing elements:

  1. user: anonym­ous or with an iden­tity (URI)
  2. web page address (URI)
  3. selec­ted content
  4. Ubi­quity com­mand (URI) with arguments

We need to find a way to identify the last 3 com­pon­ents with a single URI. Why? to tap into what URI power: you could book­mark, syn­chron­ise book­marks online, view the applied com­mand in your browser his­tory and just share that “link” via twit­ter, face­book, etc.

We can already point to a spe­cific loc­a­tion into a web page, provided that that loc­a­tion is emcom­passed into an elment that has an id, like:

http://​events​.car​son​i​fied​.com/​f​o​w​a​/​2009​/​l​o​n​d​o​n​/​s​p​e​a​k​ers#azaraskin

If that ele­ment had no id, we could use XPath to point to it, the full path in the DOM would be:

/html/body/div[3]/div/ul/li[3]/div/a

Or we could just simply assign iden­ti­fi­ers like the purple num­bers:

http://www.purpleslurple.net/ps.php?theurl=http…events.carsonified.com…speakers#purp199

How­ever we have an spe­cific­a­tion to address such con­tent — which even does bet­ter — it allows address­ing of ranges, ima­gine that your selec­tion crosses ele­ment bound­ar­ies (and users do such selec­tions), like select­ing “What you’ll learn * The advant­ages to using Objective-​J, Atlas and Cap­puccino” from the Atlas work­shop descrip­tion. That selec­tion starts with all the con­tent of a head­ing and ends up in a para­graph. The spe­cific­a­tion that can address this is XPointer, the URI that points to this selec­tion in that par­tic­u­lar web page looks like this:

http://​events​.car​son​i​fied​.com/​f​o​w​a​/​2009​/​l​o​n​d​o​n​/​w​o​r​k​s​h​ops#xpointer(start-point(string-range(/html[1]/body[1]/div[3]/div[1]/ul[1]/li[3]/div[1]/h6[1], “”, 1, 1))/range-to(end-point(string-range(/html[1]/body[1]/div[3]/div[1]/ul[1]/li[3]/div[1]/div[1]/p[1], “”, 591))))

It is quite verb­ose, if you want to pass it around you could shorten it to http://​bit​.ly/​l​k​DFs for example.

Now to pack the Ubi­quity com­mand line into, we could use a con­ven­tion, like:

http://…#ubiquity:command-line;xpointer(…

for example (here the URL is prop­erly escaped):

http://example.com/#ubiquity:translate%20to%20japanese;xpointer%28string-range%28/html[1]/body[1]/p[2],%20%22%22,%201,%2096%29%29 (again shorter would look like http://​bit​.ly/​4​u​f​0bX)

Hav­ing this con­ven­tion, all it is needed is to listen to Ubi­quity com­mands and update the loc­a­tion bar with the Ubi­quity URI, and when the user loads a page with such an URI it should repro­duce the selec­tion and invoke Ubiquity.

By the magic of Ubi­quity and XPointer exten­sion for Fire­fox, I pro­to­typed it in couple hours. Play­ing with it I observed the fol­low­ing issues:

  • it “records” in the loc­a­tion bar only one (the last) command
  • it is book­mark­able but the title of the book­mark doesn’t dis­close the existance of the command
  • if you share it with someone that opens it in another browser than Fire­fox, or it has Fire­fox without Ubi­quity, or have Ubi­quity but without the com­mand you shared, that per­son won’t notice any­thing (just loads the nor­mal page, #ubi­quity… is ignored)

For the first issues there are solu­tions, like stor­ing some­where (like in tinydb​.org) a stack of ‘Ubi­quity URIs’ to be applied in a spe­cific order, and

pass the stack iden­ti­fier around.

I added the com­mand line as a pre­fix to the title, and solved the second issue; now in browser’s his­tory or in a book­mark the above example reads “trans­late to japanese: Example Web Page”.

The third issue require an inter­me­di­ate page that would be shown if the user has no Fire­fox, Ubi­quity or that spe­cific com­mand; but this solu­tion cre­ates other issues:

  • it has a dif­fer­ent URI, which you need to use expli­citly when you share the Ubi­quity applied command
  • there is no way to detect from a web page that Ubi­quity is installed (it is a secur­ity risk) or what com­mands are available

Enough talk­ing, go play with the pro­to­type (you will see the inter­me­di­ate page men­tione above):

http://​name​bound​.com/​u​b​i​q​u​i​t​y​/​s​h​are

Note: You need to install xpoint­er­lib exten­sion and Ubi­quity must be at least 0.5.5pre7.

TODO:

  1. scroll page to the selec­tion, show icon to invoke Ubiquity
  2. wrap selec­tion with div/​span and annot­ate it with RDFa (to allow other exten­sions to participate)
  3. pub­lish user – annota­tion rela­tion (on user choice)
  4. load user, and friends annota­tions (ima­gine that Alice vis­ist Bob’s blog post on tonight’s party, and the venue was already mapped with Ubi­quity by Fred; Alice will see an icon/​hint to apply the map com­mand on that snippet)