Home

Awesome

Summary

This project provides a Dojo based web server running on NodeJS. It uses dojox/dtl as template engine and provide a page rendering framework.

Although Dojo is known as a powerful rich internet application framework running on browser side, it is also able to run on NodeJS as a server side framework. By doing this, server side javascript could take use of AMD, Dojo's object oriented framework and many fancy Dojo modules. And developers can use one framework for both client side and server side, which is very helpful for development and maintenance of a web site.

Live Demo

You can visit http://supnate.aws.af.cm/ to see the default dojos running on appfog.com

Installation

Dojos depends on NodeJS v0.6+ and Dojo Toolkit v1.7+

NOTE that you need Dojo source code version to run on NodeJS but not compressed version. Because built dojo seems only for browser environment.

Dojos folder needs to be the sibling of dojo and dojox folder, resulting in a directory structure like the following:

Configuration

You can specify multi web sites running on the server, each web site is a folder on disk and runs as an AMD package.

To config web sites, open dojos/config.js. You can see a internal applicaiton named 'Dojos Default', which list all files in dojos parent folder:

module.exports = {
	sites: [{
		id: 'dojos/default'
		,location: '../'
		,name: 'Dojos Default'
		,port: 1337
	}]
};

This site alsointends to manage web sites using a web UI, it's still in early stage so just for demo purpose, can't provide actual functions. Simlar with the Dojos Default web site config, you need to specify below parameters for a web site:

Start the server

Start up the server by running bootstrap.js:

node /path/to/dojos/bootstrap.js

What does Dojos Provide?

Create a page

Each file with extension '.djs' is rendered as a server page. Dojos looks for .djs.js for the page which is an AMD module as its backend context data provider automatically, and then render the .djs file as a dtl template with data to browser side.

index.djs

<html>
    <head>
        <title>Welcome to Dojos</title>
    </head>
    <body><h1>Hello {{name}}!</h1></body>
</html>

index.djs.js

define(['dojo/_base/declare', 'dojos/PageContext'], function(declare, PageContext){
    return declare(null, {
        getContext: function(){return {name: 'Dojos'};}
    });
});

NOTE: you need to restart the server after editing a Dojo module to apply the change because of AMD cache mechanism.