|
@@ -252,6 +252,8 @@ module.exports = function(crowi, app) {
|
|
|
tree: [],
|
|
tree: [],
|
|
|
pageRelatedGroup: null,
|
|
pageRelatedGroup: null,
|
|
|
template: null,
|
|
template: null,
|
|
|
|
|
+ localTemplateExists: false,
|
|
|
|
|
+ globalTemplateExists: false,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
@@ -280,6 +282,13 @@ module.exports = function(crowi, app) {
|
|
|
.then(function(tree) {
|
|
.then(function(tree) {
|
|
|
renderVars.tree = tree;
|
|
renderVars.tree = tree;
|
|
|
})
|
|
})
|
|
|
|
|
+ .then(function() {
|
|
|
|
|
+ return Page.checkIfTemplatesExist(originalPath);
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(function(templateInfo) {
|
|
|
|
|
+ renderVars.localTemplateExists = templateInfo.localTemplateExists;
|
|
|
|
|
+ renderVars.globalTemplateExists = templateInfo.globalTemplateExists;
|
|
|
|
|
+ })
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
return PageGroupRelation.findByPage(renderVars.page);
|
|
return PageGroupRelation.findByPage(renderVars.page);
|
|
|
})
|
|
})
|
|
@@ -434,9 +443,13 @@ module.exports = function(crowi, app) {
|
|
|
function renderPage(pageData, req, res) {
|
|
function renderPage(pageData, req, res) {
|
|
|
// create page
|
|
// create page
|
|
|
if (!pageData) {
|
|
if (!pageData) {
|
|
|
- return res.render('customlayout-selector/not_found', {
|
|
|
|
|
- author: {},
|
|
|
|
|
- page: false,
|
|
|
|
|
|
|
+ Page.findTemplate(getPathFromRequest(req))
|
|
|
|
|
+ .then((template) => {
|
|
|
|
|
+ return res.render('customlayout-selector/not_found', {
|
|
|
|
|
+ author: {},
|
|
|
|
|
+ page: false,
|
|
|
|
|
+ template: template,
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -449,6 +462,8 @@ module.exports = function(crowi, app) {
|
|
|
page: pageData,
|
|
page: pageData,
|
|
|
revision: pageData.revision || {},
|
|
revision: pageData.revision || {},
|
|
|
author: pageData.revision.author || false,
|
|
author: pageData.revision.author || false,
|
|
|
|
|
+ localTemplateExists: false,
|
|
|
|
|
+ globalTemplateExists: false,
|
|
|
};
|
|
};
|
|
|
var userPage = isUserPage(pageData.path);
|
|
var userPage = isUserPage(pageData.path);
|
|
|
var userData = null;
|
|
var userData = null;
|
|
@@ -493,6 +508,12 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
}
|
|
|
}).then(function() {
|
|
}).then(function() {
|
|
|
return interceptorManager.process('beforeRenderPage', req, res, renderVars);
|
|
return interceptorManager.process('beforeRenderPage', req, res, renderVars);
|
|
|
|
|
+ }).then(function() {
|
|
|
|
|
+ return Page.checkIfTemplatesExist(pageData.path)
|
|
|
|
|
+ .then(function(templateInfo) {
|
|
|
|
|
+ renderVars.localTemplateExists = templateInfo.localTemplateExists;
|
|
|
|
|
+ renderVars.globalTemplateExists = templateInfo.globalTemplateExists;
|
|
|
|
|
+ });
|
|
|
}).then(function() {
|
|
}).then(function() {
|
|
|
var defaultPageTeamplate = 'customlayout-selector/page';
|
|
var defaultPageTeamplate = 'customlayout-selector/page';
|
|
|
if (userData) {
|
|
if (userData) {
|
|
@@ -554,7 +575,6 @@ module.exports = function(crowi, app) {
|
|
|
return res.redirect(pagePathUtil.encodePagePath(path) + '/');
|
|
return res.redirect(pagePathUtil.encodePagePath(path) + '/');
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
-
|
|
|
|
|
var fixed = Page.fixToCreatableName(path);
|
|
var fixed = Page.fixToCreatableName(path);
|
|
|
if (fixed !== path) {
|
|
if (fixed !== path) {
|
|
|
debug('fixed page name', fixed);
|
|
debug('fixed page name', fixed);
|