1 | Connect middleware exposing the Dojo Toolkit
|
2 | ============================================
|
3 |
|
4 | This Connect middleware transparently download and display Dojo files.
|
5 |
|
6 | In its simplest form, it takes no argument and the latest stable release is
|
7 | used. Here is a quick example:
|
8 |
|
9 | ```javascript
|
10 | var express = require('express');
|
11 | var serve_static = require('serve-static');
|
12 | var dojo = require('connect-dojo');
|
13 | var app = express.createServer();
|
14 | app.configure(
|
15 | app.use(express.bodyParser());
|
16 | app.use(express.methodOverride());
|
17 | app.use(express.cookieParser());
|
18 | app.use(app.router);
|
19 | app.use(dojo());
|
20 | app.use(serve_static(__dirname + '/public'));
|
21 | app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
|
22 | );
|
23 | app.listen(3000);
|
24 | ```
|
25 |
|
26 | Options
|
27 | -------
|
28 |
|
29 | - *method*
|
30 | Support 'release' (default) and 'git'
|
31 | - *repository*
|
32 | Default parent directory where Dojo source code is downloaded
|
33 | - *version*
|
34 | Dojo version, currently `'1.7.1'`, apply only to the 'download' method
|
35 | - *mapping*
|
36 | Object whose keys are "dojo", "dijit", "dojox" and "util" and values are
|
37 | the directory where to download the source code. May be used conjointly with
|
38 | the "repository" options.
|
39 |
|
40 | Using a released version of Dojo
|
41 | --------------------------------
|
42 |
|
43 | Source code is downloaded from the official Dojo website and all the versions
|
44 | present on the website are available. For example to download the version
|
45 | '1.5.0', setup the middleware as:
|
46 |
|
47 | ```javascript
|
48 | dojo({ version: '1.7.1' })
|
49 | ```
|
50 |
|
51 | Using the git HEAD
|
52 | ------------------
|
53 |
|
54 | If the option 'method' is set to 'git' and the revision option of a dojo project
|
55 | is not defined, the middleware will checkout the HEAD revision. Each Dojo
|
56 | project will be store inside a directory defined by the option 'repository' and
|
57 | named as"git-#{project}-HEAD". Here's how to download the latest from GitHub
|
58 | while preserving working tests:
|
59 |
|
60 | ```javascript
|
61 | dojo({
|
62 | method: 'git',
|
63 | repository: __dirname+"../public/dojo",
|
64 | mapping:
|
65 | dojo: './dojo'
|
66 | dijit: './dijit'
|
67 | dojox: './dojox'
|
68 | util: './util'
|
69 | });
|
70 | ```
|
71 |
|
72 | Using a specific git revision
|
73 | -----------------------------
|
74 |
|
75 | If the option 'method' is set to 'git' and one of 'dojo_revision',
|
76 | 'dijit_revision', 'dojox_revision' or 'util_revision' is defined, then the
|
77 | middleware to checkout the revision in a specific directory inside the one
|
78 | defined by the option 'repository' and named as "git-${project}-#{revision}".
|
79 |
|
80 | General note
|
81 | ------------
|
82 |
|
83 | To prevent multiple application from conflicting, a new directory is created
|
84 | for each released version and git revision. This can lead to a large number of directories
|
85 | as new revisions are setup over time. By default, source code is stored inside the
|
86 | connect-dojo module and it is recommended to define your own directory through
|
87 | the 'repository' option.
|
88 |
|
89 | Testing
|
90 | -------
|
91 |
|
92 | Running the tests can take a long time because of the size of dojo. Using
|
93 | expresso, run the following command by adjusting the '-t' (timeout) argument:
|
94 |
|
95 | ```bash
|
96 | expresso -s -t 10000 test
|
97 | ```
|