forked from freeCodeCamp/freeCodeCamp
-
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.
- Loading branch information
Berkeley Martinez
authored and
Berkeley Martinez
committed
Jul 23, 2015
1 parent
05c6dcd
commit a5e7009
Showing
19 changed files
with
46,917 additions
and
68 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"stage": 0 | ||
} |
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,25 @@ | ||
import Rx from 'rx'; | ||
import React from 'react'; | ||
import { Route, Router } from 'react-router'; | ||
|
||
// components | ||
import App from './App.jsx'; | ||
import Jobs from './routes/Jobs'; | ||
import NotFound from './components/NotFound'; | ||
|
||
const router$ = Rx.Observable.fromNodeCallback(Router.run, Router); | ||
|
||
export const routes = ( | ||
<Route handler={ App }> | ||
<Route | ||
component={ Jobs } | ||
path='/jobs' /> | ||
<Route | ||
component={ NotFound } | ||
path='*' /> | ||
</Route> | ||
); | ||
|
||
export default function app$(location) { | ||
return router$(routes, location); | ||
} |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
import React from 'react'; | ||
|
||
export default class extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
static displayName = 'NotFound' | ||
static propTypes = {} | ||
componentDidMount() { | ||
} | ||
render() { | ||
return null; | ||
} | ||
} |
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,57 @@ | ||
// appFactory is an es6 module | ||
var debug = require('debug')('freecc:servereact'); | ||
var app$ = require('../common/app/app-stream.jsx').default; | ||
var Cat = require('thundercats').Cat; | ||
|
||
var routes = [ | ||
'/jobs' | ||
]; | ||
|
||
module.exports = function(app) { | ||
var router = app.Router(); | ||
|
||
routes.forEach(function(route) { | ||
router.get(route, serveReactApp); | ||
}); | ||
|
||
app.use(router); | ||
|
||
function serveReactApp(req, res, next) { | ||
var fcc = new Cat(); | ||
var decodedUrl = decodeURI(req.path); | ||
|
||
// returns a router wrapped app | ||
app$(decodedUrl) | ||
// if react-router does not find a route send down the chain | ||
.filter(function(data) { | ||
var state = data.state; | ||
// this may not work with react-router 1.0.0 | ||
var notFound = state.routes.some(route => route.isNotFound); | ||
if (notFound) { | ||
debug('tried to find %s but got 404', state.path); | ||
next(); | ||
} | ||
return !notFound; | ||
}) | ||
.flatMap(function(app) { | ||
// call thundercats renderToString | ||
// prefetches data and sets up it up for current state | ||
return fcc.renderToString(app); | ||
}) | ||
// makes sure we only get one onNext and closes subscription | ||
.firstOrDefault() | ||
.flatMap(function(dats) { | ||
debug('react rendered'); | ||
res.expose(dats.data, 'data'); | ||
// now render jade file with markup injected from react | ||
return res.render$('layout-react', { markup: dats.markup }); | ||
}) | ||
.subscribe( | ||
function(markup) { | ||
debug('jade rendered'); | ||
res.send(markup); | ||
}, | ||
next | ||
); | ||
} | ||
}; |
Oops, something went wrong.