<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Olivier is a Front End Developer at Lab49, London, a strategy, design and technology consulting firm that creates advanced solutions for the world’s leading investment banks, asset managers and exchanges. He has a strong experience in developing real-time HTML5 applications.
He’s the author of Emily and Olives, two JavaScript frameworks that allow to easily create powerful web applications on top of node.js, with high UI performance and low memory footprint.</description><title>Olivier Scherrer</title><generator>Tumblr (3.0; @podefr)</generator><link>http://podefr.tumblr.com/</link><item><title>Missing feature of the day: grouping DOM nodes</title><description>&lt;p&gt;Let&amp;#8217;s say that you’re developing a JS Framework that has the concept of widgets. A widget is a JavaScript Object with a representation in the DOM. As you have one reference on the JS Object somewhere in your application, you’ll want to have one reference to its DOM structure, and unfortunately the only way is to wrap the template into one parent DOM element.&lt;/p&gt;

&lt;p&gt;For example, one of your widgets has the following template:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;
    Text 
&amp;lt;/p&amp;gt;
&amp;lt;ul&amp;gt;
    List items
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When converting this to dom nodes (how you do it doesn&amp;#8217;t matter here) you may have a list of dom elements, one p tag, and one ul tag, or have a parent dom element wrapping them. Let’s call these two items a group. But when this group gets appended to the dom, you lose the notion of group, as they become two nodes among the others.&lt;/p&gt;

&lt;p&gt;To illustrate this, let’s imagine that after being attached (how you do it doesn&amp;#8217;t matter here) we have the following structure:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;
        Text
    &amp;lt;/p&amp;gt;
    &amp;lt;ul&amp;gt;
        List items
    &amp;lt;/ul&amp;gt;
    &amp;lt;p&amp;gt;
        Another widget here
     &amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As the notion of group is lost, there is no way now to distinguish them from the dom nodes of another widget. We can’t take them out and append them somewhere else.&lt;/p&gt;

&lt;p&gt;This problem is solved by wrapping them into a parent dom element, which creates the notion of groups. Usually a div is chosen. But the drawback here is that we have added an unnecessary dom element that could have been avoided. And unnecessary dom elements are one major cause of performance loss.&lt;/p&gt;

&lt;p&gt;One way of solving this issue would have been with using a document fragment. A documentFragment looks like a dom element though it can&amp;#8217;t have a representation in the actual dom. Unfortunately, once appended to the dom, it loses its children.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// this is our dom element that doesn't exist in the DOM
var domFrag = document.createDocumentFragment();

// We add it actual dom elements, they're part of our widget
domFrag.appendChild(domElement1);
domFrag.appendChild(domElement2);

// It has two children
domFrag.childNodes.length == 2; // true

// We append our non-dom element somewhere into the DOM
destinationDom.appendChild(domFrag);

// Our documentFragment still exists, but has no more children
// Of course, it doesn't exist in the DOM, though its child now do.
domFrag.childNodes.length == 0; // true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Another way of doing it would have been to have a grouping method in the DOM.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// A real dom element without tag
var domGroup = document.createDocumentGroup();

// Let's call its innerHTML, it's fast and cross browser.
domGroup.innerHTML = "&amp;lt;p&amp;gt;Text&amp;lt;/p&amp;gt;&amp;lt;ul&amp;gt;list items&amp;lt;/ul&amp;gt;";

// That's two items
domGroup.childNodes.length == 2; // true

// They get appended to destinationDom, no extra HTML tag added.
destinationDom.appendChild(domGroup);

// They're still part of the domGroup.
domGroup.childNodes.length == 2; // true

// So I can move them around
otherDestinationDom.appendChild(domGroup)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The domGroup would not have a representation in the dom, so its children could be direct children of the destinationDom, but can still be moved around by appending the group somewhere else.
If ever a childNode gets appended somewhere else, it would simply leave the group.&lt;/p&gt;

&lt;p&gt;You may also have noticed that a documentFragment doesn&amp;#8217;t have an innerHTML property, which is a shame as it&amp;#8217;s a cool way for creating dom nodes out of strings, and it&amp;#8217;s fast because it&amp;#8217;s using the browser&amp;#8217;s rendering engine.&lt;/p&gt;

&lt;p&gt;Fortunately, the domGroup would have this feature, which would become the number one tool for defining a widget&amp;#8217;s view:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var widget = {
    this.element: document.createDocumentGroup(),

    this.render: function (template) {
        if (template instanceof HTMLElement) {
            this.element.appendChild(template);
        } else if (typeof template == "string") {
            this.element.innerHTML = template;
        } else {
            throw new Error('template must be either a string a set of dom elements');
        }
    },

   this.place: function (destinationDom) {
        destinationDom.appendChild(this.element);
   }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How cool would that be?&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/40637452994</link><guid>http://podefr.tumblr.com/post/40637452994</guid><pubDate>Wed, 16 Jan 2013 01:04:00 +0100</pubDate><category>html</category><category>framework</category><category>widgets</category><category>missing feature</category><category>feature request</category></item><item><title>Migrating from Emily 1.2.0 to 1.3.1</title><description>&lt;p&gt;&lt;a href="http://podefr.tumblr.com/post/39606341462/migrating-from-olives-1-2-0-to-1-3-0"&gt;Last week I explained how to migrate from Olives 1.2.0 to 1.3.0&lt;/a&gt;. Emily has seen a few breaking changes too between 1.2.0 and 1.3.1:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Modules are anonymous&lt;/li&gt;
&lt;li&gt;Promise is fixed&lt;/li&gt;
&lt;li&gt;CouchDBStore has been completely removed&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Modules are anonymous&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://podefr.tumblr.com/post/39606341462/migrating-from-olives-1-2-0-to-1-3-0"&gt;Olives modules are now anonymous, just like Emily&amp;#8217;s. Read this to know what the implications are.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Promise is fixed&lt;/h2&gt;

&lt;p&gt;Until 1.3.0, Emily&amp;#8217;s Promises where an interpretation of Promise/A, but were done wrong. After &lt;a href="https://gist.github.com/3889970"&gt;Domenic&amp;#8217;s gist on promise&lt;/a&gt; I realized that I had to fix them. 
Emily 1.3.0 made Promise compliant with promise/A, and since 1.3.1 they&amp;#8217;re now also compliant with &lt;a href="https://github.com/promises-aplus"&gt;Promise/A+&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The API has changed, resolve is now called fulfill, and chaining promises is now working as expected:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;promise.then(function (result) {
    var newResult = doSomethingWithResult(result);
    return newResult;
}).then(function (newResult) {
    ...
});
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;CouchDBStore has been completely removed&lt;/h2&gt;

