|
|
@@ -234,10 +234,15 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
|
|
|
|
+ var isRedirect = false;
|
|
|
Page.findPage(path, req.user, req.query.revision)
|
|
|
.then(function(page) {
|
|
|
+ debug('Page found', page._id, page.path);
|
|
|
+
|
|
|
// redirect
|
|
|
if (page.redirectTo) {
|
|
|
+ debug(`Redirect to '${page.redirectTo}'`);
|
|
|
+ isRedirect = true;
|
|
|
return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + page.path));
|
|
|
}
|
|
|
|
|
|
@@ -288,12 +293,17 @@ module.exports = function(crowi, app) {
|
|
|
} else {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
- }).catch(function(err) {
|
|
|
- // page not exists
|
|
|
+ })
|
|
|
+ // page not exists
|
|
|
+ .catch(function(err) {
|
|
|
+ debug('Page not found', path);
|
|
|
// change template
|
|
|
pageTeamplate = 'customlayout-selector/not_found';
|
|
|
- }).then(function() {
|
|
|
- return Page.findListByStartWith(path, req.user, queryOptions)
|
|
|
+ })
|
|
|
+ // get list pages
|
|
|
+ .then(function() {
|
|
|
+ if (!isRedirect) {
|
|
|
+ Page.findListByStartWith(path, req.user, queryOptions)
|
|
|
.then(function(pageList) {
|
|
|
if (pageList.length > limit) {
|
|
|
pageList.pop();
|
|
|
@@ -308,14 +318,18 @@ module.exports = function(crowi, app) {
|
|
|
renderVars.pages = pageList;
|
|
|
|
|
|
return Promise.resolve();
|
|
|
+ })
|
|
|
+ .then(function() {
|
|
|
+ return interceptorManager.process('beforeRenderPage', req, res, renderVars);
|
|
|
+ })
|
|
|
+ .then(function() {
|
|
|
+ res.render(req.query.presentation ? 'page_presentation' : pageTeamplate, renderVars);
|
|
|
+ })
|
|
|
+ .catch(function(err) {
|
|
|
+ console.log(err);
|
|
|
+ debug('Error on rendering pageListShowForCrowiPlus', err);
|
|
|
});
|
|
|
- }).then(function() {
|
|
|
- return interceptorManager.process('beforeRenderPage', req, res, renderVars);
|
|
|
- }).then(function() {
|
|
|
- res.render(req.query.presentation ? 'page_presentation' : pageTeamplate, renderVars);
|
|
|
- }).catch(function(err) {
|
|
|
- console.log(err);
|
|
|
- debug('Error on rendering pageListShowForCrowiPlus', err);
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|