Merge branch 'add_redirects' of github.com:sclements/scratch-www into s3

# Conflicts:
#	.eslintrc
#	server/handler.js
This commit is contained in:
Ray Schamp 2016-04-19 16:56:22 -04:00
commit 59227e3272
5 changed files with 17 additions and 7 deletions

View file

@ -20,8 +20,9 @@
"formatMessage": true
},
"ecmaFeatures": {
"jsx": true,
"blockBindings": true
"arrowFunctions": true,
"blockBindings": true,
"jsx": true
},
"plugins": [
"react"

View file

@ -2,8 +2,12 @@
* Constructor
*/
function Handler (route) {
var url = '/' + route.view + '.html';
// Handle redirects
if (route.redirect) {
return (req, res) => { res.redirect(route.redirect); };
}
var url = '/' + route.view + '.html';
return function (req, res, next) {
req.url = url;
next();

View file

@ -16,10 +16,9 @@ app.disable('x-powered-by');
app.use(log());
// Bind routes
for (var routeId in routes) {
var route = routes[routeId];
routes.forEach(route => {
app.get(route.pattern, handler(route));
}
});
app.use(webpackDevMiddleware(compiler));

View file

@ -43,5 +43,9 @@
"pattern": "^/wedo$",
"view": "wedo2",
"title": "LEGO WeDo 2.0"
},
{
"pattern": "/info/donate/",
"redirect": "https://secure.donationpay.org/scratchfoundation/"
}
]

View file

@ -11,7 +11,9 @@ var entry = {
init: './src/init.js'
};
routes.forEach(function (route) {
if (!route.redirect) {
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
}
});
// Config