Ubiquity and Sandy (iwantsandy.com)
Home Home Contact us Contact
home News Projects Tests Files Follow manatlan on Twitter Sign in
back 2008/09/01 16:44

Ubiquity and Sandy (iwantsandy.com)

Ubiquity is the new mozilla buzz (A kind of commandline for firefox). And Sandy is a reminder service. I wanted to use Sandy with Ubiquity.

This is my first try. It's able to make the authent if '_sandyAuthent' is configured. Without that, it can only write to Sandy if you are already logued in iwantsandy.com ;-).

Here is my contribution :

CmdUtils.CreateCommand({
  name: "sandy",
  homepage: "http://manatlan.com/",
  author: { name: "manatlan", email: "me@manatlan.com"},
  license: "GPL",
  description: "Write to Sandy (iwantsandy.com), make authent if needed",
  takes: {"text": noun_arb_text},

  _sandyAuthent: { "email": "xxxx", "password": "yyyy"},

  _write: function(msg) {
    var params = {"message[body]":msg};

    jQuery.ajax({
      type: "POST",
      url: "http://iwantsandy.com/email/create",
      data: params,
      error: function() {
        displayMessage("Where is sandy ?! a problem occured ;-)");
      },
      success: function() {
        displayMessage("Ok, Sandy will '"+msg+"'");
      }
    });
  },


  preview: function( pblock,txt ) {
    pblock.innerHTML = 'Sandy, "'+txt.text+'"';
  },


  execute: function(txt) {
    zis = this;

    jQuery.ajax({
      type: "GET",
      url: "http://iwantsandy.com/email/new",
      error: function() {
        displayMessage("Where is sandy ?! a problem occured ;-)");
      },
      success: function(data) {
        if(data.indexOf("Log in")>0) {
            // not logued yet ...

            // so log in
            jQuery.ajax({
              type: "POST",
              url: "http://iwantsandy.com/session",
              data: zis._sandyAuthent,
              error: function() {
                displayMessage("Where is sandy ?! a problem occured ;-)");
              },
              success: function(data) {
                if(data.indexOf("Log in")>0) 
                    displayMessage("Need authent to write to sandy (configure '_sandyAuthent')");
                else
                    zis._write(txt.text);
              }
            });


        }
        else {
            zis._write(txt.text);
        }
      }
    });

  }
})

two posts in one day ! great !

EDIT 02/09/2008 For now, put this script in your command-editor. In a near future, it will be hosted on this domain, in an ubiquity way. I'd like to find a way to prompt the user for its registration informations (any ideas ?). In a near future, it will be able to display (in preview), the daily digest and others listings ... Discussions have started here and here

RSS Python Powered Get Ubuntu
©opyleft 2008-2019 - manatlan