&lt;p&gt;Although CouchDBStore was removed from Emily since 1.2.0, the server part was still embedded in Emily&amp;#8217;s handler. This is now fixed an part of &lt;a href="https://github.com/flams/CouchDB-emily-tools"&gt;CouchDB-Emily-Tools&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To use CouchDB-Emily-Tools, you simply need to add its handler to Emily&amp;#8217;s server:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var emily = require("emily"),
    tools = require("couchdb-emily-tools");

emily.handlers.set("CouchDB", tools.handler);

tools.requirejs(["CouchDBStore", "Transport"], function (CouchDBStore, Transport) {

    var cdb = new CouchDBStore,
        transport = new Transport(emily.handlers);

    cdb.setTransport(transport);

    cdb.sync("mydatabase", "mydocument")
    .then(function () {
        console.log(cdb.toJSON());
    }, function (error) {
        console.log(error);
    });
});
&lt;/code&gt;&lt;/pre&gt;</description><link>http://podefr.tumblr.com/post/40469480540</link><guid>http://podefr.tumblr.com/post/40469480540</guid><pubDate>Mon, 14 Jan 2013 00:28:37 +0100</pubDate><category>emily</category><category>promise/A</category><category>couchdb</category><category>promise/A+</category></item><item><title>Migrating from Olives 1.2.0 to 1.3.0</title><description>&lt;p&gt;Olives 1.3.0 introduces two breaking changes that you must be aware of before upgrading:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Modules are now anonymous&lt;/li&gt;
&lt;li&gt;Some of them have been renamed&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;These changes lead us to a new way of using Olives in your project:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;EOWYN: Embed Only What You Need. &lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Anonymous modules&lt;/h2&gt;

