Giter VIP home page Giter VIP logo

dojos's Introduction

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:

  • dojo - Provides the AMD loader
  • dojox - Provides template engine: dojox/dtl and many other none-ui modules
  • dojos

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:

  • id: the identifier of the web site, it is also used as AMD package name. If not provided, dojos will give it a random id at each server starting.
  • name: the name of the web site, it is displayed on Dojos Admin page. If not provided, it will be displayed as 'undefined' on admin page
  • location: the location of the web site, could be an absolute path on disk, such as 'c:/wwwroot/my_site/', or a path related to dojoroot, such as './admin', which is used for Dojos Admin.
  • port: the web site listening port.

Start the server

Start up the server by running bootstrap.js:

node /path/to/dojos/bootstrap.js

What does Dojos Provide?

  • Directory list, support fast sorting and filter
  • Static file server
  • Server page rendering engine using dojox/dtl as the template engine

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.

dojos's People

Contributors

supnate avatar davidleoni avatar

Watchers

James Cloos avatar Hardik Patel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.