node package manager


       ((  ) )                         _____ _                     
      ( )(  ) )                       / ____| |                    
  _ (.( ) .)(.( )) _                 | |    | |__   ___   ___ ___  
(  ( ).( ) (.)( ).)  )               | |    | '_ \ / _ \ / __/ _ \ 
|`-..___________ ..-'|               | |____| | | | (_) | (_| (_) |
\                   /                 \_____|_| |_|\___/ \___\___/ 
 |                  ;---.
 |                  (__  \           | |         | |       (_)     
 |                  |  )  )          | |     __ _| |_ ___   _ ___  
 |                  | /  /           | |    / _` | __/ _ \ | / __| 
 |                   (  /            | |___| (_| | ||  __/_| \__ \ 
 /                  \ _/             |______\__,_|\__\___(_) |___/ 
|                    |                                    _/ |     
 `-..____________..-'                                    |__/      

Chocolate - Full stack Node.js framework

Chocolate is an experimental and isomorphic Node.js webapp framework built using Coffeescript.

It includes :

  • Chocolate Studio -- an online IDE (with Coffeescript, Javascript, Css, Json, and Markdown support)

  • Locco -- the Chocolate protocol : so, what, where, how...

  • LateDB -- a kind of database running in-memory and logged to disk

  • Chocokup -- a 100% pure CoffeeScript templating language that helps build web user interfaces (based on Coffeekup)

  • Chocodown -- Chocokup-aware port of Markdown (based on Showdown)

  • Chocolate Lab -- an online and immediate Lab playground where you write, transpile and/or test code between Javascript and Coffeescript and also between Html and Chocokup...

  • Specolate -- a behavior/test driven development tool (based on Jasmine) that works client and server side

  • Doccolate -- an online documentation editing tool (based on Docco)

  • Chocodash -- toolbox with javascript object identity, types, serialization and asynchronous calls and signals management

  • liteJq -- a lite jQuery-compatible library

  • an automatic free SSL certificate service with Let's Encrypt

  • a simple reverse proxy service

  • a basic source control with Git

  • Chocoss -- a Css framework

  • NewNotes -- a promising note taking tool

Chocolate integrates:

Node.js - Coffeescript - Ace - Letsencrypt - Http-proxy - Jasmine - Reactor

Coffeekup - Showdown - Highlight.js - Docco - Ccss - Git - Impress



Chocolate v0.0.24 - (2017-05-17)


  • chocolatejs can now handle proxying websockets


  • updated with LateDB section
  • updated microtime to 2.1.3
  • updated ws to 2.3.1


  • in general/interface, the review method was missing the actor property in its this context
  • in server/workflow, an empty json string result was not handled correctly

Chocolate v0.0.23 - (2017-05-07)


  • added general/lateDB: a very simple database system.

    lateDB provides you an in-memory javascript space that you can modify with an update method

         db.update('key': { op: func, data: some_data });

    i.e. (in Coffeescript):

         db.update 'result':
             op: (data) -> (@log ?= []).push data
             data: "done"

    or in Javascript:

           'result': {
             op: function(data) {
               return (this.log != null ? this.log : this.log = []).push(data);
             data: "done"

    will store in the database


    result is the key parameter which defines a section/table/bucket name, in which you want to store some data It contains an op field which provides a function to execute on this location, and a data field which should contain the data to provide to the op function.

    What the update service do is that it records the op method and the data provided in a log.db file which will be reloaded and executed next time your app will be restarted.

    Your op and data should rather not produce object oriented data (using the prototyping chain), unless those objets provides a stringify method which should write a javascript code in the log.db file that will re-create the oject.

    And voilà, that's bascially all...

  • in server/interface:

    • the __ context parameter sent to invoked module services now contains:
      • a websocket that can be used to send some message to the client when a websocket connection has been established (i.e. when locco Workspace is running client-side)
      • a console object with a log method that will route the log message to the default console and to the client through the websocket that may be present in the context object


  • in locco/chocodash:

  • _.cell and _.observe are added as functional equivalent to object oriented _.Signal and _.Observer

  • removed helpers option from _.Signal service

  • _.stringify

    • has now 3 optional modes:
      • json : returns a JSON stringification
      • js : (which is default mode) returns a javascript string to recreate the given object
      • full : same as js mode, but treats Array objects as full object and stringifies values by keys instead of by indexes
    • has a write option to define a function that will receive every chunk of string generated during the stringify operation,
      It can be used to store those string to a file or the send them to a stream. By default it should return the given string.
    • has a strict option to tell wether _.stringify accepts a user typed object. If not it throws an error.
  • in server/studio:

  • list of opened files is now saved in localStorage. Those files are reload automaticaly next tile studio is opened

  • in opened files panel, you can now click on directory entries to go directly there

  • the login toggle button will now display a yellow color when the app is restarting

  • the darktheme is now more grey and not brown anymore.

  • a * symbol is now also added to the file name displayed in the editor's file selector when the file was modified

  • in server/monitor:

  • the restart service now throttle the requests to 1 per second to avoid unnecessary restarts when few files are generated/rebuilt on a save


  • in server/studio

  • errors were not properly displayed in lab execution panel

  • Specolate service was crashing when an error was occuring in server side tested code due to a relative pathname of the tested file

  • in general/chocokup

  • a box, panel, header or footer followed by a string was not displaying that string in the produced html

  • in server/workflow, better management of region to define a system command

  • in server/file, reorganized code, normalize, resolve and region management (system and app)

  • in general/newnotes, put needed resource files for present service, inside /static/vendor/slides

See history in file





There is a non-writable demo at :


This procedure was tested as root on Debian 8.0


Chocolate needs Node.js (from v0.10.22 to latest).

Install Node.js (v6.x)

apt-get update
apt-get upgrade
apt-get install curl
curl -sL | bash -
apt-get install -y nodejs

Make node modules accessible everywhere

You can use start, stop and monitor Chocolate's app with PM2 service:

Install PM2

npm install -g pm2


Chocolate also needs:

Other prerequisites

apt-get install g++
apt-get install git
npm install -g coffee-script


Install Chocolate:

npm install -g --unsafe-perm chocolate


Run chocomake to create myapp

cd /home
chocomake myapp

Answer asked questions to create a self-signed SSL certificate.


Install Chocolate in PM2

su - myapp

Start 'myapp'

pm2 start coffee --name="myapp" -- /usr/lib/node_modules/chocolate/server/ /home/myapp
pm2 save
pm2 startup
-- then execute the command that was displayed

To stop, start or restart 'myapp'

pm2 stop myapp
pm2 start myapp
pm2 restart myapp


Use it

Chocolate runs on your server and responds to https requests on port 8026

You can change port number in the pm2 start command where you append the port parameter:

pm2 start coffee --name="myapp" -- /usr/lib/node_modules/chocolate/server/ /home/myapp 8081

You can also use a simple Http server by specifying options in the /home/myapp/data/app.config.json file:

http_only: true
port: 80

Log on

You defined a master key when using chocomake to create myapp.

You enter that key at:


Log off

To logoff go to :


Enter Chocolate Studio

To enter Chocolate Studio, go to:


There you can create, modify, move and commit source files

Web access to source files and functions

You access a file directly in the browser:

To display as raw text


To display as documentation text (docco)


To edit


To run specs (if you create it)


Locco main operations

Requests to Chocolate server follow theses rules (the Locco protocol main operations):


By default, Chocolate uses Https:

Http requests are redirected to https
Https server is located (by default) at port 8026
Http server is located at port Https+1 (8027)

You can specify options in data/app.config.json file:

http_only: true or false
port: <main port number>
key: <key filename>
cert: <cert filename>

Let's Encrypt SSL certificate

You can use Let's Encrypt free SSL certificate service directly in your Chocolate app:

First configure Let's Encrypt's service in data/app.config.json:

"letsencrypt": {
    "domains": [ "" ],
    "email": "",
    "agreeTos": true,
    "production": true,

You can put false in production parameter to test certificate generation. The generated certificates should appear in data/letsencrypt/live/yourdomain folder

Your certificate will then be renewed and the app restarted, automatically after approximately 90 days

But there is more: you can put many domains in the same certificate

"domains": [ "", "", "" ]

Finally, know that you have to explicitly add an entry with yourdomain prefixed with www if you want to support it:

"domains": [ "", "" ]

Reverse Proxy service

There is a simple Reverse Proxy service that you can configure in data/app.config.json:

"proxy": ['', '', '']

Then Chocolate will forward request for those domains to local processes/apps awaiting requests on your proxy app port + 10

So if your proxy app is on 8026 port then will be on 8036, will be on 8046...

And if you also use Chocolate's letsencrypt feature, you'll only have to set:

        "proxy": true

and Chocolate will use the domains defined in

        "letsencrypt": {
            "domains": [ "" ],

Javascript Bundle service

You can define Javascript bundles to be build when source files are saved.
If you have some client side Coffeescript/Javascript files (in Client or General folders) with the same prefix (or in the same subfolder), they can be bundled in the same file.

In the app.config.json file, add a build:{bundles:[]} section, with the following parameters:

    filename: the name for the output bundle file
    prefix: the prefix used in (or the path to) every file to put in the bundle
    known_files: an array of files' path, that have to be put in that precise order in the bundle
    with_modules: true or false, to put in the bundle the necessary code to make those files required by the Chocolate's require service
    "build": {
        "bundles": [
                "filename": "locco.js",
                "prefix": "locco",
                "known_files": {
                    "locco/intention.js": true,
                    "locco/data.js": true,
                    "locco/action.js": true,
                    "locco/document.js": true,
                    "locco/workflow.js": true,
                    "locco/interface.js": true,
                    "locco/actor.js": true,
                    "locco/reserve.js": true,
                    "locco/prototype.js": true
                "with_modules": true

Chocolate system services and files

They are accessible (if you registered the master key) at:


Your app services and files

They are at:


Default service in source file

If your source file exports an interface function (ie. in

exports.interface = () -> 
    'Hello world!'    

Then it is called when you request that file with no parameter:


returns a web page with

Hello world!

You can use the Interface.Web service with Chocokup to produce your Html page :

Interface = require 'chocolate/general/locco/interface'
exports.interface = 
    new Interface.Web ->
        div "Hello world #{world}!" for world in [1..5]


Chocolate Studio

A sweet web app development environment.

It displays your source files and browse through directories, has a search in files service.
It has a panel that displays log messages.
It can also list and open source file commited versions.

You can create, move, rename and delete files.

The central panel has the code editor. It has syntax highlighting for Coffeescript, Javascript, CSS and Markdown.

### Autocomplete and Snippets

It has a basic automplete feature that, by pressing CTRL+SPACE keys, proposes you a list of words collected from your file.

It also has snippets that will expand code from a shortcut:
in an HTML file, html5+CTRL+SPACE will become:

    <!DOCTYPE html>
            <meta http-equiv="content-type" content="text/html; charset=utf-8" />
            <title>`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`</title>

Then you can move to meta and body section by pressing the TAB key.

Currently there are Coffeescript, Javascript, CSS and HTML snippets in the editor.

### Spec, Doc, Lab, Help and Notes panels

The central panel can also split to display the associated spec file (see Specolate)
or the source file in help mode (see Doccolate) or the Lab that can be used to test Coffeescript or Chocodown code.

The help panel lists some usefull resources. Links will be opened in the central panel.

The Notes panel allows you to write and save some notes.





Editor shrotcuts


The Lab

The Lab helps you write your code and test cases, syntax and also translate between Javascript and Coffeescript and also between Html and Chocokup...

Coffeescript Lab

When you type Coffescript code in the Lab editor, it is immediately translated in Javascript.
You can use this service to learn Coffeescript but also to verify that your code will do what you expect it should.

Beside beeing translated in Javascript it is also immediately executed.
And you can see the result in the terminal panel.

But more... when you display the Debug panel you can see your variables values through code execution!
This service is inspired by Bret Victor's lecture (Inventing on priciples).

Copy the following code in the Coffeescript Lab with the Debug panel:

    binarySearch = (key, array) ->
        low = 0
        high = array.length-1
        while (low <= high)
            mid = Math.floor((low + high) / 2)
            value = array[mid]
            if value > key
                high = mid - 1
            else if value < key
                low = mid + 1
                return mid
        return -1
    result = binarySearch 'f', ['a', 'b', 'c', 'd', 'e','f']

Then change the 'f' to something else and see the Debug panel change in live!

This service is experimental but it has been really useful to me.

Javascript Lab

But you can also select the Javascript mode where your Javascript code will be immediately executed and also translated to Coffeescript!

Chocodown Lab

Literate programming...

Chocodown panel lets you write Markdown, Chocokup and Coffeescript code that will be immediately translated to html and javascript!

But more... when you display the Dom panel you can see immmediately the result!

Basically, this panel is a Markdown editor, but you can insert code blocks by using the # and the ! signs followed by the language you want to use: html, css, javascript, coffeescript, chocokup.

When you use the # sign, Chocodown displays and highlights the following code.
When you use the ! sign, it executes the code.
And you can use both #!

Copy the following code in the Chocokup Lab with the Dom panel:

### Here is a basic Chocodown sample:

**Css code**

    #! css
    #chocodown-demo .header,
    #chocodown-demo .footer {
        border: 1px solid grey;
        background: maroon;
        color: white;
        text-align: center;

**Chocokup code**

    #! chocokup
    panel "#chocodown-demo", ->
        header -> 'header'
        footer -> 'footer'
        body ->
            for i in [0..3] 
                button "#{i}"

**Coffeescript code**

    #! coffeescript
    buttons = document.querySelectorAll '#chocodown-demo button'
    for button in buttons
        addEvent = button.addEventListener ? button.attachEvent button, "click", -> 
            alert "I'm button #" + @innerhtml

And see...

Then change [0..3] to [0..6] and see the result...

Html Lab

But you can also select the Html mode where your Html code will be immediately rendered and also translated to Coffeekup/Chocokup!


How to write Modules

You can create a module by pressing the Create button. It will create a module with the name you provide in the currently displayed folder. If you dont put a suffix the the filename, it will create a Coffescript file with .coffee suffix.

Supported file types are: .coffee, .js, .html, .css, .md

If you have asset files you want to be downloadable from the web (like images or js libraries), put them in the /static folder.

It is supposed that you will put modules that run only in the node.js environment in the /server folder. Modules that run only in the browser will go int the /client folder, and modules that can run in both environment will be put in /general folder.

If you put .coffee or .js files in the /client or /general folder, they will be compiled if .coffee and copied to the /static/lib folder and will be downloadable by your javascript client code (using the provided require function).

If you create a general module (that can work on server and in browser), you will need to write something like the following code:

class MyGeneralModule
    constructor: ->
_module = window ? module
_module.exports = MyGeneralModule

The exported function interface, if present in your module, is used to return an Interface.Web object or an html content if someone calls that module with no parameter:

i.e., in module

exports.interface = ->


Interface = require 'chocolate/general/locco/interface'
exports.interface = 
    new Interface.Web -> div 'Hello'

Will display Hello when called with https://myserver/mymodule

You can also directly export an Interface.Web object

Interface = require 'chocolate/general/locco/interface'
module.exports = 
    new Interface.Web -> div 'Hello'

You can write module that runs on server with functions that you can call directly from the browser like this:

exports.say_hello = (who = 'you', where = 'Paris') ->
    'hello ' + who + ' in ' + where

This function can be called like this:

https://myserver/mymodule?say_hello and display hello you in Paris
https://myserver/mymodule?say_hello&me and display hello me in Paris
https://myserver/mymodule?say_hello&me&London and display hello me in London
https://myserver/mymodule?say_hello&where=Madrid and display hello you in Madrid
https://myserver/mymodule?say_hello&who=me&where=Madrid and display hello me in Madrid

Those function can declare a system parameter __ which contains:

  .appdir: application directory
  .datadir: application data directory
  .session: session object to store user's session data
  .request: HTTP request object
  .response: HTTP response object


exports.check_appdir = (__) ->
    "Application directory is:" + __.appdir

Instead of a javascript function you can call a Locco Interface:

Interface = require 'chocolate/general/locco/interface'
exports.say_hello = new Interface
        who: 'you'
        where: 'Paris'
    render: ({who, where}) ->
        'hello ' + who + ' in ' + where



lateDB provides you an in-memory javascript space that you can modify with an update method

        db.update('key': { op: func, data: some_data });

i.e. (in Coffeescript):

        db.update 'result':
            op: (data) -> (@log ?= []).push data
            data: "done"

or in Javascript:

          'result': {
            op: function(data) {
              return (this.log != null ? this.log : this.log = []).push(data);
            data: "done"

will store in the database


`result` is the key parameter which defines a `section`/`table`/`bucket` name, in which you want to store some data
It contains an `op` field which provides a function to execute on `this` location, and a `data` field which should contain the `data` to provide to the `op` function.

What the `update` service do is that it records the `op` method and the `data` provided in a `log.db` file which will be reloaded and executed next time your app will be restarted.

Your `op` and `data` should rather not produce object oriented data (using the prototyping chain), unless those objets provides a `stringify` method which should write a javascript code in the `log.db` file that will re-create the oject.

And voilà, that's bascially all...



Chocodash is a small library that includes javascript utilities:

_.Type, _.type

_.type returns the type of an object

    _type({}) === '[object Object]'

_.Type provides a Type enumeration

    _type({}) === _.Type.Object

    _.Type = 
        Object: '[object Object]'
        Array: '[object Array]'
        Boolean: '[object Boolean]'
        Number: '[object Number]'
        Date: '[object Date]'
        Function: '[object Function]'
        Math: '[object Math]'
        String: '[object String]'
        Undefined: '[object Undefined]'
        Null: '[object Null]'


_.prototype makes it easy to create a Javascript prototype

following the classical class way:


    Service = _.prototype 
        add: (a,b) -> a+b
        sub: (a,b) -> a-b


    Service = _.prototype({
      add: function(a, b) {
        return a + b;
      sub: function(a, b) {
        return a - b;

or the mixin way:


    Service = _.prototype()
    Service.use ->
        @add = (a,b) -> a+b
        @sub = (a,b) -> a-b


    Service = _.prototype();
    Service.use(function() {
      this.add = function(a, b) {
        return a + b;
      return this.sub = function(a, b) {
        return a - b;

Then use your prototype to create javascript objects:

    sevr = new Service();
    expect(serv instanceof Service).toBe(true);

You can define a prototype initializer by using the constructor keyword:


    Service = _.prototype 
        constructor: (@name) ->
    serv = new Service "MyDoc"
    expect( "MyDoc"


    Service = _.prototype({
      constructor: function(name) { = name;
    serv = new Service("MyDoc");

You can also create a prototype by adopting/copying
another prototype's beahaviour and adding new functions:


    MoreMath = ->
        @multiply = (a,b) -> a * b
        @divide = (a,b) -> a / b
    CopiedService = _.prototype adopt:Service, use:MoreMath
    cop = new CopiedService
    expect(cop.add 2,2).toBe 4
    expect(cop.multiply 3,3).toBe 9


    MoreMath = function() {
      this.multiply = function(a, b) {
        return a * b;
      return this.divide = function(a, b) {
        return a / b;
    CopiedService = _.prototype({
      adopt: Service,
      use: MoreMath
    cop = new CopiedService;
    expect(cop.add(2, 2)).toBe(4);
    expect(cop.multiply(3, 3)).toBe(9);

You can finally create a prototype by inheriting another prototype's beahaviour and adding new functions that can access parent's overriden function:


    InheritedService = _.prototype 
        use: -> @sub = (a,b) -> a + ' - ' + b + ' = ' + _.super @, a,b
    inh = new InheritedService
    expect(inh.add 2,2).toBe 4
    expect(inh.sub 2,2).toBe "2 - 2 = 0"


    InheritedService = _.prototype({
      inherit: Service,
      use: function() {
        return this.sub = function(a, b) {
          return a + ' - ' + b + ' = ' + _.super(this, a, b);
    inh = new InheritedService;
    expect(inh.add(2, 2)).toBe(4);
    expect(inh.sub(2, 2)).toBe("2 - 2 = 0");


_.defaults ensure default values are set on an object

Set default values if not set:

    o = _.defaults({first:1}, {second:2});

Set default values on sub-object if not set and preserve other values:

    o = _.defaults({second:{sub1:'sub1'}}, {first:2, second:sub2:'sub2'});

_.Signal, _.Observer, _.Publisher

Here are Chocolate's reactive services.

_.signal represents a value which can be observed

Signals are objects representing observed values. They are read by executing the value() function with no arguments.
They are set by executing the value() function with a signal definition as the only argument.

a = new _.Signal(1);
b = new _.Signal(function(){ a.value() });

_.Observer reports signal changes

Observers are defined in a manner similar to Signals

The primary differences of observers are:

  • they have no value to read
  • they cannot be observed themselves
  • they are notified only after signals have all been updated

They are called upon Signal change:

    a = new _.Signal(1);
    b = null;
    c = new _.Observer(function(){ b = a.value() });

Together, Signals and Observers form a directed acyclic graph. Signals form the root and intermediate nodes of the graph, while Observers form the leaf nodes in the graph.

When a signal is updated, it propagates its changes through the graph. Observers are updated last after all affected signals have been updated. From the perspective of observers, all signals are updated atomically and instantly .

_.Publisher reports basic signal changes to one-to-many reporters. They use one internal pair of Signal and Observer

    asyncFunc = function() {
      var publisher = new _.Publisher;
      var callback = function() {
        return publisher.notify('done');
      return publisher;
    asyncFunc().subscribe(function(answer) { // do something when notified });

_.serialize, _.parallelize

Really simple tools to help manage asynchronous calls serialization.

You can change this javascript code:

    db.createOrGetTable(function(table) {
      return table.insertRow(row, function() {
        return {
          return console.log(rows.count);

to this code:

    _.serialize(function(defer, local) {
      defer(function(next) {
        return db.createOrGetTable(function(table) {
          local.table = table;
          return next();
      defer(function(next) {
        return local.table.insertRow(row, function() {
          return next();
      defer(function(next) {
        return {
          local.rows = rows;
          return next();
      return defer(function() {
        return console.log(local.rows.count);

or in Coffeescript, this code:

    db.createOrGetTable (table) ->
        table.insertRow row,  ->
   query (rows) ->
                console.log rows.count

to this code:

    _.serialize (defer, local) ->
        defer (next) -> db.createOrGetTable (table) -> local.table = table; next()
        defer (next) -> local.table.insertRow row,  -> next()
        defer (next) -> query (rows) -> local.rows = rows; next()
        defer -> console.log local.rows.count

It helps you mix synchronous and asynchronous, iterative and recursive code, in a simple way with no new concept to learn.

Here is an example taken from /general/chocodash spec file:

    var _, end, start, time1, time2, time3, aync_func;

    aync_func = function(duration, cb) {
      return setTimeout((function() {
        return cb(new Date().getTime());
      }), duration);

    _ = require('chocolate/general/chocodash');
    start = new Date().getTime();
    time1 = time2 = time3 = end = null;
    _.serialize(function(defer) {
      defer(function(next) {
        return aync_func(250, function(time) {
          time1 = time;
          return next();
      defer(function(next) {
        return aync_func(150, function(time) {
          time2 = time;
          return next();
      defer(function(next) {
        return aync_func(350, function(time) {
          time3 = time;
          return next();
      defer(function() {
        // expect(time1 - start).toBeGreaterThan(250 - 5);
        // expect(time2 - start).toBeGreaterThan(400 - 5);
        // expect(time3 - start).toBeGreaterThan(750 - 5);
        // expect(end - start).toBeLessThan(10);
      end = new Date().getTime();

_.stringify, _.parse

_.stringify transforms a javascript object in a string that can be parsed back as an object

You can stringify every property of an object, even a function or a Date:

    o = {
        u: void 0,
        n: null,
        i: 1,
        f: 1.11,
        s: '2',
        b: true,
        add: function(a, b) { return a + b; },
        d: new Date("Sat Jan 01 2011 00:00:00 GMT+0100")

    s = _.stringify o
    expect(s).toBe "{u:void 0,n:null,i:1,f:1.11,s:'2',b:true,add:function (a, b) {\n          return a + b;\n        },d:new Date(1293836400000)}"

_.parse transforms a stringified javascript object back to a javascript object

    a = _.parse "{u:void 0,n:null,i:1,f:1.11,s:'2',b:true,add:function (a, b) {\n          return a + b;\n        },d:new Date(1293836400000)}"

    expect(a.u).toBe undefined
    expect(a.n).toBe null
    expect(a.i).toBe 1
    expect(a.f).toBe 1.11
    expect(a.s).toBe '2'
    expect(a.b).toBe yes
    expect(a.add(1,1)).toBe 2
    expect(a.d.valueOf()).toBe new Date("Sat Jan 01 2011 00:00:00 GMT+0100").valueOf()


_.Uuid helps to generate RFC4122(v4) UUIDs, and also non-RFC compact ids

    Uuid() // produces a string like "88a8814c-fd78-44cc-b4c1-dbff3cc63abd"
    expect(Uuid.parse("49A15746135C4DEDAB55B2C5F74BD5BB").toString()).toBe([73, 161, 87, 70, 19, 92, 77, 237, 171, 85, 178, 197, 247, 75, 213, 187].toString());



Debugate is really basic tool to help profile and log code execution.

Here is a sample taken from the /general/debugate spec file:

    var Debug = require('chocolate/general/debugate'), f1;
    f1 = function(cb) {
      return setTimeout((function() {
        return cb(new Date().getTime());
      }), 250);
    Debugate.profile.start('Test time spent');
    f1(function(time) {
      Debugate.profile.end('Test time spent');
      // expect(Debugate.profile.spent('Test time spent').time).toBeGreaterThan((250 - 5) * 1000);
      // expect(Debugate.profile.spent('Test time spent').time).toBeLessThan((250 + 5) * 1000);



Chocokup is derived from Coffeekup which is a templating engine for node.js and browsers that lets you to write your html templates in 100% pure CoffeeScript.

What Chocokup adds is the "Panel orientation" missing from html which is page oriented.

Chocokup introduces few new tags:

  • panel
  • box

and modifies some already existing tags:

  • body
  • header
  • footer

Using a pure Coffeescript syntax, you can write this:

panel proportion:"served", ->
    panel "aside left"
    panel "main"
    panel "aside right"

which translates into:

<div class="space">
  <div class="space service horizontal left">
    <div class="space">aside left</div>
  <div class="space service horizontal served center">
    <div class="space">main</div>
  <div class="space service horizontal right">
    <div class="space">aside right</div>

and displays as a main panel with a left and a right service panels.

You can also write Css code using Chocokup:

panel "#calc", ->
    button "##{id()}", i for i in [9..0]
    button '+' ; button '-'
    button '.by3', '='           
css ->
    width = 160
    nbColumn = 3
    box: ->
        border: '1px solid black'
        width: width + 'px'
        minHeight: '20px'
        textAlign: 'center'
        whiteSpaceCollapse: 'collapse'
        width: width / nbColumn - 4
        height: width / nbColumn - 4
        width: width 

This will display a basic Calculator




In a Coffeescript source file (ie. :,
insert an interface function that returns a new Chocokup.Document

Chocokup = require 'chocolate/general/chocokup'

exports.interface = ->
    new Chocokup.Document 'Chocolate - Wep Apps with a sweet taste', theme:'writer'->
        body ->
            "Welcome to !"

Then open a web browser and open that page: ie. https://myserver/mypage

Chocokup documents include the Eric Meyer's reset CSS.

You can select few themes:

  • reset: (default) Eric Meyer's reset CSS
  • paper: reset CSS + traditional CSS values
  • writer: paper CSS + classic Blog CSS values
  • coder: paper CSS + developer Blog CSS values


If you only want to build a partial document, you can use Chocokup.Panel

Chocokup = require 'chocolate/general/chocokup'

kup = ->
    text "Welcome to !"
exports.interface = ->
    new Chocokup.Panel(kup).render()


Read the complete Chocokup reference in Chocolate Studio Chocokup help panel.



Chocoss is a Css templating system currently being developed inside Chocokup

Five simple reset types and a static grid system are added to Chocokup fluid panel system.

The reset types are:

  • reset: the Eric Meyer's Css Reset. Reset things like default line heights, margins and font sizes of headings, and so on...
  • basic: apply reset and redefine basic styles.
  • paper: apply basic and add margins
  • writer: general blog type reset based on paper
  • coder: developer blog type reset based on paper



Locco is the Chocolate protocol. It helps manage data, workflows and interfaces.

Protocol operations

  • so indicates the action type.

    • do: execute an exported function in source file

      • parameters can be specified by name or by position
    • move:

      • if what is specified:
        move what file's content to where file
      • otherwise, if Http request is a POST request then:
        move POST message data to where file
    • eval: run the where file associated spec: ie. for

    • go: default action. Load where file and execute interface function.

  • what adds a precision on the action object (usualy its pathname).

  • where tells where the action should take place: a pathname

  • how asks for a special type of respond if available (web, raw, help).

    • web: default. responds as an html document
    • raw: responds as plain text
    • help: responds as an html Docco help file
    • edit: responds as an html source web editor
  • a backdoor_key key can be specified to have system access



       Moves /myworld/mydocument file to /myworld/myfolder
       so = move
       what = /myworld/mydocument
       where = /myworld/myfolder
       how = web (by default) - will return an answer as html.

       Go to /myworld/myfolder file, 
         load and renderit if it's an Interface or execute **interface** function if exists,
         otherwise open file in editor
       so = go (by default)
       what = undefined
       where = /myworld/myfolder
       how = web (by default) - will return an answer as html.

       Go to /myworld/myfolder file, 
         load it and execute **myFunc** function if exists, with myParamValue param
         otherwise returns empty page
       so = do (by default when request has parameters)
       what = myFunc
       where = /myworld/myfolder
       how = web (by default) - will return an answer as html.


Locco Interface is a javascript protoype that provides the following services:

Rules enforcement:

  • default values : ensures that default values are set
  • security control : ensures current user has access rights
  • values validation control : ensures values are valid before proceeding

Steps execution:

  • execute asynchronous preparation steps before 'render' function

Render execution:

  • execute interface's 'render' function ('action' is an available synonym for 'render')
  • returns synchronously or asynchronously an Interface.Reaction

When Chocolate workflow service receives a request, it loads the corresponding module. If the module has an property named interface which is an instance of Locco Interface, it submits the provided parameters and the system context (__) in a bin to the interface:

    Interface = require 'chocolate/general/locco/interface'
    exports.interface = new Interface
            who: 'you'
            where: 'Paris'
        render: ->
            'hello ' + @bin.who + ' in ' + @bin.where

Interface service makes explicit what you have to deal with when you create an interface.


An Interface.Web service makes it easy to build a web interface component.

You just declare an interface where the render is some Chocokup code that can access data stored in the provided bin. That interface can embed other Interface.Web modules:

    welcome_user = new Interface.Web
            welcome_message: -> 'Welcome'
            login_panel: new Interface.Web
                    login: -> 'Login'
                    signin: -> 'Sign in'
                render: ({login, signin}) ->
                    a href:'#', login
                    a href:'#', signin
        render: ({__, welcome_message})->
            if __.session.user?.has_signed_in
                span welcome_message
                login_panel @bin.login_panel.bin



Specolate is a client and server side behavior/test driven development tool.

It uses Jasmine, a great behavior-driven development framework for testing JavaScript code.


Something interesting is that it runs your specs in the server and in the browser contexts.

You only have add, at the begining of your spec file:

Server only module

unless window?
    describe ...

Browser only module

if window?
    describe ...

General module

Newnotes = require './newnotes'

describe 'Newnotes', ->
    it 'creates, then lists a basic todo', ->
        newnotes = new Newnotes
        newnotes.add 'do first'
        newnotes.add 'do after'
        expect([todo.title for todo in newnotes.list()].join(',')).toEqual 'do first,do after'



Docco is a literate-programming-style documentation generator. It produces html that displays your comments alongside your code.

Doccolate is a modified version of Docco that can be used on demand both on client and server side. It supports Coffeescript, Javascript, CSS and Markdown file formats.

You can use it by clicking on the Doc button while a source file is opened. Then you will immediately see if your source is well documented. Source modifications are reflected on the fly!

Source comments are passed through Markdown, and code is passed through Highlight syntax highlighting.

Documented version of your source files can be displayed directly in the browser by using the how=help Http parameter: https://myserver/mymodule?how=help



Litejq is a lite jQuery-compatible library introduced to be Chocolate client-side scripts foundation.

It knows:


$.ready, $.noConflict, $.type, $.isArray, $.isWindow, $.isPlainObject, $.each, $.map, $.extend, .get, .each, .splice, .map


$.ajax, $.get, $.post, $.getJson, $.param


.filter, .find, .parent, .parents, .siblings, .children, .first, .last, .closest


$.Event, $.now, .on, .off, .bind, .unbind, .delegate, .undelegate


.addClass, .removeClass, .toggleClass, .hasClass, .css


.text, .html, .append, .prepend, .replaceWith, .empty, .attr, .removeAttr, .data, .removeData, .val, .show, .hide, .height, .width, .offset, .remove



Newnotes is a note taking tool that helps memorize and get things done.

Things are structured-text with each level thought as shortest-long-title. Each thing input has a date and a time stamp.

You can use it to manage notes / todo lists / oulines.

New item/sub-item

You can create a new item with the same attributes than the previous (use Ctrl-Return). You can also create sub-items with the indent/outdent function (use Tab and Shift-Tab)

Tagging attributes

You can modify the item attributes using the selectors.

Dimensions :

  • Priority: Now, Tomorrow, Later, Done

  • Scope: Me, Household, Family, Friends, Community, Business, State, Public

  • Action: Explore, Memorize, Learn, Teach, Do, Control, Delegate, Relax

  • Intention: Know, Use, Make, Manage

  • Wish: No wish, Identity, Hobbies, Education, Religion, Leisure

  • Need: No need, Food, Health, Clothing, Equipment, Housing

  • Share: No share, Communication, Partnership, Work, Banking, Insurance


You can use it directly inside Chocolate Studio in the Notes panel, but also directly and fullscreen at: https://myserver/-/server/newnotes

Impress.js with Newnotes !

You can display a Newnotes branch with impress.js: https://myserver/-/server/newnotes?my-branch-title&as=impress


Read the complete Newnotes reference in Chocolate Studio Newnotes help panel.


Road Map

Chocolate is still currently (2016/05) an experimental framework that needs to be completed and polished, so I'm working on:

  • user interface generation using locco/interface and chocokup
  • data storage using server/document and/or server/reserve
  • putting this framework live on a real use case
  • ...



MIT License

Chocolate is a simple webapp framework built on Node.js using Coffeescript
Copyright (c) 2011-2016, Jean-Claude Levy

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.