Porting from Kanso 0.0.7

Tips on upgrading your project to the latest version

Upgrade Kanso

If you downloaded the dev branch from github, you can just make reinstall.

Then, update your project files

This may not be an exhaustive list of changes you'll need to make.

in kanso.json

Add a version, description, and dependencies.

Replace "base_template": "base.html" with "duality": { "base_template": "base.html" }.

Replace "templates": "templates" with "dust": { "templates": "templates" }.

{   
    "name": "notes",
    "load": "lib/app",
    "modules": "lib",
    "attachments": "static",

    "duality": { "base_template": "base.html" },    
    "dust": { "templates": "templates" },

    "dependencies": {
        "modules": null,
        "settings": null,
        "attachments": null,
        "properties": null,
        "couchtypes": null,
        "dust": null,
        "duality": null,
        "duality-dust": null
    }
}

in your terminal

In your project folder run kanso install.

This downloads dependencies from your kanso.json file and puts them in the packages directory at the root of your project.

in your source files

Update your require calls.

0.0.7 Module                0.0.8 Module

kanso/events            ->  duality/events
kanso/templates         ->  duality/templates
kanso/db                ->  db
kanso/session           ->  session
kanso/forms             ->  couchtypes/forms
kanso/utils             ->  duality/utils
                        ->  couchtypes/utils
kanso/types             ->  couchtypes/types
kanso/fields            ->  couchtypes/fields
kanso/widgets           ->  couchtypes/widgets
kanso/permissions       ->  couchtypes/permissions
kanso/underscore        ->  underscore

in app.js

remove events: require("./events") from modules.exports. Add require("./events") after modules.exports.

It will look something like this:

module.exports = {
  types: require("./types"),
  shows: require("./shows"),
  lists: require("./lists"),
  views: require("./views"),
  updates: require("./updates"),
  filters: require("./filters"),
  rewrites: require("./rewrites"),
  validate_doc_update: require("./validate")
};

require("./events");

in events.js or anywhere you used events.on("sessionChange", ...)

Replace

events.on("sessionChange", function(userCtx, req) { ... })

With

session = require("session")
session.on('change', function(userCtx, req) { ... })

in base.html

At the bottom of the file, replace this:

<script src="{baseURL}/kanso.js"></script>

With this:

<script src="{baseURL}/modules.js"></script>
<script src="{baseURL}/duality.js"></script>

in lists and shows: anywhere you used a db function

All db functions are now called on an object.

In a list or show (not at the top of the file), first you get the database

appdb = db.use(require('duality/core').getDBURL());

The saveDoc method takes the same arguments

appdb.saveDoc(new_doc, function(err) { ... });

Call getView with a new first argument, the name of your design document

appdb.getView("design_doc", "view_name", query_object, function(err, data){ ... });

You can get the design doc name through the settings module

settings = require('settings/root');

appdb.getView(settings.name, "view_name", {}, callback);

Questions?

If you're stuck, you can get help on the kanso google group, irc: #kansojs on irc.freenode.net, or report a bug on github.