Update to Dojo 1.8.0, separate package & application profiles, change whitespace rules.
diff --git a/README.md b/README.md
index dfb9901..62f2674 100644
--- a/README.md
+++ b/README.md
@@ -3,10 +3,10 @@
The Dojo Boilerplate is a set of files to help you rapidly get up and running
with the Dojo Toolkit. It illustrates some basic best practices when working
-with Dojo. This is the branch for the new Dojo 1.7 loader and build systems,
-which use AMD modules; there is also a [branch using the old synchronous
-loader](https://github.com/csnover/dojo-boilerplate/tree/1.6), for use
-with Dojo 1.6.
+with Dojo. This is the branch for the new AMD loader and build systems in Dojo
+1.7 and later; there is also a
+[branch using the old synchronous loader](https://github.com/csnover/dojo-boilerplate/tree/1.6),
+for use with Dojo 1.6 and earlier.
Huge thanks go out to [neonstalwart](https://github.com/neonstalwart) for his
original
@@ -50,19 +50,17 @@
(by way of the second `[ 'app' ]` argument).
* The file `build.sh` takes your application files and builds them for
production use using the Dojo build tool. It depends on the presence of the
- build profile at `src/app/app.profile.js`.
+ build profile at `profiles/app.profile.js`.
* The file `src/app/resources/app.css` contains import statements to load
the CSS for Dojo’s Claro theme. _If you are not using Dijit widgets, you
probably want to remove these imports!_
-* The directory `src/dbp` contains tools you may find useful. These tools
- are a work in progress, and are not yet updated to AMD syntax.
Useful resources
----------------
-* [Dojo Reference Guide (latest release version)](http://dojotoolkit.org/reference-guide/)
-* [Dojo Reference Guide (Dojo trunk)](http://livedocs.dojotoolkit.org/)
-* [Introduction to Custom Dojo Widgets](http://www.enterprisedojo.com/2010/09/21/introduction-to-custom-dojo-widgets/)
+* [Dojo Tutorials](http://dojotoolkit.org/documentation/)
+* [Dojo Reference Guide](http://dojotoolkit.org/reference-guide/)
+* [Dojo API Browser](http://dojotoolkit.org/api/)
About the boilerplate
---------------------
diff --git a/build.sh b/build.sh
index 27062eb..cdf0080 100755
--- a/build.sh
+++ b/build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
set -e
@@ -21,13 +21,13 @@
LOADERCONF="$SRCDIR/$LOADERMID.js"
# Main application package build configuration
-PROFILE="$SRCDIR/app/app.profile.js"
+PROFILE="$BASEDIR/profiles/app.profile.js"
# Configuration over. Main application start up!
if [ ! -d "$TOOLSDIR" ]; then
- echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
- exit 1
+ echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
+ exit 1
fi
echo "Building application with $PROFILE to $DISTDIR."
@@ -39,12 +39,12 @@
cd "$TOOLSDIR"
if which node >/dev/null; then
- node ../../dojo/dojo.js load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" "$@"
+ node ../../dojo/dojo.js load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
elif which java >/dev/null; then
- java -Xms256m -Xmx256m -cp ../shrinksafe/js.jar:../closureCompiler/compiler.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js baseUrl=../../dojo load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" "$@"
+ java -Xms256m -Xmx256m -cp ../shrinksafe/js.jar:../closureCompiler/compiler.jar:../shrinksafe/shrinksafe.jar org.mozilla.javascript.tools.shell.Main ../../dojo/dojo.js baseUrl=../../dojo load=build --require "$LOADERCONF" --profile "$PROFILE" --releaseDir "$DISTDIR" $@
else
- echo "Need node.js or Java to build!"
- exit 1
+ echo "Need node.js or Java to build!"
+ exit 1
fi
cd "$BASEDIR"
diff --git a/profiles/app.profile.js b/profiles/app.profile.js
new file mode 100644
index 0000000..8e9f3a0
--- /dev/null
+++ b/profiles/app.profile.js
@@ -0,0 +1,107 @@
+/**
+ * This is the default application build profile used by the boilerplate. While it looks similar, this build profile
+ * is different from the package build profile at `app/package.js` in the following ways:
+ *
+ * 1. you can have multiple application build profiles (e.g. one for desktop, one for tablet, etc.), but only one
+ * package build profile;
+ * 2. the package build profile only configures the `resourceTags` for the files in the package, whereas the
+ * application build profile tells the build system how to build the entire application.
+ *
+ * Look to `util/build/buildControlDefault.js` for more information on available options and their default values.
+ */
+
+var profile = {
+ // `basePath` is relative to the directory containing this profile file; in this case, it is being set to the
+ // src/ directory, which is the same place as the `baseUrl` directory in the loader configuration. (If you change
+ // this, you will also need to update run.js.)
+ basePath: '../src/',
+
+ // This is the directory within the release directory where built packages will be placed. The release directory
+ // itself is defined by `build.sh`. You should probably not use this; it is a legacy option dating back to Dojo
+ // 0.4.
+ // If you do use this, you will need to update build.sh, too.
+ // releaseName: '',
+
+ // Builds a new release.
+ action: 'release',
+
+ // Strips all comments and whitespace from CSS files and inlines @imports where possible.
+ cssOptimize: 'comments',
+
+ // Excludes tests, demos, and original template files from being included in the built version.
+ mini: true,
+
+ // Uses Closure Compiler as the JavaScript minifier. This can also be set to "shrinksafe" to use ShrinkSafe,
+ // though ShrinkSafe is deprecated and not recommended.
+ // This option defaults to "" (no compression) if not provided.
+ optimize: 'closure',
+
+ // We're building layers, so we need to set the minifier to use for those, too.
+ // This defaults to "shrinksafe" if not provided.
+ layerOptimize: 'closure',
+
+ // Strips all calls to console functions within the code. You can also set this to "warn" to strip everything
+ // but console.error, and any other truthy value to strip everything but console.warn and console.error.
+ // This defaults to "normal" (strip all but warn and error) if not provided.
+ stripConsole: 'all',
+
+ // The default selector engine is not included by default in a dojo.js build in order to make mobile builds
+ // smaller. We add it back here to avoid that extra HTTP request. There is also a "lite" selector available; if
+ // you use that, you will need to set the `selectorEngine` property in `app/run.js`, too. (The "lite" engine is
+ // only suitable if you are not supporting IE7 and earlier.)
+ selectorEngine: 'acme',
+
+ // Builds can be split into multiple different JavaScript files called "layers". This allows applications to
+ // defer loading large sections of code until they are actually required while still allowing multiple modules to
+ // be compiled into a single file.
+ layers: {
+ // This is the main loader module. It is a little special because it is treated like an AMD module even though
+ // it is actually just plain JavaScript. There is some extra magic in the build system specifically for this
+ // module ID.
+ 'dojo/dojo': {
+ // In addition to the loader `dojo/dojo` and the loader configuration file `app/run`, we are also including
+ // the main application `app/main` and the `dojo/i18n` and `dojo/domReady` modules because, while they are
+ // all conditional dependencies in `app/main`, we do not want to have to make extra HTTP requests for such
+ // tiny files.
+ include: [ 'dojo/i18n', 'dojo/domReady', 'app/main', 'app/run' ],
+
+ // By default, the build system will try to include `dojo/main` in the built `dojo/dojo` layer, which adds
+ // a bunch of stuff we do not want or need. We want the initial script load to be as small and quick to
+ // load as possible, so we configure it as a custom, bootable base.
+ boot: true,
+ customBase: true
+ },
+
+ // In the demo application, we conditionally require `app/Dialog` on the client-side, so here we build a
+ // separate layer containing just that client-side code. (Practically speaking, you would probably just want
+ // to roll everything into a single layer, but this helps provide a basic illustration of multi-layer builds.)
+ // Note that when you create a new layer, the module referenced by the layer is always included in the layer
+ // (in this case, `app/Dialog`), so it does not need to be explicitly defined in the `include` array.
+ 'app/Dialog': {}
+ },
+
+ // Providing hints to the build system allows code to be conditionally removed on a more granular level than
+ // simple module dependencies can allow. This is especially useful for creating tiny mobile builds.
+ // Keep in mind that dead code removal only happens in minifiers that support it! Currently, only Closure Compiler
+ // to the Dojo build system with dead code removal.
+ // A documented list of has-flags in use within the toolkit can be found at
+ // <http://dojotoolkit.org/reference-guide/dojo/has.html>.
+ staticHasFeatures: {
+ // The trace & log APIs are used for debugging the loader, so we do not need them in the build.
+ 'dojo-trace-api': 0,
+ 'dojo-log-api': 0,
+
+ // This causes normally private loader data to be exposed for debugging. In a release build, we do not need
+ // that either.
+ 'dojo-publish-privates': 0,
+
+ // This application is pure AMD, so get rid of the legacy loader.
+ 'dojo-sync-loader': 0,
+
+ // `dojo-xhr-factory` relies on `dojo-sync-loader`, which we have removed.
+ 'dojo-xhr-factory': 0,
+
+ // We are not loading tests in production, so we can get rid of some test sniffing code.
+ 'dojo-test-sniff': 0
+ }
+};
\ No newline at end of file
diff --git a/src/app/Dialog.js b/src/app/Dialog.js
index 1faaa4f..9e84928 100644
--- a/src/app/Dialog.js
+++ b/src/app/Dialog.js
@@ -1,10 +1,10 @@
/**
- * This file is a very simple example of a class declaration in Dojo. It defines the “app/Dialog” module as a new
+ * This file is a very simple example of a class declaration in Dojo. It defines the `app/Dialog` module as a new
* class that extends a dijit Dialog and overrides the default title and content properties.
*/
define([ 'dojo/_base/declare', 'dijit/Dialog' ], function (declare, Dialog) {
- return declare(Dialog, {
- title: 'Hello World',
- content: 'Loaded successfully!'
- });
+ return declare(Dialog, {
+ title: 'Hello World',
+ content: 'Loaded successfully!'
+ });
});
\ No newline at end of file
diff --git a/src/app/app.profile.js b/src/app/app.profile.js
deleted file mode 100644
index 7a6a32c..0000000
--- a/src/app/app.profile.js
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * This is a new Dojo 1.7 style build profile. Look at util/build/buildControlDefault.js if you want to explore the
- * default Dojo build profile options.
- */
-
-// This function is used to determine whether or not a resource should be tagged as copy-only. See the resourceTags
-// property below for more information.
-function copyOnly(mid) {
- return mid in {
- // There are no modules right now in dojo boilerplate that are copy-only. If you have some, though, just add
- // them here like this:
- // 'app/module': 1
- };
-}
-
-var profile = {
- // basePath is relative to the directory containing this profile file; in this case, it is being set to the
- // src/ directory, which is the same place as the baseUrl directory in the loader configuration. (If you change
- // this, you will also need to update run.js).
- basePath: '..',
-
- // This is the directory within the release directory where built packages will be placed. The release directory
- // itself is defined by build.sh. You really probably should not use this; it is a legacy option from very old
- // versions of Dojo (like, version 0.1). If you do use it, you will need to update build.sh, too.
- // releaseName: '',
-
- // Builds a new release.
- action: 'release',
-
- // Strips all comments from CSS files.
- cssOptimize: 'comments',
-
- // Excludes tests, demos, and original template files from being included in the built version.
- mini: true,
-
- // Uses Closure Compiler as the JavaScript minifier. This can also be set to "shrinksafe" to use ShrinkSafe.
- // Note that you will probably get some “errors” with CC; these are generally safe to ignore, and will be
- // fixed in a later version of Dojo. This defaults to "" (no compression) if not provided.
- optimize: 'closure',
-
- // We’re building layers, so we need to set the minifier to use for those, too. This defaults to "shrinksafe" if
- // it is not provided.
- layerOptimize: 'closure',
-
- // Strips all calls to console functions within the code. You can also set this to "warn" to strip everything
- // but console.error, and any other truthy value to strip everything but console.warn and console.error.
- stripConsole: 'all',
-
- // The default selector engine is not included by default in a dojo.js build in order to make mobile builds
- // smaller. We add it back here to avoid that extra HTTP request. There is also a "lite" selector available; if
- // you use that, you’ll need to set selectorEngine in app/run.js too. (The "lite" engine is only suitable if you
- // are not supporting IE7 and earlier.)
- selectorEngine: 'acme',
-
- // Builds can be split into multiple different JavaScript files called “layers”. This allows applications to
- // defer loading large sections of code until they are actually required while still allowing multiple modules to
- // be compiled into a single file.
- layers: {
- // This is the main loader module. It is a little special because it is treated like an AMD module even though
- // it is actually just plain JavaScript. There is some extra magic in the build system specifically for this
- // module ID.
- 'dojo/dojo': {
- // In addition to the loader (dojo/dojo) and the loader configuration file (app/run), we’re also including
- // the main application (app/main) and the dojo/i18n and dojo/domReady modules because they are one of the
- // conditional dependencies in app/main (the other being app/Dialog) but we don’t want to have to make
- // extra HTTP requests for such tiny files.
- include: [ 'dojo/dojo', 'dojo/i18n', 'dojo/domReady', 'app/main', 'app/run' ],
-
- // By default, the build system will try to include dojo/main in the built dojo/dojo layer, which adds a
- // bunch of stuff we don’t want or need. We want the initial script load to be as small and quick as
- // possible, so we configure it as a custom, bootable base.
- boot: true,
- customBase: true
- },
-
- // In the demo application, we conditionally require app/Dialog on the client-side, so we’re building a
- // separate layer containing just that client-side code. (Practically speaking, you’d probably just want
- // to roll everything into a single layer, but I wanted to make sure to illustrate multi-layer builds.)
- 'app/Dialog': { include: [ 'app/Dialog' ] }
- },
-
- // Providing hints to the build system allows code to be conditionally removed on a more granular level than
- // simple module dependencies can allow. This is especially useful for creating tiny mobile builds.
- // Keep in mind that dead code removal only happens in minifiers that support it! Currently, ShrinkSafe does not
- // support dead code removal; Closure Compiler and UglifyJS do.
- staticHasFeatures: {
- // The trace & log APIs are used for debugging the loader, so we don’t need them in the build
- 'dojo-trace-api':0,
- 'dojo-log-api':0,
-
- // This causes normally private loader data to be exposed for debugging, so we don’t need that either
- 'dojo-publish-privates':0,
-
- // We’re fully async, so get rid of the legacy loader
- 'dojo-sync-loader':0,
-
- // dojo-xhr-factory relies on dojo-sync-loader
- 'dojo-xhr-factory':0,
-
- // We aren’t loading tests in production
- 'dojo-test-sniff':0
- },
-
- // Resource tags are functions that provide hints to the compiler about a given file. The first argument is the
- // filename of the file, and the second argument is the module ID for the file.
- resourceTags: {
- // Files that contain test code.
- test: function (filename, mid) {
- return false;
- },
-
- // Files that should be copied as-is without being modified by the build system.
- copyOnly: function (filename, mid) {
- return copyOnly(mid);
- },
-
- // Files that are AMD modules.
- amd: function (filename, mid) {
- return !copyOnly(mid) && /\.js$/.test(filename);
- },
-
- // Files that should not be copied when the “mini” compiler flag is set to true.
- miniExclude: function (filename, mid) {
- return mid in {
- 'app/profile': 1
- };
- }
- }
-};
\ No newline at end of file
diff --git a/src/app/main.js b/src/app/main.js
index f56c774..d671346 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -1,50 +1,57 @@
/**
- * This file is your application’s main JavaScript file. It is listed as a dependency in run.js and will
- * automatically load when run.js loads.
+ * This file is the application's main JavaScript file. It is listed as a dependency in run.js and will automatically
+ * load when run.js loads.
*
- * Because this file has the special filename “main.js”, and because we’ve registered the “app” package in run.js,
- * whatever object this module returns can be loaded by other files simply by requiring “app” (instead of “app/main”).
+ * Because this file has the special filename `main.js`, and because we've registered the `app` package in run.js,
+ * whatever object this module returns can be loaded by other files simply by requiring `app` (instead of `app/main`).
*
- * Our first dependency is to the “dojo/has” module, which allows us to conditionally execute code based on
+ * Our first dependency is to the `dojo/has` module, which allows us to conditionally execute code based on
* configuration settings or environmental information. Unlike a normal conditional, these branches can be compiled
- * away by the build system; see “staticHasFeatures” in app.profile.js for more information.
+ * away by the build system; see `staticHasFeatures` in app.profile.js for more information.
*
- * Our second dependency is to the special module “require”; this allows us to make additional require calls using
- * relative module IDs within the body of our define function.
+ * Our second dependency is to the special module `require`; this allows us to make additional require calls using
+ * module IDs relative to this module within the body of the define callback.
*
- * In all cases, whatever function is passed to define() is only invoked once, and the return value is cached.
+ * In all cases, whatever function is passed to define() is only invoked once, and the returned value is cached.
*
* More information about everything described about the loader throughout this file can be found at
- * http://livedocs.dojotoolkit.org/loader/amd.
+ * <http://dojotoolkit.org/reference-guide/loader/amd.html>.
*/
define([ 'dojo/has', 'require' ], function (has, require) {
- var app = {};
+ var app = {};
- if (has('host-browser')) {
- /*
- * This require call’s first dependency, “./Dialog”, uses a relative module identifier; you should use this
- * type of notation for dependencies *within* a package in order to ensure the package is fully portable. It
- * works like a path, where “./” refers to the current directory and “../” refers to the parent directory. If
- * you are referring to a module in a *different* package, you should *not* use a relative module identifier.
- *
- * The second dependency is a plugin dependency; in this case, it is a dependency on the special functionality
- * of the “dojo/domReady” plugin, which waits until the DOM is ready before finishing loading.
- * The “!” after the module name indicates you want to use special plugin functionality; if you were to
- * require just “dojo/domReady”, it would load that module just like any other module, without any of the
- * special plugin functionality.
- */
- require([ './Dialog', 'dojo/domReady!' ], function (Dialog) {
- app.dialog = new Dialog().placeAt(document.body);
+ /**
+ * This main.js file conditionally executes different code depending upon the host environment it is loaded in.
+ * This is an increasingly common pattern when dealing with applications that run in different environments that
+ * require different functionality (i.e. client/server or desktop/tablet/phone).
+ */
+ if (has('host-browser')) {
+ /*
+ * This require call's first dependency, `./Dialog`, uses a relative module identifier; you should use this
+ * type of notation for dependencies *within* a package in order to ensure the package is fully portable. It
+ * works like a path, where `./` refers to the current directory and `../` refers to the parent directory. If
+ * you are referring to a module in a *different* package (like `dojo` or `dijit`), you should *not* use a
+ * relative module identifier.
+ *
+ * The second dependency is a plugin dependency; in this case, it is a dependency on the special functionality
+ * of the `dojo/domReady` plugin, which simply waits until the DOM is ready before resolving.
+ * The `!` after the module name indicates you want to use special plugin functionality; if you were to
+ * require just `dojo/domReady`, it would load that module just like any other module, without the special
+ * plugin functionality.
+ */
+ require([ './Dialog', 'dojo/domReady!' ], function (Dialog) {
+ app.dialog = new Dialog().placeAt(document.body);
- // It is important to remember to always call startup on widgets after you have added them to the DOM.
- // It won’t hurt if you do it twice, but things will often not work right if you forget to do it.
- app.dialog.startup();
+ // It is important to remember to always call startup on widgets after you have added them to the DOM.
+ // It will not hurt if you do it twice, but things will often not work right if you forget to do it.
+ app.dialog.startup();
- // And now…
- app.dialog.show();
- });
- }
- else {
- console.log('Hello from the server!');
- }
+ // And now we just show the dialog to demonstrate that, yes, the example app has loaded successfully.
+ app.dialog.show();
+ });
+ }
+ else {
+ // TODO: Eventually, the Boilerplate will actually have a useful server implementation here :)
+ console.log('Hello from the server!');
+ }
});
\ No newline at end of file
diff --git a/src/app/package.js b/src/app/package.js
new file mode 100644
index 0000000..de0fa1d
--- /dev/null
+++ b/src/app/package.js
@@ -0,0 +1,43 @@
+/**
+ * This file is referenced by the `dojoBuild` key in `package.json` and provides extra hinting specific to the Dojo
+ * build system about how certain files in the package need to be handled at build time. Build profiles for the
+ * application itself are stored in the `profiles` directory.
+ */
+
+var profile = {
+ // Resource tags are functions that provide hints to the build system about the way files should be processed.
+ // Each of these functions is called once for every file in the package directory. The first argument passed to
+ // the function is the filename of the file, and the second argument is the computed AMD module ID of the file.
+ resourceTags: {
+ // Files that contain test code and should be excluded when the `copyTests` build flag exists and is `false`.
+ // It is strongly recommended that the `mini` build flag be used instead of `copyTests`. Therefore, no files
+ // are marked with the `test` tag here.
+ test: function (filename, mid) {
+ return false;
+ },
+
+ // Files that should be copied as-is without being modified by the build system.
+ // All files in the `app/resources` directory that are not CSS files are marked as copy-only, since these files
+ // are typically binaries (images, etc.) and may be corrupted by the build system if it attempts to process
+ // them and naively assumes they are scripts.
+ copyOnly: function (filename, mid) {
+ return (/^app\/resources\//.test(filename) && !/\.css$/.test(filename));
+ },
+
+ // Files that are AMD modules.
+ // All JavaScript in this package should be AMD modules if you are starting a new project. If you are copying
+ // any legacy scripts from an existing project, those legacy scripts should not be given the `amd` tag.
+ amd: function (filename, mid) {
+ return !this.copyOnly(filename, mid) && /\.js$/.test(filename);
+ },
+
+ // Files that should not be copied when the `mini` build flag is set to true.
+ // In this case, we are excluding this package configuration file which is not necessary in a built copy of
+ // the application.
+ miniExclude: function (filename, mid) {
+ return mid in {
+ 'app/package': 1
+ };
+ }
+ }
+};
\ No newline at end of file
diff --git a/src/app/package.json b/src/app/package.json
index 44ed9a8..c090977 100644
--- a/src/app/package.json
+++ b/src/app/package.json
@@ -1,26 +1,26 @@
{
- "name": "app",
- "version": "1.0",
- "main": "main",
- "dependencies": {
- "dojo": "current",
- "dijit": "current",
- "dojox": "current",
- "util": "current"
- },
- "description": "Dojo Boilerplate Example Application. A quick-start application that demonstrates basic usage of the Dojo Toolkit. This package.json file is a CommonJS Packages/1.0 manifest, with a special “dojoBuild” property to point to the build file for this package. (This is more useful for library packages than the main application package.)",
- "licenses": [
- {
- "type": "AFLv2.1",
- "url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"
- },
- {
- "type": "BSD",
- "url": "http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"
- }
- ],
- "bugs": "https://github.com/csnover/dojo-boilerplate/issues",
- "keywords": ["JavaScript", "Dojo", "Boilerplate", "Example", "Howto"],
- "homepage": "https://github.com/csnover/dojo-boilerplate",
- "dojoBuild": "app.profile.js"
+ "name": "app",
+ "version": "1.0",
+ "main": "main",
+ "dependencies": {
+ "dojo": "1.8.0",
+ "dijit": "1.8.0",
+ "dojox": "1.8.0",
+ "util": "1.8.0"
+ },
+ "description": "Dojo Boilerplate Example Application. A quick-start application that demonstrates basic usage of the Dojo Toolkit. This package.json file is a CommonJS Packages/1.0 manifest, with a special `dojoBuild` property to point to the build file for this package.",
+ "licenses": [
+ {
+ "type": "AFLv2.1",
+ "url": "http://bugs.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43"
+ },
+ {
+ "type": "BSD",
+ "url": "http://bugs.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13"
+ }
+ ],
+ "bugs": "https://github.com/csnover/dojo-boilerplate/issues",
+ "keywords": ["JavaScript", "Dojo", "Boilerplate", "Example", "Howto"],
+ "homepage": "https://github.com/csnover/dojo-boilerplate",
+ "dojoBuild": "package.js"
}
\ No newline at end of file
diff --git a/src/app/resources/app.css b/src/app/resources/app.css
index 572366f..135ab7c 100644
--- a/src/app/resources/app.css
+++ b/src/app/resources/app.css
@@ -3,7 +3,7 @@
* below; otherwise, you can remove them. When building for release, Dojo will automatically combine all of your
* @imported CSS files into a single file.
*
- * It is highly, highly recommended that you develop your CSS using LESS: http://lesscss.org.
+ * It is highly, highly recommended that you develop your CSS using Stylus: http://learnboost.github.com/stylus/.
*/
@import '../../dojo/resources/dojo.css';
diff --git a/src/app/run.js b/src/app/run.js
index e014707..a3532aa 100644
--- a/src/app/run.js
+++ b/src/app/run.js
@@ -1,38 +1,31 @@
/**
- * This file is used to reconfigure parts of the loader at runtime for this application. We’ve put this extra
+ * This file is used to reconfigure parts of the loader at runtime for this application. We've put this extra
* configuration in a separate file, instead of adding it directly to index.html, because it contains options that
* can be shared if the application is run on both the client and the server.
*
- * If you aren’t planning on running your app on both the client and the server, you could easily move this
+ * If you aren't planning on running your app on both the client and the server, you could easily move this
* configuration into index.html (as a dojoConfig object) if it makes your life easier.
*/
require({
- // The base path for all packages and modules. If you don't provide this, baseUrl defaults to the directory
- // that contains dojo.js. Since all packages are in the root, we just leave it blank. (If you change this, you
- // will also need to update app.profile.js).
- baseUrl: '',
+ // The base path for all packages and modules. If you don't provide this, baseUrl defaults to the directory
+ // that contains dojo.js. Since all packages are in the root, we just leave it blank. (If you change this, you
+ // will also need to update `app.profile.js`).
+ baseUrl: '',
- // A list of packages to register. Strictly speaking, you do not need to register any packages,
- // but you can't require "app" and get app/main.js if you do not register the "app" package (the loader will look
- // for a module at <baseUrl>/app.js instead). Unregistered packages also cannot use the packageMap feature, which
- // might be important to you if you need to relocate dependencies. TL;DR, register all your packages all the time:
- // it will make your life easier.
- packages: [
- // If you are registering a package that has an identical name and location, you can just pass a string
- // instead, and it will configure it using that string for both the "name" and "location" properties. Handy!
- 'dojo',
- 'dijit',
- 'dojox',
- 'app',
+ // A list of packages to register. Strictly speaking, you do not need to register any packages,
+ // but you can't require "app" and get app/main.js if you do not register the "app" package (the loader will look
+ // for a module at <baseUrl>/app.js instead). Unregistered packages also cannot use the `map` feature, which
+ // might be important to you if you need to relocate dependencies. TL;DR, register all your packages all the time:
+ // it will make your life easier.
+ packages: [
+ // If you are registering a package that has an identical name and location, you can just pass a string
+ // instead, and it will configure it using that string for both the "name" and "location" properties. Handy!
+ 'dojo',
+ 'dijit',
+ 'dojox',
- // For reference, this is what a more verbose package declaration looks like.
- { name: 'dbp', location: 'dbp', packageMap: {} }
- ],
-
- // This is a hack. In order to allow app/main and app/run to be built together into a single file, a cache key needs
- // to exist here in order to force the loader to actually process the other modules in the file. Without this hack,
- // the loader will think that code for app/main has not been loaded yet and will try to fetch it again, resulting in
- // a needless extra HTTP request.
- cache: {}
-// Require 'app'. This loads the main application file, app/main.js.
+ // For reference, this is what a more verbose package declaration looks like.
+ { name: 'app', location: 'app', map: {} }
+ ]
+// Require `app`. This loads the main application module, `app/main`, since we registered the `app` package above.
}, [ 'app' ]);
\ No newline at end of file
diff --git a/src/dbp/Router.js b/src/dbp/Router.js
deleted file mode 100644
index d1c4d85..0000000
--- a/src/dbp/Router.js
+++ /dev/null
@@ -1,278 +0,0 @@
-/**
- * THIS FILE IS A WORK IN PROGRESS AND MOST LIKELY
- * DOES NOT WORK AT THE MOMENT. YOU HAVE BEEN WARNED.
- */
-dojo.provide("dbp.Router");
-
-dojo.require("dojo.hash");
-
-/**
- * dbp.Router provides an API for specifying hash-based URLs ("routes") and
- * the functionality associated with each. It allows the routes to include both
- * path and query string parameters which are then available inside the
- * handling function:
- *
- * /things/:id -> #/things/3
- * /things -> #/things?id=3&color=red
- *
- * Defining a route involves providing a path for the route, and a function to
- * run for the route. The function receives two arguments: an object containing
- * the parameters associated with the route, if any; and an object containing
- * information about the route that was run.
- *
- * Example usage
- *
- * var myRouter = new dbp.Router([
- * {
- * path : "/foo/:bar",
- * handler : function(params) { },
- * defaultRoute : true
- * }
- * ]);
- *
- * myRouter.init();
- *
- * This router was heavily inspired by Sammy.js, a full-featured router
- * for jQuery projects. http://sammyjs.org/
- */
-
-(function(d){
-
-var routes = [],
- routeCache = {},
- currentPath,
- connections = [],
- subscriptions = [],
-
- PATH_REPLACER = "([^\/]+)",
- PATH_NAME_MATCHER = /:([\w\d]+)/g,
-
- hasHistoryState = "onpopstate" in window;
-
-dojo.declare('dbp.Router', null, {
- constructor : function(userRoutes) {
- if (!userRoutes || !userRoutes.length) {
- throw "No routes provided to dbp.Router.";
- }
-
- if (routes.length) {
- console.warn("An instance of dbp.Router already exists. You may want to create another one, but it's unlikely.");
- }
-
-
- d.forEach(userRoutes, function(r) {
- this._registerRoute(r.path, r.handler, r.defaultRoute);
- }, this);
-
- // use the first route as the default if one
- // is not marked as the default
- if (!this.defaultRoute) {
- this.defaultRoute = userRoutes[0];
- }
-
- },
-
- /**
- * Initialization method; looks at current hash and handles,
- * else uses default route to get started
- */
- init : function() {
- this.go(window.location.hash || this.defaultRoute.path);
-
- if (hasHistoryState) {
- connections.push(d.connect(window, "onpopstate", this, function() {
- this._handle(window.location.hash);
- }));
- } else {
- subscriptions.push(d.subscribe("/dojo/hashchange", this, "_handle"));
- }
- },
-
- /**
- * Redirect to a path
- * @param {String} path
- */
- go : function(path) {
- path = dojo.trim(path);
- if (!path) { return; }
-
- this._handle(path);
-
- if (path.indexOf("#") !== 0) {
- path = "#" + path;
- }
-
- if (hasHistoryState) {
- history.pushState(null, null, path);
- } else {
- window.location.hash = path;
- }
- },
-
- /**
- * When the router observes navigation to a new hash, it passes
- * the hash to this function to be handled.
- *
- * @param {String} The hash to which the user navigated
- */
- _handle : function(hash) {
- if (hash === currentPath) { return; }
- currentPath = hash;
-
- var path = hash.replace("#",""),
-
- route = this._chooseRoute(this._getRouteablePath(path)) ||
- this.defaultRoute;
-
- params = this._parseParams(path, route);
-
- route = d.mixin(route, {
- hash : hash,
- params : params
- });
-
- route.handler(params, route);
- },
-
- /**
- * Find the route to use for a given path
- */
- _chooseRoute : function(path) {
- var routeablePath;
-
- if (!routeCache[path]) {
- routeablePath = this._getRouteablePath(path);
- d.forEach(routes, function(r) {
- if (routeablePath.match(r.matcher)) { routeCache[path] = r; }
- });
- }
-
- return routeCache[path];
- },
-
- /**
- * Register a route with the router. Generally only used internally,
- * but exposed for external use as well.
- *
- * @param {Regex|String} path The path pattern to which the route applies
- * @param {Function} fn The handler to use for the route
- * @param {Boolean} defaultRoute Whether the route should be used as
- * the default route.
- */
- _registerRoute : function(path, fn, defaultRoute) {
- var r = {
- path : path,
- handler : fn,
- matcher : this._convertPathToMatcher(path),
- paramNames : this._getParamNames(path)
- };
-
- routes.push(r);
-
- if (defaultRoute) { this.defaultRoute = r; }
- },
-
- /**
- * Given a path, which may be a regex or a string, return a regex
- * that can be used to determine whether to use the associated route
- * to process a given path.
- *
- * @private
- * @param {Regex|String} route
- * @returns Regex for determining whether a path matches the route
- * @type {Regex}
- */
- _convertPathToMatcher : function(route) {
- return d.isString(route) ?
- new RegExp("^" + route.replace(PATH_NAME_MATCHER, PATH_REPLACER) + "$") :
- route;
- },
-
- /**
- * Given a path to which a user navigated, and the route that we've
- * determined should handle the path, return an object containg the parameter
- * name(s) and value(s)
- *
- * @private
- * @param {String} hash The hash to which a user navigated
- * @param {Route} route The route
- * @returns A params object containing parameter keynames and values
- * @type {Object}
- */
- _parseParams : function(hash, route) {
- // TODO
- var parts = hash.split('?'),
- path = parts[0],
- query = parts[1],
- params,
- pathParams,
- _decode = decodeURIComponent;
-
- params = query ? d.mixin({}, d.queryToObject(query)) : {};
-
- if ((pathParams = route.matcher.exec(this._getRouteablePath(path))) !== null) {
- // first match is the full path
- pathParams.shift();
-
- // for each of the matches
- d.forEach(pathParams, function(param, i) {
- // if theres a matching param name
- if (route.paramNames[i]) {
- // set the name to the match
- params[route.paramNames[i]] = _decode(param);
- } else {
- // initialize 'splat'
- if (!params.splat) { params.splat = []; }
- params.splat.push(_decode(param));
- }
- });
- }
-
- return params;
- },
-
- /**
- * Given a path that may contain a query string:
- *
- * /foo/bar?baz=1
- *
- * Return a string that does not contain the query string, so we
- * can use the string for matching to a route.
- *
- * @private
- * @param {String} path
- */
- _getRouteablePath : function(path) {
- return path.split('?')[0];
- },
-
- /**
- * Given a route, which could be a string or a regex, return
- * the parameter names expected by the route as an array.
- *
- * @param {Regex|String} path The path specified for a route
- * @returns An array of parameter names
- * @type Array
- */
- _getParamNames : function(path) {
- var pathMatch,
- paramNames = [];
-
- PATH_NAME_MATCHER.lastIndex = 0;
-
- while ((pathMatch = PATH_NAME_MATCHER.exec(path)) !== null) {
- paramNames.push(pathMatch[1]);
- }
-
- return paramNames;
- },
-
- destroy : function() {
- dojo.forEach(connections, d.disconnect);
- dojo.forEach(subscriptions, d.unsubscribe);
- routes = [];
- }
-});
-
-}(dojo));
-
diff --git a/src/dbp/tests/Router.html b/src/dbp/tests/Router.html
deleted file mode 100644
index ff3dab4..0000000
--- a/src/dbp/tests/Router.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!doctype html>
-<html>
- <head>
- <title>Dojo Unit Test Runner</title>
- <meta http-equiv="REFRESH" content="0;url=../../dojo-release-1.6.0-src/util/doh/runner.html?registerModulePath=dbp,../../dbp;&testModule=dbp.tests.Router">
- </head>
- <body>
- Redirecting to D.O.H runner.
- </body>
-</html>
-
diff --git a/src/dbp/tests/Router.js b/src/dbp/tests/Router.js
deleted file mode 100644
index eeb7cde..0000000
--- a/src/dbp/tests/Router.js
+++ /dev/null
@@ -1,109 +0,0 @@
-dojo.provide('dbp.tests.Router');
-
-dojo.require('dbp.Router');
-
-(function() {
-
-var testVal,
-
- routes = [
- {
- path : '/test',
- handler : function() {
- testVal = '/test';
- },
- defaultRoute : true
- },
- {
- path : '/test2',
- handler : function() {
- testVal = '/test2';
- }
- },
- {
- path : '/basic',
- handler : function() {
- testVal = 'basic';
- }
- },
- {
- path : '/bar/:baz',
- handler : function(params) {
- testVal = params.baz;
- }
- },
- {
- path : '/bar/:baz/:bim',
- handler : function(params) {
- testVal = params.baz + params.bim;
- }
- },
- {
- path : '/bar/:baz/bim/:bop',
- handler : function(params) {
- testVal = params.baz + params.bop;
- }
- },
- {
- path : /\/splat\/(.*)/,
- handler : function(params) {
- testVal = params.splat[0];
- }
- },
- {
- path : /\/splat\/(.*)\/foo\/(.*)/,
- handler : function(params) {
- testVal = params.splat[0] + ':' + params.splat[1];
- }
- }
- ];
-
-doh.register('dbp.Router', [
-
- {
- name : "It should handle a hash if one is set when initialized",
- setUp : function() {
- this.router = new dbp.Router(routes);
- },
- runTest : function() {
- window.location.hash = '#/test';
- this.router.init();
- doh.is(testVal, '/test');
- },
- tearDown : function() {
- this.router.destroy();
- }
- },
-
- {
- name : "It should route the request to the appropriate route with the appropriate parameters",
- setUp : function() {
- this.router = new dbp.Router(routes);
- },
- runTest : function() {
- this.router.go('/bar/test-123');
- doh.is(testVal, 'test-123');
-
- this.router.go('/basic');
- doh.is(testVal, 'basic');
-
- this.router.go('/bar/hello/world');
- doh.is(testVal, 'helloworld');
-
- this.router.go('/bar/testing/bim/123');
- doh.is(testVal, 'testing123');
-
- this.router.go('/splat/1/2/3');
- doh.is(testVal, '1/2/3');
-
- this.router.go('/splat/1/2/3/foo/4/5/6');
- doh.is(testVal, '1/2/3:4/5/6');
- },
- tearDown : function() {
- this.router.destroy();
- }
- }
-
-]);
-
-}());
diff --git a/src/dijit b/src/dijit
index 18f1bb1..ef9e7bf 160000
--- a/src/dijit
+++ b/src/dijit
@@ -1 +1 @@
-Subproject commit 18f1bb1bf1d479aa16a68ff859db7e9759d1711c
+Subproject commit ef9e7bf5df60a8a74f7e7a7eeaf859b9df3b09b6
diff --git a/src/dojo b/src/dojo
index 2e1e84e..2d9bb03 160000
--- a/src/dojo
+++ b/src/dojo
@@ -1 +1 @@
-Subproject commit 2e1e84ecd7829b9f17311ffb621fbfba27653aab
+Subproject commit 2d9bb030ed4587473b6d2e1d338c0a552d783aac
diff --git a/src/dojox b/src/dojox
index 8dc197a..bae5b67 160000
--- a/src/dojox
+++ b/src/dojox
@@ -1 +1 @@
-Subproject commit 8dc197aa90ebdcd5eeace9ebc68d61037989f344
+Subproject commit bae5b676e32877b0a20cdd27fa1f4f2d9a4bb7c4
diff --git a/src/index.html b/src/index.html
index ec067f5..eaed9af 100644
--- a/src/index.html
+++ b/src/index.html
@@ -12,7 +12,7 @@
as shown here, from a global dojoConfig object (which must be defined *before* dojo.js is loaded), or from
a global require object.
- Configuration options for the loader can be viewed at http://livedocs.dojotoolkit.org/loader/amd
+ Configuration options for the loader can be viewed at http://dojotoolkit.org/reference-guide/loader/amd.html
along with a bunch of additional information about its features.
Below, we’re doing the following:
@@ -24,13 +24,15 @@
3. Enabling debugging. (isDebug: 1)
The remainder of Dojo configuration, as well as our application’s instantiation, occurs within
- app/run.js. -->
- <script data-dojo-config="async: 1, tlmSiblingOfDojo: 0, isDebug: 1"
- src="dojo/dojo.js" defer></script>
+ app/run.js.
+
+ NOTE: `build.sh` is responsible for removing the "isDebug" flag when deploying to production. If you modify
+ this flag at all, you will break the build! -->
+ <script data-dojo-config="async: 1, tlmSiblingOfDojo: 0, isDebug: 1" src="dojo/dojo.js"></script>
<!-- Load the loader configuration script. Note that this module ID is hard-coded in build.sh in order to provide
an optimised build that loads as few as one script for the entire application. If you change the name or
location of this module, you will need to update build.sh too. -->
- <script src="app/run.js" defer></script>
+ <script src="app/run.js"></script>
</body>
</html>
\ No newline at end of file
diff --git a/src/server.sh b/src/server.sh
index db785f1..ff4da4f 100755
--- a/src/server.sh
+++ b/src/server.sh
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/usr/bin/env bash
# This is a very simple script that demonstrates how to load a Dojo
# application on the server using Node.js.
-node dojo/dojo.js load=app/run
+node dojo/dojo.js load=app/run $@
\ No newline at end of file
diff --git a/src/util b/src/util
index 859717b..46d6180 160000
--- a/src/util
+++ b/src/util
@@ -1 +1 @@
-Subproject commit 859717b49f74bab670a2d9d94029d65fc2d9a65b
+Subproject commit 46d61804c75d787ba70ff7cd251e341cce8c15dd