Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 05_requirejs/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ define(function(require) {
/**
* Client and server.
*
* `postInitialize` is called on app initialize, both on the client and server.
* `initialize` is called on app initialize, both on the client and server.
* On the server, an app is instantiated once for each request, and in the
* client, it's instantiated once on page load.
*
* This is a good place to initialize any code that needs to be available to
* app on both client and server.
*/
postInitialize: function() {
initialize: function() {
/**
* Register our Handlebars helpers.
*
Expand Down
2 changes: 1 addition & 1 deletion 05_requirejs/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define(function(require) {
Router.prototype = Object.create(BaseClientRouter.prototype);
Router.prototype.constructor = BaseClientRouter;

Router.prototype.postInitialize = function() {
Router.prototype.initialize = function() {
this.on('action:start', this.trackImpression, this);
};

Expand Down
2 changes: 1 addition & 1 deletion 05_requirejs/app/views/app_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(function(require) {
var $body = $('body');

return BaseAppView.extend({
postInitialize: function() {
initialize: function() {
this.app.on('change:loading', function(app, loading) {
$body.toggleClass('loading', loading);
}, this);
Expand Down
25 changes: 13 additions & 12 deletions 05_requirejs/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
var express = require('express')
, rendr = require('rendr')
, app = express();

/**
* Initialize Express middleware stack.
*/
app.use(express.compress());
app.use(express.static(__dirname + '/public'));
app.use(express.logger());
app.use(express.bodyParser());
var express = require('express')
, rendr = require('rendr')
, app = express()
, bodyParser = require('body-parser')
, compression = require('compression')
, serveStatic = require('serve-static');

/**
* In this simple example, the DataAdapter config, which specifies host, port, etc. of the API
Expand All @@ -34,6 +29,12 @@ var server = rendr.createServer({
dataAdapterConfig: dataAdapterConfig
});

server.configure(function (expressApp) {
expressApp.use(compression());
expressApp.use(serveStatic(__dirname + '/public'));
expressApp.use(bodyParser.json());
});

/**
* To mount Rendr, which owns its own Express instance for better encapsulation,
* simply add `server` as a middleware onto your Express app.
Expand All @@ -42,7 +43,7 @@ var server = rendr.createServer({
*
* app.use('/my_cool_app', server);
*/
app.use(server);
app.use(server.expressApp);

/**
* Start the Express server.
Expand Down
28 changes: 16 additions & 12 deletions 05_requirejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@
"postupdate": "test -f ../../package.json && npm install ../../ || echo"
},
"dependencies": {
"express": "~3",
"underscore": "~1.5.2",
"async": "~0.2.9",
"rendr-handlebars": "0.2.0",
"rendr": "0.5.0",
"body-parser": "^1.12.0",
"compression": "^1.4.1",
"express": "^4.12.0",
"jquery": "^2.1.3",
"rendr": "1.0.x",
"rendr-handlebars": "^1.0.0",
"serve-static": "^1.9.1",
"underscore": "^1.8.2",
"amdefine": "~0.1.0"
},
"devDependencies": {
"requirejs": "~2.1.10",
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.3.1",
"grunt-contrib-stylus": "~0.5.0",
"grunt-contrib-handlebars": "~0.5.11",
"requirejs": "~2.1.15",
"grunt": "~0.4.5",
"grunt-contrib-watch": "~0.6.1",
"grunt-contrib-stylus": "~0.20.0",
"grunt-contrib-handlebars": "~0.9.3",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-rendr-requirejs": "~0.1.1",
"grunt-rendr-requirejs": "~1.0.0",
"nodemon": "~0.7.6",
"mocha": "~1.9.0",
"should": "~1.2.2"
"should": "~1.2.2",
"async": "~0.9.0"
},
"engines": {
"node": ">=0.8"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be 0.10?

Expand Down