forked from kriasoft/react-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add server-side rendering with Node.js/Express; big refactoring
- Add Node.js/Express web server (see ./src/server.js) - Remove Flux store base class - Remove PageStore in favor of AppStore - Refactor AppStore to use EventEmitter3 (see ./src/stores/AppStore.js) - Refactor `serve` Gulp task to use nodemon - Add __SERVER__ env variable - Move HTML template for React component(s) to ./src/index.html - Refactor client-side startup script (see ./src/app.js) - Add CHANGE_LOCATION, LOAD_PAGE action types - Add NavigationMixin to be used in the top-level component - Remove Index.js, Privacy.js React components - Add HomePage, ContentPage, NotFoundPage, ErrorPage React components - Replace <Link> with <a> - Remove PageActions, RouteActions in favor of AppActions
- Loading branch information
1 parent
889360b
commit 1a047dc
Showing
38 changed files
with
864 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"globals": { | ||
"require": false, | ||
"__dirname": false, | ||
"__DEV__": false | ||
"__DEV__": false, | ||
"__SERVER__": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* React.js Starter Kit | ||
* Copyright (c) 2014 Konstantin Tarkus (@koistya), KriaSoft LLC. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE.txt file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Dispatcher = require('../core/Dispatcher'); | ||
var ActionTypes = require('../constants/ActionTypes'); | ||
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment'); | ||
var http = require('superagent'); | ||
|
||
module.exports = { | ||
|
||
navigateTo(path) { | ||
if (ExecutionEnvironment.canUseDOM) { | ||
window.history.pushState({}, document.title, path); | ||
} | ||
|
||
Dispatcher.handleViewAction({ | ||
actionType: ActionTypes.CHANGE_LOCATION, path: path | ||
}); | ||
}, | ||
|
||
loadPage(path, cb) { | ||
Dispatcher.handleViewAction({ | ||
actionType: ActionTypes.LOAD_PAGE, path: path | ||
}); | ||
|
||
http.get('/api/page' + path) | ||
.accept('application/json') | ||
.end((err, res) => { | ||
Dispatcher.handleServerAction({ | ||
actionType: ActionTypes.LOAD_PAGE, path: path, err: err, page: res | ||
}); | ||
if (cb) { | ||
cb(); | ||
} | ||
}); | ||
} | ||
|
||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.