mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-29 10:36:42 -05:00
Merge branch 'add_redirects' of github.com:sclements/scratch-www into s3
# Conflicts: # .eslintrc # server/handler.js
This commit is contained in:
commit
59227e3272
5 changed files with 17 additions and 7 deletions
|
@ -20,8 +20,9 @@
|
||||||
"formatMessage": true
|
"formatMessage": true
|
||||||
},
|
},
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
"jsx": true,
|
"arrowFunctions": true,
|
||||||
"blockBindings": true
|
"blockBindings": true,
|
||||||
|
"jsx": true
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"react"
|
"react"
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function Handler (route) {
|
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) {
|
return function (req, res, next) {
|
||||||
req.url = url;
|
req.url = url;
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -16,10 +16,9 @@ app.disable('x-powered-by');
|
||||||
app.use(log());
|
app.use(log());
|
||||||
|
|
||||||
// Bind routes
|
// Bind routes
|
||||||
for (var routeId in routes) {
|
routes.forEach(route => {
|
||||||
var route = routes[routeId];
|
|
||||||
app.get(route.pattern, handler(route));
|
app.get(route.pattern, handler(route));
|
||||||
}
|
});
|
||||||
|
|
||||||
app.use(webpackDevMiddleware(compiler));
|
app.use(webpackDevMiddleware(compiler));
|
||||||
|
|
||||||
|
|
|
@ -43,5 +43,9 @@
|
||||||
"pattern": "^/wedo$",
|
"pattern": "^/wedo$",
|
||||||
"view": "wedo2",
|
"view": "wedo2",
|
||||||
"title": "LEGO WeDo 2.0"
|
"title": "LEGO WeDo 2.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "/info/donate/",
|
||||||
|
"redirect": "https://secure.donationpay.org/scratchfoundation/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,7 +11,9 @@ var entry = {
|
||||||
init: './src/init.js'
|
init: './src/init.js'
|
||||||
};
|
};
|
||||||
routes.forEach(function (route) {
|
routes.forEach(function (route) {
|
||||||
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
|
if (!route.redirect) {
|
||||||
|
entry[route.view] = './src/views/' + route.view + '/' + route.view + '.jsx';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
|
|
Loading…
Reference in a new issue