Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Indentation as 2 spaces

  • Loading branch information...
commit 65ff88e1117ba0411cc2d5bdd4c381a6153ca84d 1 parent 8c3b3ff
@wdavidw authored
View
36 README.md
@@ -5,19 +5,21 @@ This Connect middleware transparently download and display Dojo files.
In its simplest form, it takes no argument and the latest stable release is used. Here is a quick example:
- var express = require('express');
- var dojo = require('connect-dojo');
- var app = express.createServer();
- app.configure(
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(express.cookieParser());
- app.use(dojo());
- app.use(app.router);
- app.use(express.static(__dirname + '/public'));
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- );
- app.listen(3000);
+```javascript
+var express = require('express');
+var dojo = require('connect-dojo');
+var app = express.createServer();
+app.configure(
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(dojo());
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+);
+app.listen(3000);
+```
Options
-------
@@ -33,7 +35,9 @@ Source code is downloaded from the official Dojo website and all the versions
present on the website are available. For example to download the version '1.5.0', setup
the middleware as:
- dojo({ version: '1.7.1' })
+```javascript
+dojo({ version: '1.7.1' })
+```
Using the git HEAD
------------------
@@ -65,4 +69,6 @@ Testing
Running the tests can take a long time because of the size of dojo. Using
expresso, run the following command by adjusting the '-t' (timeout) argument:
- expresso -s -t 10000 test
+```bash
+expresso -s -t 10000 test
+```
View
34 samples/git_head.js
@@ -1,18 +1,18 @@
- var express = require('express');
- var dojo = require('connect-dojo');
- var app = express.createServer();
- app.configure( function(){
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(express.cookieParser());
- app.use(dojo({
- method: 'git',
- repository: __dirname + '/git_head'
- }));
- app.use(app.router);
- app.use(express.static(__dirname + '/public'));
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- } );
- app.listen(7000);
- console.log('http://localhost:3000/dojo/dojo.js');
+ var express = require('express');
+ var dojo = require('connect-dojo');
+ var app = express.createServer();
+ app.configure( function(){
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(dojo({
+ method: 'git',
+ repository: __dirname + '/git_head'
+ }));
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+ } );
+ app.listen(7000);
+ console.log('http://localhost:3000/dojo/dojo.js');
View
42 samples/git_revision.js
@@ -1,22 +1,22 @@
- var express = require('express');
- var dojo = require('connect-dojo');
- var app = express.createServer();
- app.configure( function(){
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(express.cookieParser());
- app.use(dojo({
- method: 'git',
- repository: __dirname + '/git_revision',
- dojo_revision: '852b5161559f3eda16dc',
- dijit_revision: '37b5298bb8b4f24134d5',
- dojox_revision: '145d3bec095382c2f4ac',
- util_revision: 'f9cbb550e2959024df57'
- }));
- app.use(app.router);
- app.use(express.static(__dirname + '/public'));
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- } );
- app.listen(7000);
- console.log('http://localhost:3000/dojo/dojo.js');
+ var express = require('express');
+ var dojo = require('connect-dojo');
+ var app = express.createServer();
+ app.configure( function(){
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(dojo({
+ method: 'git',
+ repository: __dirname + '/git_revision',
+ dojo_revision: '852b5161559f3eda16dc',
+ dijit_revision: '37b5298bb8b4f24134d5',
+ dojox_revision: '145d3bec095382c2f4ac',
+ util_revision: 'f9cbb550e2959024df57'
+ }));
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+ } );
+ app.listen(7000);
+ console.log('http://localhost:3000/dojo/dojo.js');
View
28 samples/simple.js
@@ -1,15 +1,15 @@
- var express = require('express');
- var dojo = require('connect-dojo');
- var app = express.createServer();
- app.configure( function(){
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(express.cookieParser());
- app.use(dojo());
- app.use(app.router);
- app.use(express.static(__dirname + '/public'));
- app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- } );
- app.listen(7000);
- console.log('http://localhost:3000/dojo/dojo.js');
+ var express = require('express');
+ var dojo = require('connect-dojo');
+ var app = express.createServer();
+ app.configure( function(){
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(dojo());
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+ } );
+ app.listen(7000);
+ console.log('http://localhost:3000/dojo/dojo.js');
View
180 src/dojo.coffee
@@ -4,93 +4,93 @@ fs.exists ?= require('path').exists
{exec} = require 'child_process'
module.exports = (options) ->
- # Merge user options with default options
- options ?= {}
- options.method ?= 'release'
- options.version ?= '1.7.1'
- options.repository ?= '/tmp'
- # Store HTTP request in case we need to download Dojo
- loading = true
- submodules = ['dojo', 'dijit', 'dojox', 'util']
- mapping = {}
- args = []
- switch options.method
- when 'release'
- dir = options.repository + '/dojo-release-' + options.version
- mapping =
- dojo: dir + '/dojo'
- dijit: dir + '/dijit'
- dojox: dir + '/dojox'
- util: dir + '/util'
- fs.exists dir, (exists) ->
- return finish() if exists
- url = 'http://download.dojotoolkit.org/release-' + options.version + '/dojo-release-' + options.version + '.tar.gz'
- tgz = options.repository + '/dojo-release-' + options.version + '.tar.gz'
- cmd = 'curl ' + url + ' -o ' + tgz + ' && tar -xzf ' + tgz + ' -C ' + options.repository
- exec cmd, (err, stdout, stderr) ->
- finish(err)
- when 'git'
- count = 0
- _finish = ->
- return if ++count isnt 4
- finish()
- submodules.forEach (submodule) ->
- revision = options[ submodule + '_revision' ] or 'HEAD'
- dirname = 'git-' + submodule + '-' + revision
- mapping[submodule] = options.repository + '/' + dirname
- clone = (next) ->
- fs.exists options.repository + '/' + dirname, (exists) ->
- # Unrequired checkout if the directory named after the revision exists
- return _finish() if exists and revision isnt 'HEAD'
- return next() if exists
- url = 'https://github.com/dojo/' + submodule + '.git'
- cmds = []
- cmds.push 'cd ' + options.repository
- cmds.push 'git clone ' + url + ' ' + dirname
- cmds = cmds.join ' && '
- exec cmds, (err, stdout, stderr) ->
- next(err)
- checkout = (next) ->
- cmds = []
- cmds.push 'cd ' + options.repository + '/' + dirname
- cmds.push 'git checkout ' + revision
- cmds = cmds.join ' && '
- exec cmds, (err, stdout, stderr) ->
- next(err)
- clone (err) ->
- return finish err if err
- checkout (err) ->
- return finish err if err
- _finish()
- else
- throw new Error 'Invalid method option "' + options.method + '" (expects "download")'
- finish = (err) ->
- throw err if err
- loading = false
- for arg in args
- plugin.apply null, arg
- plugin = (req, res, next) ->
- return args.push arguments if loading
- app = /^\/(\w+)\/.*/.exec req.url
- if app and submodules.indexOf( app[1] ) isnt -1
- app = app[1];
- req.url = req.url.substr app.length + 1
- ### prior express 1.7
- # Less
- connect.compiler({ src: mapping[app], enable: ['less'] })(req, res, (err) ->
- console.log err if err
- # Static
- sttc = connect.static mapping[app]
- sttc req, res, ->
- req.url = '/' + app + req.url
- next()
- )
- ###
- # Static
- sttc = connect.static mapping[app]
- sttc req, res, ->
- req.url = '/' + app + req.url
- next()
- else
- next()
- plugin
+ # Merge user options with default options
+ options ?= {}
+ options.method ?= 'release'
+ options.version ?= '1.7.1'
+ options.repository ?= '/tmp'
+ # Store HTTP request in case we need to download Dojo
+ loading = true
+ submodules = ['dojo', 'dijit', 'dojox', 'util']
+ mapping = {}
+ args = []
+ switch options.method
+ when 'release'
+ dir = options.repository + '/dojo-release-' + options.version
+ mapping =
+ dojo: dir + '/dojo'
+ dijit: dir + '/dijit'
+ dojox: dir + '/dojox'
+ util: dir + '/util'
+ fs.exists dir, (exists) ->
+ return finish() if exists
+ url = 'http://download.dojotoolkit.org/release-' + options.version + '/dojo-release-' + options.version + '.tar.gz'
+ tgz = options.repository + '/dojo-release-' + options.version + '.tar.gz'
+ cmd = 'curl ' + url + ' -o ' + tgz + ' && tar -xzf ' + tgz + ' -C ' + options.repository
+ exec cmd, (err, stdout, stderr) ->
+ finish(err)
+ when 'git'
+ count = 0
+ _finish = ->
+ return if ++count isnt 4
+ finish()
+ submodules.forEach (submodule) ->
+ revision = options[ submodule + '_revision' ] or 'HEAD'
+ dirname = 'git-' + submodule + '-' + revision
+ mapping[submodule] = options.repository + '/' + dirname
+ clone = (next) ->
+ fs.exists options.repository + '/' + dirname, (exists) ->
+ # Unrequired checkout if the directory named after the revision exists
+ return _finish() if exists and revision isnt 'HEAD'
+ return next() if exists
+ url = 'https://github.com/dojo/' + submodule + '.git'
+ cmds = []
+ cmds.push 'cd ' + options.repository
+ cmds.push 'git clone ' + url + ' ' + dirname
+ cmds = cmds.join ' && '
+ exec cmds, (err, stdout, stderr) ->
+ next(err)
+ checkout = (next) ->
+ cmds = []
+ cmds.push 'cd ' + options.repository + '/' + dirname
+ cmds.push 'git checkout ' + revision
+ cmds = cmds.join ' && '
+ exec cmds, (err, stdout, stderr) ->
+ next(err)
+ clone (err) ->
+ return finish err if err
+ checkout (err) ->
+ return finish err if err
+ _finish()
+ else
+ throw new Error 'Invalid method option "' + options.method + '" (expects "download")'
+ finish = (err) ->
+ throw err if err
+ loading = false
+ for arg in args
+ plugin.apply null, arg
+ plugin = (req, res, next) ->
+ return args.push arguments if loading
+ app = /^\/(\w+)\/.*/.exec req.url
+ if app and submodules.indexOf( app[1] ) isnt -1
+ app = app[1];
+ req.url = req.url.substr app.length + 1
+ ### prior express 1.7
+ # Less
+ connect.compiler({ src: mapping[app], enable: ['less'] })(req, res, (err) ->
+ console.log err if err
+ # Static
+ sttc = connect.static mapping[app]
+ sttc req, res, ->
+ req.url = '/' + app + req.url
+ next()
+ )
+ ###
+ # Static
+ sttc = connect.static mapping[app]
+ sttc req, res, ->
+ req.url = '/' + app + req.url
+ next()
+ else
+ next()
+ plugin
View
86 test/git.coffee
@@ -5,46 +5,46 @@ should = require 'should'
dojo = if process.env.DOJO_COV then require '../lib-cov/dojo' else require '../lib/dojo'
describe 'Git', ->
- it 'should download dojo HEAD', (next) ->
- @timeout 0
- middleware = dojo method: 'git'
- req = url: 'http://localhost'
- res = {}
- middleware req, res, (err) ->
- should.not.exist err
- each([
- '/tmp/git-dojo-HEAD'
- '/tmp/git-dijit-HEAD'
- '/tmp/git-dojox-HEAD'
- '/tmp/git-util-HEAD'
- ])
- .on 'item', (path, next) ->
- fs.stat path, (err, stats) ->
- should.not.exist err
- stats.isDirectory().should.be.ok
- next()
- .on 'both', next
- it 'should download specified revisions', (next) ->
- @timeout 0
- middleware = dojo
- method: 'git',
- dojo_revision: '852b5161559f3eda16dc'
- dijit_revision: '37b5298bb8b4f24134d5'
- dojox_revision: '145d3bec095382c2f4ac'
- util_revision: 'f9cbb550e2959024df57'
- req = { url: 'http://localhost' }
- res = {}
- middleware req, res, (err) ->
- should.not.exist err
- each([
- '/tmp/git-dojo-852b5161559f3eda16dc'
- '/tmp/git-dijit-37b5298bb8b4f24134d5'
- '/tmp/git-dojox-145d3bec095382c2f4ac'
- '/tmp/git-util-f9cbb550e2959024df57'
- ])
- .on 'item', (path, next) ->
- fs.stat path, (err, stats) ->
- should.not.exist err
- stats.isDirectory().should.be.ok
- next()
- .on 'both', next
+ it 'should download dojo HEAD', (next) ->
+ @timeout 0
+ middleware = dojo method: 'git'
+ req = url: 'http://localhost'
+ res = {}
+ middleware req, res, (err) ->
+ should.not.exist err
+ each([
+ '/tmp/git-dojo-HEAD'
+ '/tmp/git-dijit-HEAD'
+ '/tmp/git-dojox-HEAD'
+ '/tmp/git-util-HEAD'
+ ])
+ .on 'item', (path, next) ->
+ fs.stat path, (err, stats) ->
+ should.not.exist err
+ stats.isDirectory().should.be.ok
+ next()
+ .on 'both', next
+ it 'should download specified revisions', (next) ->
+ @timeout 0
+ middleware = dojo
+ method: 'git',
+ dojo_revision: '852b5161559f3eda16dc'
+ dijit_revision: '37b5298bb8b4f24134d5'
+ dojox_revision: '145d3bec095382c2f4ac'
+ util_revision: 'f9cbb550e2959024df57'
+ req = { url: 'http://localhost' }
+ res = {}
+ middleware req, res, (err) ->
+ should.not.exist err
+ each([
+ '/tmp/git-dojo-852b5161559f3eda16dc'
+ '/tmp/git-dijit-37b5298bb8b4f24134d5'
+ '/tmp/git-dojox-145d3bec095382c2f4ac'
+ '/tmp/git-util-f9cbb550e2959024df57'
+ ])
+ .on 'item', (path, next) ->
+ fs.stat path, (err, stats) ->
+ should.not.exist err
+ stats.isDirectory().should.be.ok
+ next()
+ .on 'both', next
View
36 test/release.coffee
@@ -5,21 +5,21 @@ each = require 'each'
dojo = if process.env.DOJO_COV then require '../lib-cov/dojo' else require '../lib/dojo'
describe 'Release', ->
- it 'should download specific release', (next) ->
- @timeout 0
- middleware = dojo version: '1.5.0'
- req = url: 'http://localhost'
- res = {}
- middleware req, res, (err) ->
- should.not.exist err
- each([
- '/tmp/dojo-release-1.5.0/dojo'
- '/tmp/dojo-release-1.5.0/dijit'
- '/tmp/dojo-release-1.5.0/dojox'
- ])
- .on 'item', (path, next) ->
- fs.stat path, (err, stats) ->
- should.not.exist err
- stats.isDirectory().should.be.ok
- next()
- .on 'both', next
+ it 'should download specific release', (next) ->
+ @timeout 0
+ middleware = dojo version: '1.5.0'
+ req = url: 'http://localhost'
+ res = {}
+ middleware req, res, (err) ->
+ should.not.exist err
+ each([
+ '/tmp/dojo-release-1.5.0/dojo'
+ '/tmp/dojo-release-1.5.0/dijit'
+ '/tmp/dojo-release-1.5.0/dojox'
+ ])
+ .on 'item', (path, next) ->
+ fs.stat path, (err, stats) ->
+ should.not.exist err
+ stats.isDirectory().should.be.ok
+ next()
+ .on 'both', next
Please sign in to comment.
Something went wrong with that request. Please try again.