Alexis Bauchu - On est pas des machines

Aller au contenu | Aller au menu | Aller à la recherche

Mot-clé - ubiquity

Fil des billets - Fil des commentaires

jeudi, septembre 3 2009

Update of the 'Share on reader' command for Ubiquity

I've finally updated that command that allows to share content on your Google Reader Shared Items page (providing you've got one!). The new version allows you to type the name without the hyphens (no more share-on-reader), you can also type share using reader, or note using reader, or note with reader.For those of you who don't know Ubiquity, head up to the project page.

You can install the "Share on reader" command by going there and clicking subscribe in the popup above the page.

CmdUtils.CreateCommand({
  names: [ "share on Reader", "note with Reader", "share using Reader", "note using reader" ],
  homepage: "http://abauchu.net/",
  icon: "http://www.google.com/reader/ui/favicon.ico",
  author: { name: "Alexis Bauchu", email: "alexis.bauchu@gmail.com" },
  license: "MPL",
  description: "Shares content Google Reader's shared stuff page and allow you to add a note.",
  help: "This uses Google Reader, so you need a Google account to use this command.",

 
  arguments: [ 
    { role: 'object', nountype: noun_arb_text, label: 'extract' }
  ],

 
  execute: function (args) {
   var cmd = "var b=document.body;var GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}";
   var doc = Application.activeWindow.activeTab.document;
   var body = doc.body;
   void (cript = doc.createElement('script'));
   void (code = doc.createTextNode(cmd));
   void (cript.appendChild(code));
   void (body.appendChild(cript));
  }

});

jeudi, janvier 8 2009

Ubiquity command: share-on-reader and share-on-reader-secure

The share-on-reader command is the first ubiquity command I've ever coded. I made it just to try ubiquity's command editor, but I wouldn't expect people to use it. It's basically a wrapper of Google Reader's bookmarklet that allows you to select (or not) text from a web page, and share it with a note on your Google Reader Shared Stuff Page (providing you've got a Google Account and activated Google Reader). It's that simple. You can subscribe to that command on that page. Here is the code:

CmdUtils.CreateCommand({
  name: "share-on-reader",
  homepage: "http://abauchu.net/",
  icon: "http://www.google.com/reader/ui/favicon.ico",
  author: { name: "Alexis Bauchu", email: "alexis.bauchu@gmail.com"},
  license: "MPL",
  description: "Shares content Google Reader's shared stuff page and allow you to add a note.",
  help: "This uses Google Reader, so you need a Google account to use this command.",
 
  takes: {"your selection": noun_arb_text},
  preview: function( pblock, selection ) {
    pblock.innerHTML = "Shares \"" + selection.html + "\" with Google Reader and allows to add a note";
  },
  execute: function(selection) {
   var cmd = "var b=document.body;var GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}";
   var doc = Application.activeWindow.activeTab.document;
   var body = doc.body;
   void (cript = doc.createElement('script'));
   void (code = doc.createTextNode(cmd));
   void (cript.appendChild(code));
   void (body.appendChild(cript));
  }
});

The code is rather long, because at the time there wasn't any command like CmdUtils.makeBookmarkletCommant(). I could have updated it, but I like it like that. You know, it's my first one.

But this command doesn't work with the https version of Google Reader (I should say the bookmarklet doesn't work, because I virtually didn't code anything). Someone commented about it in this blog: he uses the customizegoogle extension which automatically redirects the normal url to the secured one (https). And it breaks the command. So I tried some stuff, and came with a solution: in fact, on the https version of the website, Google provides ANOTHER bookmarklet, working this time. Simple! You can subscribe here. Here's the code:

CmdUtils.makeBookmarkletCommand({
  name: "share-on-reader-secure",
  url: "javascript:var%20b=document.body;var%20GR________bookmarklet_domain='https://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='https://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}"
});

Reminder: makeBookmarkletCommand

This is just a reminder: how to make a command out of a bookmarklet. For example, a command that embed a Flickr photo (the example is taken from Aza Raskin's blog).

CmdUtils.makeBookmarkletCommand({
name: "Embed Flickr Photo",
url: "javascript:(function(){if(window.page_p)window.open('http://www.elsewhere.org/mbedr/?p='+window.page_p.id);%20else%20alert('No%20Flickr%20photo%20found.');})()"
});

Replace the url by your bookmarklet code.

mercredi, décembre 31 2008

Ubiquity: makeSearchCommand template

This is just a reminder of the search command template. It allows you to create in no time what must be the most used feature of Ubiquity at the moment.

Use the command-editor command, and type the following code in the editor:

CmdUtils.makeSearchCommand({
  name: "your-function-name",
  url: "http://url-to-my-search-engine/?q={QUERY}",
  icon: "http://url-to-my-search-engine/favicon.ico",
  description: "Searches 'my-search-engine' for your words."
});

And just replace your-function-name and url-to-my-search-engine by your own new values. You may have to adapt the query url though.

An example, which searches cplusplus.com:

CmdUtils.makeSearchCommand({
  name: "c++",
  url: "http://www.cplusplus.com/query/search.cgi?q={QUERY}",
  icon: "http://www.cplusplus.com/favicon.ico",
  description: "Searches cplusplus.com for your words."
});

Ubiquity for Firefox

Ubiquity is a prototype extension for Firefox developed by guys of the Mozilla labs. It proposes to use a command line using human language in Firefox to create mashups, uses web services, do searchs, etc. But if you don't know that awesome extension yet, the following video will explain everything:

Lire la suite...