Skip to content
This repository has been archived by the owner on Dec 31, 2017. It is now read-only.

Commit

Permalink
Update to 1.7.1 and 1.7 build profile.
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed Dec 28, 2011
1 parent 3ad813b commit fde4faa
Show file tree
Hide file tree
Showing 25 changed files with 156 additions and 178 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
www/js/dojo-release-1.6.0-src
dist
16 changes: 8 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "src/js/dojo"]
path = src/js/dojo
[submodule "src/dojo"]
path = src/dojo
url = https://github.com/dojo/dojo.git
[submodule "src/js/dijit"]
path = src/js/dijit
[submodule "src/dijit"]
path = src/dijit
url = https://github.com/dojo/dijit.git
[submodule "src/js/dojox"]
path = src/js/dojox
[submodule "src/dojox"]
path = src/dojox
url = https://github.com/dojo/dojox.git
[submodule "src/js/util"]
path = src/js/util
[submodule "src/util"]
path = src/util
url = https://github.com/dojo/util.git
26 changes: 12 additions & 14 deletions util/build.sh → build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,51 @@

set -e

UTILDIR=$(cd $(dirname $0) && pwd)

# Base directory for this entire project
BASEDIR=$(cd "$UTILDIR/.." && pwd)
BASEDIR=$(cd $(dirname $0) && pwd)

# Source directory for unbuilt code
SRCDIR="$BASEDIR/src"

# Directory containing dojo build utilities
TOOLSDIR="$SRCDIR/js/util/buildscripts"
TOOLSDIR="$SRCDIR/util/buildscripts"

# Destination directory for built code
DISTDIR="$BASEDIR/dist"

# Main application package
PACKAGEDIR="$BASEDIR/src/js/app"

# Main application package loader configuration
LOADERCONF="$PACKAGEDIR/run.js"
LOADERCONF="$SRCDIR/app/run.js"

# Main application package build configuration
PROFILE="$SRCDIR/app/app.profile.js"

if [ ! -d "$TOOLSDIR" ]; then
echo "Can't find Dojo build tools -- did you initialise submodules? (git submodule update --init --recursive)"
exit 1
fi

echo "Building application at $PACKAGEDIR."
echo "Building application with $PROFILE to $DISTDIR."

# clean the old distribution files
echo -n "Cleaning old files..."
rm -rf "$DISTDIR"
echo " Done"

cd "$TOOLSDIR"

if which node >/dev/null; then
node ../../dojo/dojo.js load=build --require "$LOADERCONF" --package "$PACKAGEDIR" --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" --package "$PACKAGEDIR" --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
fi

cd "$UTILDIR"
cd "$BASEDIR"

# copy the index.html and make it production-friendly
# copy index.html and make it production-friendly
cp "$SRCDIR/index.html" "$DISTDIR/index.html"
sed -i "s/, *isDebug: *1//" "$DISTDIR/index.html"
sed -i -e :a -re 's/<!--.*?-->//g;/<!--/N;//ba' "$DISTDIR/index.html"

echo "Build complete"
55 changes: 0 additions & 55 deletions profiles/main.profile.js

This file was deleted.

File renamed without changes.
75 changes: 38 additions & 37 deletions src/js/app/app.profile.js → src/app/app.profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

// 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){

// Ensures that our boot script is not transformed by the build system.
return mid in {
'app/run': 1
};
function copyOnly(mid) {
// Ensures that our boot script is not transformed by the build system.
return mid in {
'app/run': 1
};
}

var profile = {
// basePath is relative to the directory containing this profile file; in this case, it is being set to the
// src/js directory, which is the same place as the baseUrl directory in the loader configuration.
basePath: '..',
// 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.
basePath: '..',

// This is the directory within the release directory where built packages will be placed. The release directory
// itself is defined by util/build.sh.
releaseName: 'js',
// itself is defined by util/build.sh.
// releaseName: '',

// Builds a new release.
action: 'release',
Expand All @@ -31,7 +30,7 @@ var profile = {
mini: true,

// Uses Closure Compiler as the JavaScript minifier. This can also be set to "shrinksafe" to use ShrinkSafe.
optimize: 'closure',
optimize: 'shrinksafe',

// Strips all calls to console functions within the code.
stripConsole: 'all',
Expand All @@ -42,15 +41,15 @@ var profile = {

// 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.
// be compiled into a single file.
layers: {
// This is our main application layer. This layer will normally contain most or all of your application code.
'app/main': { include: [ 'app/main' ] },

// 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.
'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.
Expand All @@ -59,27 +58,29 @@ var profile = {
staticHasFeatures: {
},

// 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 false;
}
}
// 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
};
}
}
};
50 changes: 50 additions & 0 deletions src/app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* 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.
*
* 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
* configuration settings or environmental information. Unlike a normal conditional, these branches can be compiled
* away by the build system; see staticHasFeatures in profiles/main.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.
*
* In all cases, whatever function is passed to define() is only invoked once, and the return value is cached.
*
* More information about everything described about the loader throughout this file can be found at
* http://livedocs.dojotoolkit.org/loader/amd.
*/
define([ 'dojo/has', 'require' ], function (has, require) {
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);

// 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();

// And now…
app.dialog.show();
});
}
else {
console.log('Hello from the server!');
}
});
26 changes: 26 additions & 0 deletions src/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +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.",
"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"
}
2 changes: 2 additions & 0 deletions src/js/app/resources/app.css → src/app/resources/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* If you are developing a project that makes use of Dijit widgets, you will probably want to include the two files
* 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.
*/

@import '../../dojo/resources/dojo.css';
Expand Down
19 changes: 12 additions & 7 deletions src/js/app/run.js → src/app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
require({
// The base path for all packages and modules. If you don't provide this, baseUrl defaults to the directory
// that contains dojo.js.
baseUrl: '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.
// 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: [
{ name: 'dojo', location: 'dojo' },
{ name: 'dijit', location: 'dijit' },
{ name: 'dojox', location: 'dojox' },
{ name: 'app', location: 'app' },
{ name: 'dbp', location: 'dbp' }
// 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',

// For reference, this is what a more verbose package declaration looks like.
{ name: 'dbp', location: 'dbp', packageMap: {} }
]
// Require 'app'. This loads the main application file, app/main.js.
}, [ 'app' ]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/dijit
Submodule dijit added at afb02f
1 change: 1 addition & 0 deletions src/dojo
Submodule dojo added at e051bf
1 change: 1 addition & 0 deletions src/dojox
Submodule dojox added at 9097d6
Loading

0 comments on commit fde4faa

Please sign in to comment.