&lt;p&gt;Until 1.2.0, Olives modules were named and prefixed with Olives/:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;define("Olives/ModuleName", function ModuleName() {
    ...
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Modules had to be named so they could be loaded into the test runner (jsTestDriver) before the specs and the specs are able to require them (with requirejs). Then they had to be prefixed with Olives/ to create a namespace and avoid collision with other libraries.
The counterpart is that it&amp;#8217;s ugly and repeats the file name, à la Java.&lt;/p&gt;

&lt;p&gt;As I didn&amp;#8217;t like it much I preferred adding a pre-compilation step before running the tests. I was then able to remove the names in the modules definitions, keeping my project DRY.&lt;/p&gt;

&lt;p&gt;Olives modules are now anonymous by the commonJS definition.&lt;/p&gt;

&lt;h2&gt;Renamed modules&lt;/h2&gt;

&lt;p&gt;For the names to be more explicit and for Olives plugins being easier to spot, the following modules have been renamed.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Model-plugin.js is now called Bind.plugin.js&lt;/li&gt;
&lt;li&gt;Event-plugin.js is now called Event.plugin.js&lt;/li&gt;
&lt;li&gt;UI-plugin.js is now called Place.plugin.js&lt;/li&gt;
&lt;li&gt;Transport.js is now called SocketIOTransport.js&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;EOWYN: Embed Only What You Need&lt;/h2&gt;

&lt;p&gt;Theses changes allow you to better integrate Olives within your project. Given that you already use require.js and its optimizer (or any equivalent), you can simply download Olives&amp;#8217;s parts that you actually need and paste them into one of your application&amp;#8217;s directory.
Make your require.js configuration point to them and you&amp;#8217;ll be able to develop and debug your app with the unminified version of Olives. 
Finally, when minifying and packing your application, Olives will be seamlessly embedded without any the extra weight.&lt;/p&gt;

&lt;p&gt;Of course, you can still download and use the built Olives for rapid prototyping, just like it used to work with the previous versions of Olives, but with the new names.&lt;/p&gt;

&lt;p&gt;Checkout Olives&amp;#8217; github for more information: &lt;a href="https://github.com/flams/olives"&gt;https://github.com/flams/olives&lt;/a&gt;&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/39606341462</link><guid>http://podefr.tumblr.com/post/39606341462</guid><pubDate>Fri, 04 Jan 2013 01:01:00 +0100</pubDate><category>Olives</category><category>migration</category><category>1.3.0</category><category>EOWYN</category></item><item><title>Securing CouchDB in 3 steps</title><description>&lt;p&gt;Freshly installed, CouchDB offers little to no security. There&amp;#8217;s even a name for that temporary state: its called the &amp;#8220;Admin Party&amp;#8221;, as every user is considered to be an admin.&lt;/p&gt;

&lt;p&gt;While it might seem dangerous, it&amp;#8217;s actually a nice thing as it lets you fine tune the level of security you want to obtain.&lt;/p&gt;

&lt;p&gt;Say you&amp;#8217;re in learning mode and you just want to figure out what CouchDB is and how it works. You&amp;#8217;re creating databases and documents and fetching them through design documents. At this time there&amp;#8217;s no need to secure anything, and anyway, CouchDB is bound to your local address so you&amp;#8217;re the only one who can mess around with it.&lt;/p&gt;

&lt;p&gt;But start using it in production, with an application that manipulates sensible information, and you&amp;#8217;ll have to go deeper into securing it.&lt;/p&gt;

&lt;p&gt;And that&amp;#8217;s what i&amp;#8217;m going to describe, in 3 steps.&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;Identifying the user who issues the request&lt;/li&gt;
&lt;li&gt;Limiting a user&amp;#8217;s read/write access to a database&lt;/li&gt;
&lt;li&gt;Limiting a user&amp;#8217;s write access to his own documents&lt;/li&gt;
&lt;/ol&gt;&lt;h3&gt;1. Identifying the user who issues the request&lt;/h3&gt;

&lt;p&gt;CouchDB stores its users in the _users database. A user document looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
    "_id": "org.couchdb.user:couchdb",
    "_rev": "1-8995e8ff247dae75048ab2dc800136d7",
    "name": "couchuser",
    "password": null,
    "roles": [
    ],
    "type": "user"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The _id is the user&amp;#8217;s name prefixed with &amp;#8220;org.couchdb.user&amp;#8221;. &lt;code&gt;_rev&lt;/code&gt; is the document&amp;#8217;s revision. &lt;code&gt;name&lt;/code&gt; is the name of the user, the one that the user will remember, along with his password.
Roles is a feature that we&amp;#8217;ll develop when speaking about &lt;code&gt;_security&lt;/code&gt; documents. It allows to create some sort of groups for the users.
Finally, type can only be &lt;code&gt;user&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;While &lt;code&gt;roles&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt; should be defined by the application during the account creation phase, &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; are chosen by the user. They are his credentials.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wiki.apache.org/couchdb/Security_Features_Overview#Authentication_database"&gt;More information on the authentication database in the official wiki&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, how does one authenticate himself?&lt;/p&gt;

&lt;p&gt;Basic authentication&lt;/p&gt;

&lt;p&gt;This authentication mode is using the name:password@url style. For a couch user &lt;code&gt;couchuser&lt;/code&gt; whose password is &lt;code&gt;couchpass&lt;/code&gt;, the request url would be:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;http://couchuser:couchpass@localhost:5984/db/document
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Querying CouchDB with the user&amp;#8217;s credentials will create a &amp;#8220;user context&amp;#8221; object that will be passed around to control functions, such as the validation functions we are going to talk about.&lt;/p&gt;

&lt;p&gt;Cookie authentication&lt;/p&gt;

&lt;p&gt;The second way of authenticating a user is by issuing a POST request on _session. The request must embed the credentials:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -vX POST http://localhost:5984/_session -H 'application/x-www-form-urlencoded' \
-d 'name=couchuser&amp;amp;password=couchpass'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The response&amp;#8217;s header will have a Set-Cookie field that can now be re-used to authenticate the user for 10 minutes, depending on your configure files.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;HTTP/1.1 200 OK
&amp;lt; Set-Cookie: \
AuthSession=Y291Y2hkYjo1MDQ2NUI3MjrL7w8A3NhUpW6XkVvVVJ25epeGsw; \
Version=1; Path=/; HttpOnly
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You&amp;#8217;re going to need to be able to extract the AuthSession from the header before passing it to further requests. Here&amp;#8217;s an example of a request embedding AuthSession:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  curl [your request here] --cookie \
  AuthSession=Y291Y2hkYjo1MDQ2NUI3MjrL7w8A3NhUpW6XkVvVVJ25epeGsw
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://guide.couchdb.org/editions/1/en/security.html#security"&gt;More on authentication is available here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that the user is authenticated, we can control which databases he has access to.&lt;/p&gt;

&lt;h3&gt;2. Limiting a user&amp;#8217;s read/write access to a database&lt;/h3&gt;

&lt;p&gt;Database-wise, there are two types of users, admins and readers.&lt;/p&gt;

&lt;p&gt;Readers can create, read and write document except for design documents.
Database admins can also modify design documents and _security documents. They can do some other stuff but it&amp;#8217;s not the purpose of this article.&lt;/p&gt;

&lt;p&gt;The _security document will simply specify what type of database user a CouchDB user is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// This example comes from the CouchDB guide
{
    "admins" : {
        "names" : ["joe", "phil"],
        "roles" : ["boss"]
    },
    "readers" : {
        "names" : ["dave"],
        "roles" : ["producer", "consumer"]
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;Notice the &amp;#8220;roles&amp;#8221; fields. Instead of adding every user in the &lt;code&gt;names&lt;/code&gt; array of the &lt;code&gt;_security&lt;/code&gt; document, you could instead specify which roles are &lt;code&gt;admins&lt;/code&gt; or &lt;code&gt;readers&lt;/code&gt;, and assign the adequate role to the user.&lt;/p&gt;

&lt;p&gt;As soon as a &lt;code&gt;_security&lt;/code&gt; document is added to a database, any user not listed in is not granted any access. [need to double check on that]&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wiki.apache.org/couchdb/Security_Features_Overview#Authorization"&gt;Authorization documents in the official wiki are explained here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now prevent users from wandering around in our application. But if a user&amp;#8217;s granted access to a database, how can we secure write access to documents that he doesn&amp;#8217;t own?&lt;/p&gt;

&lt;h3&gt;3. Limiting a user&amp;#8217;s write access to his own documents&lt;/h3&gt;

&lt;p&gt;Design documents can have a validation function that is called everytime a document is altered. Here&amp;#8217;s an example of a function that checks if the user who tries to modify a document is its owner.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;"validate_doc_update": "function (newDoc, oldDoc, userCtx) {
     if (newDoc.author != userCtx.name) { 
         throw({ 
             forbidden: 'Only' + userCtx.name + ' may edit this document'
         });
     }
  }"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Throw defines the error that is returned to the application. Other helper functions are available too:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;required(field)&amp;#160;: check if a field is set in a submitted document&lt;/li&gt;
&lt;li&gt;unchanged(field)&amp;#160;: prevent changes in a field&lt;/li&gt;
&lt;li&gt;user_is(role)&amp;#160;: check if user has given role&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;UserCtx has other properties:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;roles&amp;#160;: the roles that are assigned to the user&lt;/li&gt;
&lt;li&gt;db&amp;#160;: the name of the database&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;And a last argument is passed to the validation function, the database&amp;#8217;s security document.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wiki.apache.org/couchdb/Document_Update_Validation"&gt;More on validation functions.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To go further, we could imagine adding a proxy, between CouchDB and the application, that would filter out dangerous requests. &lt;a href="http://wiki.apache.org/couchdb/How_to_enable_SSL"&gt;Querying the database through https should also be considered.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a future article, I will explain how to secure CouchDB when used by an OlivesJS/EmilyJS application.&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/30895595277</link><guid>http://podefr.tumblr.com/post/30895595277</guid><pubDate>Wed, 05 Sep 2012 00:56:00 +0200</pubDate><category>couchdb</category><category>security</category><category>nosql</category><category>database</category></item><item><title>Locally test your npm modules without publishing them to npmjs.org</title><description>&lt;p&gt;There could be several situations where you want to locally deploy an npm module of your own before publishing it to npmjs.org.&lt;/p&gt;

&lt;p&gt;Say you&amp;#8217;ve just created one and want to see how it deploys, or you&amp;#8217;re fixing bugs and you want to test the module in integration before publishing a new version, or you just want to keep your npm private.&lt;/p&gt;

&lt;p&gt;To create a local npm, change directory to where its package.json is.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /path/to/package.json
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then run the pack command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;npm pack
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will create, in the same directory, a tarball named after the name of the project + the version specified in the package.json.&lt;/p&gt;

&lt;p&gt;This is exactly what is published to npmjs.org! You can now see what&amp;#8217;s inside&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;tar -tf packagename-version.tgz
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or you can install it in your project to test it in integration.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd path/to/your/project/
npm install ../path/to/your/npm/packagename-version.tgz
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see, &amp;#8216;npm install&amp;#8217; can either be used to fetch an npm on the official repository, or to install a local one.&lt;/p&gt;

&lt;p&gt;Note that each time you&amp;#8217;ll run npm install, the previous files will be overridden by the new ones, regardless of the version number, which is pretty convenient!&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/30488475488</link><guid>http://podefr.tumblr.com/post/30488475488</guid><pubDate>Thu, 30 Aug 2012 02:47:00 +0200</pubDate><category>npm</category><category>node.js</category><category>pack</category><category>test</category></item><item><title>Vincent Weyl: The toy designer: an Ideafy use case with Q&amp;A</title><description>&lt;a href="http://blog.taiaut.com/post/29954299808/the-toy-designer-an-ideafy-use-case-with-q-a"&gt;Vincent Weyl: The toy designer: an Ideafy use case with Q&amp;A&lt;/a&gt;: &lt;p&gt;&lt;a href="http://blog.taiaut.com/post/29954299808/the-toy-designer-an-ideafy-use-case-with-q-a" class="tumblr_blog"&gt;vweyl&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p class="p1"&gt;&lt;strong&gt;THE TOY COMPANY SCENARIO&lt;/strong&gt;&lt;/p&gt;
&lt;p class="p2"&gt;Jane Doe is working at a toy company that just bought a license for a major motion picture to use the characters in connection with the toys they produce.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Usually making such a “buy” decision means you already have a good idea what you’re going to do with this…&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;</description><link>http://podefr.tumblr.com/post/29958079367</link><guid>http://podefr.tumblr.com/post/29958079367</guid><pubDate>Wed, 22 Aug 2012 11:48:03 +0200</pubDate></item><item><title>HTML5 and bindable datalist</title><description>&lt;p&gt;&lt;a href="http://owietrich.tumblr.com/post/24901219460/html5-and-bindable-datalist" class="tumblr_blog"&gt;owietrich&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;HTML5 datalist* allows to autocomplete input elements with static content (option element).&lt;/p&gt;
&lt;pre class="prettyprint"&gt;&lt;span class="tag"&gt;&amp;lt;input&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;strong&gt;list&lt;/strong&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;"cars"&lt;/span&gt;&lt;span class="tag"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;&lt;/span&gt;&lt;strong&gt;datalist&lt;/strong&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;id&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;"cars"&lt;/span&gt;&lt;span class="tag"&gt;&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br/&gt;  &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;option&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;value&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;"BMW"&lt;/span&gt;&lt;span class="tag"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br/&gt;  &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;option&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;value&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;"Ford"&lt;/span&gt;&lt;span class="tag"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br/&gt;  &lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;option&lt;/span&gt;&lt;span class="pln"&gt; &lt;/span&gt;&lt;span class="atn"&gt;value&lt;/span&gt;&lt;span class="pun"&gt;=&lt;/span&gt;&lt;span class="atv"&gt;"Volvo"&lt;/span&gt;&lt;span class="tag"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="pln"&gt;&lt;br/&gt;&lt;/span&gt;&lt;span class="tag"&gt;&amp;lt;/&lt;/span&gt;&lt;strong&gt;datalist&lt;/strong&gt;&lt;span class="tag"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Thanks to Olives Framework, you can bind datalist options to a store and set them as you wish.&lt;/p&gt;
&lt;p&gt;If you are interested, I put an example into my &lt;a href="https://github.com/bredele/Autocomplete" title="github"&gt;github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;*Until now, only Firefox supports this feature.&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://podefr.tumblr.com/post/24949111740</link><guid>http://podefr.tumblr.com/post/24949111740</guid><pubDate>Tue, 12 Jun 2012 13:48:25 +0200</pubDate></item><item><title>Olivier Wietrich: A real-time blog by your own in 8 JavaScript lines of code</title><description>&lt;a href="http://owietrich.tumblr.com/post/24811416269/a-real-time-blog-by-your-own-in-8-javascript-lines-of"&gt;Olivier Wietrich: A real-time blog by your own in 8 JavaScript lines of code&lt;/a&gt;: &lt;p&gt;&lt;a href="http://owietrich.tumblr.com/post/24811416269/a-real-time-blog-by-your-own-in-8-javascript-lines-of" class="tumblr_blog"&gt;owietrich&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you’re familiar with Nodejs you’ve surely read some stuff about how to create a blog with this technology and others such as socket.io, mongoDB or couchDB. &lt;/p&gt;
&lt;p&gt;I have and even though it was quite simple, it was still too much for me. Why make easy things difficult? It’s a question to which I…&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://podefr.tumblr.com/post/24881391180</link><guid>http://podefr.tumblr.com/post/24881391180</guid><pubDate>Mon, 11 Jun 2012 15:02:21 +0200</pubDate></item><item><title>Olives 1.1.5 supports SVG views</title><description>&lt;p&gt;Since version 1.1.5 Olives is officially supporting SVG. SVG and HTML are very similar and can be manipulated almost the same way. It&amp;#8217;s all about creating xml tags, setting there attributes and styling them. The great news is that Olives was born to support SVG and only a few modifications were required to support them.&lt;/p&gt;

&lt;p&gt;In Olives, views are almost fully passive. They have no logic attached to them, let aside the data- attributes that describes the plugin calls. Considering that HTMLElement and SVGElement are almost similar, we should be able to treat SVG views just like we treat the HTML ones.&lt;/p&gt;

&lt;p&gt;As an example, I&amp;#8217;ve create an &lt;a href="http://podefr.github.com/Olives-SVG/index.html"&gt;SVG+Olives charting demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s see how the grid of the demo is built:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m4wr41CVUm1r9e6ux.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;We first create an SVG group that will group the horizontal lines:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;g class="grid"&amp;gt;
    &amp;lt;g data-gridy="foreach"&amp;gt;
        &amp;lt;line x1="0" y1 x2="600" y2 data-gridy="bind: y1; bind: y2" /&amp;gt;
    &amp;lt;/g&amp;gt;
&amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you&amp;#8217;re familiar with Olives, you&amp;#8217;ll recognize the data- attributes that specify which plugin to use to manipulate the SVG.
data-gridy will call the foreach method of the &amp;#8216;gridy&amp;#8217; plugin on the &lt;g&gt; Element, when bind will be called on the line method.&lt;/g&gt;&lt;/p&gt;

&lt;p&gt;The plugin is configured in the Grid UI and it binds the SVG with the gridY data store.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;grid.plugins.add("gridy", new ModelPlugin(gridY));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The combination of the SVG and Olives will generate as many lines as specified in gridY, with y1 and y2 being replaced by the store&amp;#8217;s values, as declared by data-gridy=&amp;#8221;bind: y1; bind: y2&amp;#8221;.&lt;/p&gt;

&lt;p&gt;Once the grid is generated, we can render the chart on top of it.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m4wr4fB3y81r9e6ux.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;The chart is a polyline:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;g class="chart"&amp;gt;
    &amp;lt;polyline points="" data-line="bind: drawLine, line" /&amp;gt;
&amp;lt;/g&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To add points to a polyline, we have to add them to the points=&amp;#8221;&amp;#8221; attribute. These points have a special formatting and can&amp;#8217;t be simply extracted from an array of points. So we need to create a drawLine function that will handle this formatting. drawLine will then be added to the Model-plugin.&lt;/p&gt;

&lt;p&gt;points is a simple array with many points: [ 43, 65, 87, 83, 79, 101, 102, 95 ]&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;chart.plugins.add("line", new ModelPlugin(model, {
    drawLine: function (points) {   
        var newPoints = [];

        // We populate the new array
        points.forEach(function (val, idx) {

            // 20px separate each point
            // the Y axis is "inverted" so subtract the value to 200
            newPoints.push([idx*20, 200-val]);

        });

        // It also has "terminating points"
        newPoints.unshift([0, 200]);
        newPoints.push([newPoints[newPoints.length-1][0], 200]);

        // Finally, we join all the points (x1,y1 x2,y2 x3,y3…)
        // And set the points attribute
        this.setAttribute("points", newPoints.join(" "));
    }
}));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Any kind of chart can be rendered using this technique, bar charts, pie charts, whatever. And we can even go further by connecting our models to a node.js server to have real-time charts!&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/24153620497</link><guid>http://podefr.tumblr.com/post/24153620497</guid><pubDate>Fri, 01 Jun 2012 00:24:53 +0200</pubDate><category>SVG</category><category>olives</category><category>JS</category><category>MVC</category><category>Framework</category></item><item><title>Understanding Olives' MV* model</title><description>&lt;p&gt;&lt;a href="https://github.com/flams/olives"&gt;Olives&lt;/a&gt; is a JavaScript MVC-like framework for building web applications. There are already loads of MVC frameworks out there (more than 30 featured in &lt;a href="http://addyosmani.github.com/todomvc/"&gt;todomvc.com&lt;/a&gt; including labs!) and almost each of them interprets the MVC model in a different manner. To better understand how to develop web applications using Olives, I need to explain its own interpretation first.&lt;/p&gt;

&lt;p&gt;Olives&amp;#8217; MV* was carefuly designed to address 3 major points:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Maintanable application&lt;/li&gt;
&lt;li&gt;Extendable application&lt;/li&gt;
&lt;li&gt;User-centred API&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Of course there are others, but these 3 certainly had the most impact on Olives&amp;#8217; design.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s create an extremely simple UI example taken from &lt;a href="https://github.com/flams/dev-env"&gt;Olives&amp;#8217; dev environment&lt;/a&gt; to see what it looks like&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m42v15gRXR1r9e6ux.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;When I click on &amp;#8220;en&amp;#8221; I&amp;#8217;d like &amp;#8220;Hello Olives!&amp;#8221; to be displayed, but when I click on &amp;#8220;fr&amp;#8221; I want &amp;#8220;Bonjour Olives&amp;#8221; instead.&lt;/p&gt;

&lt;h1&gt;View&lt;/h1&gt;

&lt;p&gt;In Olives, views are pure HTML, they&amp;#8217;re completely passive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;section&amp;gt;
  &amp;lt;span data-model="bind: innerHTML, greeting"&amp;gt;Default Greeting&amp;lt;/span&amp;gt;
   Olives!&amp;lt;br /&amp;gt;
  Choose your greeting : 
   &amp;lt;a href="#" data-event="listen: click, changeLanguage"&amp;gt;en&amp;lt;/a&amp;gt; 
   | &amp;lt;a href="#" data-event="listen: click, changeLanguage"&amp;gt;fr&amp;lt;/a&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://github.com/flams/dev-env/blob/master/index.html"&gt;located in index.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll notice the data- attributes though, they&amp;#8217;re the only link to the logic. I see multiple benefits to this approach:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Easy to add behavior to existing html&lt;/li&gt;
&lt;li&gt;Easy to update, change or evolve even by a non programmer&lt;/li&gt;
&lt;li&gt;Easy to style, no pre-processing needed&lt;/li&gt;
&lt;li&gt;Easy to find, the view is in an .html files.&lt;/li&gt;
&lt;li&gt;No new technology to learn, like a specific templating tool&lt;/li&gt;
&lt;/ul&gt;&lt;h1&gt;Model&lt;/h1&gt;

&lt;p&gt;The model is an observable data store provided by the framework. Olives&amp;#8217; simplest Store can store data in an Array or an Object, and notify on changes. Of course the Model has no knowledge of both View and Model. Example of an Olives model:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// Initializing the Store with an object that has a greeting key.
var model = new Store({ greeting: "Hello" });

// updating the model...
model.set("greeting", "Bonjour");

// ... will also notify observers
model.watch("updated", function ( key, value ) {
   console.log(key, value); // "greeting" "Bonjour"
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But it can also be sub-typed for persistence, like Olive&amp;#8217;s LocalStore which stores the data in localStorage, following Liskov principle.&lt;/p&gt;

&lt;p&gt;Olives&amp;#8217; &lt;em&gt;controller&lt;/em&gt; uses the simple Store by default, and it can be overridden by any subtype of Store. This is what happens in our simple demo, which is the reason why no model is explicitly defined.&lt;/p&gt;

&lt;h1&gt;OObject&lt;/h1&gt;

&lt;p&gt;And then comes the OObject. The OObject is a kind of Controller but with more responsibilities. It&amp;#8217;s actually a skeleton of the part of a user interface, it&amp;#8217;s the place that concentrates the whole logic. Let&amp;#8217;s see it in action.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// OObject creation
var ui = new OObject;

// The behaviors to add to the view can be implemented in plugins
ui.plugins.addAll({

  // This is a plugin that links the view to the model. 
  // Reachable through data-model
  "model": new ModelPlugin(ui.model),

  // This is a plugin that captures user inputs and 
  //transmits them to the OObject (ui)
  "event": new EventPlugin(ui)
});

// Specify the view of the UI
ui.alive(document.querySelector("section"));

// The function that is called when clicking on "en" or "fr"
ui.changeLanguage = function (event, node) {
  //  ....
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://github.com/flams/dev-env/blob/master/index.html"&gt;located in index.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The OObject binds the view to the model through the use of plugins. Olives has a built-in plugin called ModelPlugin, which implements double-way binding: when the model is updated, the view gets updated, and vice-versa.&lt;/p&gt;

&lt;p&gt;It also has a plugin called EventPlugin which binds the view to methods of the ui, like changeLanguage.&lt;/p&gt;

&lt;p&gt;And of course, you can imagine creating your own plugins to extend Olives capabilities. Why not adding mustaches on pictures using a face recognition plugin? Or translating coordinates to localized city names?&lt;/p&gt;

&lt;h1&gt;Application examples&lt;/h1&gt;

&lt;p&gt;The previous example is quite limited. There are two other applications using Olives that serve as example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/addyosmani/todomvc/tree/master/labs/architecture-examples/olives"&gt;TodoMVC&lt;/a&gt;
This is a more complete application that is divided between 3 UIs that share data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/podefr/suggestions"&gt;Suggestions&lt;/a&gt; (Under development as of today)
Similar to a todo list but with more features, such as routing, real-time model etc.&lt;/p&gt;

&lt;h1&gt;Comparing Olives&amp;#8217; MV* to MVC&lt;/h1&gt;

&lt;p&gt;When looking at the files tree, we see that an Olives application isn&amp;#8217;t split between several model/controller/view files as we usually have, but in small UIs instead. Each UI is specifically designed for a simple task, like adding a todo, displaying todos, or counting them. And this makes it way easier to design, develop and maintain an application.&lt;/p&gt;

&lt;p&gt;While this may not be obvious for a small application with few contributors over a small amount of time, it becomes dramatically more important with bigger projects.&lt;/p&gt;

&lt;p&gt;As a project grows in size, its number of files increases, diluting the knowledge of the architecture. As years pass by, developers forget where to put code and just happen to place it where it works. Sometimes duplicating code, data or coupling things that shouldn&amp;#8217;t be. The cost to avoid this, through processes, also increases as the project ages. I have seen this too often.&lt;/p&gt;

&lt;p&gt;On the other hand, Olives MV* has a 1:1 correspondence between the UI and its source code. You could almost see the files tree as you look at the UI. Divide the UI into multiple views, and each view has a single js file. Because of the way the OObject works, it&amp;#8217;s really hard to mix things up and associate some business logic to the wrong view, giving you even more hints on where to place your code. It&amp;#8217;s also possible to create generic UIs that can be duplicated throughout the application. The result is that you have a code that is easy to maintain and to extend!&lt;/p&gt;

&lt;h1&gt;Less plumbing&lt;/h1&gt;

&lt;p&gt;Last but not least, as the example shows, there&amp;#8217;s almost no plumbing. Scanning through the given code, one can seen that every line has a meaning to the developer and not to the framework.
There&amp;#8217;s no specific Olives way of structuring code, declaring classes, doing inheritance or such, it&amp;#8217;s just plain JavaScript, and Olives is an API.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s what I call a user-centered API, but I&amp;#8217;ll expand my thoughts in another post.&lt;/p&gt;

&lt;h1&gt;Links&lt;/h1&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="http://addyosmani.github.com/todomvc/"&gt;TodoMVC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/podefr"&gt;Suggestions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/flams/dev-env"&gt;Olives+Emily dev environment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://podefr.tumblr.com/post/23132038481</link><guid>http://podefr.tumblr.com/post/23132038481</guid><pubDate>Wed, 16 May 2012 09:31:00 +0200</pubDate><category>MVC</category><category>MV*</category><category>OlivesJS</category></item><item><title>A BMW for wheelchair users</title><description>&lt;p&gt;I worked on this project in 2007, when I was studying automotive design. I found these pictures buried deep into my hard drive and wanted to give them a second life.&lt;/p&gt;

&lt;p&gt;The goal was to invent a car that would specifically be designed for wheelchair users without it being perceived as such by other drivers. It had to allow their users to easily get in and out, in a safe and elegant manner.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m3obysrFeo1r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3obz5bh911r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3obzrO7Hw1r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3oc08ghYf1r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3oc0vACUR1r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3oc1g4Tzq1r9e6ux.jpg" alt=""/&gt;&lt;img src="http://media.tumblr.com/tumblr_m3oc1oEnAn1r9e6ux.jpg" alt=""/&gt;&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/22618810929</link><guid>http://podefr.tumblr.com/post/22618810929</guid><pubDate>Tue, 08 May 2012 02:03:31 +0200</pubDate><category>BMW</category><category>wheelchair</category><category>automotive</category><category>design</category></item><item><title>An innovative way to replace AJAX and JSONP using node.js and socket.io</title><description>&lt;p&gt;I was so happy the first time I used socket.io, seeing how fast, reliable and easy to use it is, that when I started doing XHRs I felt that something was wrong.
Current State of the Art implies using AJAX calls coupled with JSONP for getting data from a 3rd party server. To new applications we&amp;#8217;re also adding WebSockets that allow to push data from the server to the client. Three different techniques for carrying data, can&amp;#8217;t we unify them?&lt;/p&gt;

&lt;p&gt;Actually, it turns out that we can. Let&amp;#8217;s imagine something like this: data is fetched by the node.js server. By data I mean any data, whether it comes from a database, a web service, the file system, actually anything that node.js can have access to. 
Each data source is accessed by what would be called a request handler.
And when the data is available on the node.js server, it can be accessed from within the application and be streamed to the client using socket.io.&lt;/p&gt;

&lt;p&gt;It would resemble something like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m3mkxjnSwE1r9e6ux.png" alt=""/&gt;&lt;/p&gt;

&lt;h3&gt;How would it work from the client side?&lt;/h3&gt;

&lt;p&gt;A component, let&amp;#8217;s call it Transport, would be responsible to query the requests handlers. For instance, verifying a browserID assertion would look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Transport.request("BrowserID", assertion, callback);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Fetching data from CouchDB would look like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Transport.request("CouchDB", { path: "/db/_all_docs" }, callback);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And opening a keep-alive socket that would trigger the callback for every new chunk:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Transport.listen("CouchDB", { path: "/db/_changes" }, callback);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And the exact same syntax would work on the server side with a Transport directly connected to the requests handlers.&lt;/p&gt;

&lt;h3&gt;How to trick socket.io to transport the requests params and push the result back to the client?&lt;/h3&gt;

&lt;p&gt;Think of it like JsonP. You load a script on a different website which pads the result with a function name that you&amp;#8217;ve previously defined.
When you get this result, the callback is executed.&lt;/p&gt;

&lt;p&gt;So what I do is, I send the requests params to the server and I ask it to reply on a previously defined channel (a unique one).
The server executes the request through the handler, and streams the result back to the client. If transport.request is called, the channel is closed right away,
otherwise a function responsible for closing it is returned.&lt;/p&gt;

&lt;h3&gt;The solution has 5 major benefits&lt;/h3&gt;

&lt;ul&gt;&lt;li&gt;One unique transport&lt;/li&gt;
&lt;li&gt;Multi-purpose transport that can stream binary data too&lt;/li&gt;
&lt;li&gt;Based on well known technologies&lt;/li&gt;
&lt;li&gt;Easy to use&lt;/li&gt;
&lt;li&gt;No cross-domain issues&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;Want to see it in action?&lt;/h3&gt;

&lt;p&gt;The solution was successfully implemented in &lt;a href="http://flams.github.com/olives/"&gt;Olives JS Framework&lt;/a&gt;, which Transport module can be found &lt;a href="https://github.com/flams/olives/blob/master/src/Transport.js"&gt;here&lt;/a&gt;, and requests handlers are explained &lt;a href="https://github.com/flams/emily/wiki/Transport"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s a &lt;a href="http://taiaut.net:8000/"&gt;simple application&lt;/a&gt; currently being developed that also uses this Transport module and another use case&lt;/p&gt;

&lt;h2&gt;Warning&lt;/h2&gt;

&lt;p&gt;A &lt;a href="https://groups.google.com/d/topic/socket_io/2_Yovcrc1e0/discussion"&gt;discussion is going on on socket.io&amp;#8217;s google groups&lt;/a&gt;. I&amp;#8217;m exposing a database to the browser&amp;#8217;s application to showcase this solution but this has security issues. I&amp;#8217;m looking for a way to secure this and will post about it, until then, just be aware of the implications.&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/22553968711</link><guid>http://podefr.tumblr.com/post/22553968711</guid><pubDate>Mon, 07 May 2012 02:07:00 +0200</pubDate><category>node.js</category><category>socket.io</category><category>OlivesJS</category><category>AJAX</category><category>JSONP</category></item><item><title>Using CouchDB in a real-time web application</title><description>&lt;p&gt;CouchDB offers three distinct APIs for querying documents. It also comes up with an API to track changes happening in a database.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve written 3 articles to explain how to use these APIs in real-time web applications, using the _changes API that is available through a keep-alive socket.
They describe the flow of requests needed to fetch the documents, keep them up-to-date with the database, and when available, update the database when changes happened on the client side:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="https://github.com/flams/emily/wiki/CouchDB-document-in-a-real-time-application"&gt;Document API in a real-time application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/flams/emily/wiki/CouchDB-bulk-document-in-a-real-time-application"&gt;Bulk Document API in a real-time application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/flams/emily/wiki/CouchDB-view-in-a-real-time-application"&gt;View API in real-time a application&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Also note that these articles reflect how &lt;a href="https://github.com/flams/emily/wiki/CouchDBStore"&gt;Emily CouchDBStore&lt;/a&gt; works, in combination with &lt;a href="https://github.com/flams/emily/wiki/Transport"&gt;Transport&lt;/a&gt;&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21602167408</link><guid>http://podefr.tumblr.com/post/21602167408</guid><pubDate>Sun, 22 Apr 2012 23:45:14 +0200</pubDate><category>CouchDB</category><category>real-time</category><category>web application</category><category>javascript</category><category>framework</category></item><item><title>Central Park, NYC</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m2wgxkPbxp1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Central Park, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21600831155</link><guid>http://podefr.tumblr.com/post/21600831155</guid><pubDate>Sun, 22 Apr 2012 23:27:19 +0200</pubDate><category>central park</category><category>NYC</category></item><item><title>High Line Park, NYC</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m2wgpcHyrT1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;High Line Park, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21600463140</link><guid>http://podefr.tumblr.com/post/21600463140</guid><pubDate>Sun, 22 Apr 2012 23:22:23 +0200</pubDate><category>High Line</category><category>NYC</category></item><item><title>Photo</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m2wgiyrgwX1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;</description><link>http://podefr.tumblr.com/post/21600172524</link><guid>http://podefr.tumblr.com/post/21600172524</guid><pubDate>Sun, 22 Apr 2012 23:18:33 +0200</pubDate><category>NYC</category><category>architecture</category></item><item><title>Manhattan, NYC</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m2wg9lmKOU1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Manhattan, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21599747914</link><guid>http://podefr.tumblr.com/post/21599747914</guid><pubDate>Sun, 22 Apr 2012 23:12:56 +0200</pubDate><category>Manhattan</category><category>NYC</category><category>Liberty Island</category></item><item><title>Harlem, NYC</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m2wg4pULLF1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Harlem, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21599526846</link><guid>http://podefr.tumblr.com/post/21599526846</guid><pubDate>Sun, 22 Apr 2012 23:10:01 +0200</pubDate><category>harlem</category><category>NYC</category></item><item><title>Manhattan, NYC</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m2wg0xtfeG1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Manhattan, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21599359276</link><guid>http://podefr.tumblr.com/post/21599359276</guid><pubDate>Sun, 22 Apr 2012 23:07:43 +0200</pubDate><category>Manhattan</category><category>architecture</category></item><item><title>Brooklyn Bridge, NYC</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m2wfybgARI1rsyymzo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Brooklyn Bridge, NYC&lt;/p&gt;</description><link>http://podefr.tumblr.com/post/21599240630</link><guid>http://podefr.tumblr.com/post/21599240630</guid><pubDate>Sun, 22 Apr 2012 23:06:10 +0200</pubDate><category>Brooklyn bridge</category><category>NYC</category><category>architecture</category></item></channel></rss>
