|
@@ -316,20 +316,7 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
|
|
return Page.findAllTemplates(pathList)
|
|
return Page.findAllTemplates(pathList)
|
|
|
.then(templates => {
|
|
.then(templates => {
|
|
|
- //get local template
|
|
|
|
|
- //@tempate: applicable only to immediate decendants
|
|
|
|
|
- const localTemplate = templateFinder(templates, templateUrl, '@');
|
|
|
|
|
-
|
|
|
|
|
- //get global templates
|
|
|
|
|
- //_tempate: applicable to all pages under
|
|
|
|
|
- const globalTemplate = globalTemplateFinder(templates, templateUrl);
|
|
|
|
|
-
|
|
|
|
|
- if (localTemplate) {
|
|
|
|
|
- renderVars.template = localTemplate.revision.body;
|
|
|
|
|
- }
|
|
|
|
|
- else if (globalTemplate) {
|
|
|
|
|
- renderVars.template = globalTemplate.revision.body;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ renderVars.template = templateFinder(templates, templateUrl);
|
|
|
});
|
|
});
|
|
|
})
|
|
})
|
|
|
// get list pages
|
|
// get list pages
|
|
@@ -396,8 +383,16 @@ module.exports = function(crowi, app) {
|
|
|
return findAllAscendantPaths(newPath, pathList);
|
|
return findAllAscendantPaths(newPath, pathList);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const findTemplateByType = (templates, path, type) => {
|
|
|
|
|
+ for (let i = 0; i < templates.length; i++) {
|
|
|
|
|
+ if (templates[i].path === `${path}/${type}template`) {
|
|
|
|
|
+ return templates[i];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const globalTemplateFinder = (globalTemplates, path) => {
|
|
const globalTemplateFinder = (globalTemplates, path) => {
|
|
|
- const globalTemplate = templateFinder(globalTemplates, path, '_');
|
|
|
|
|
|
|
+ const globalTemplate = findTemplateByType(globalTemplates, path, '_');
|
|
|
if (globalTemplate) {
|
|
if (globalTemplate) {
|
|
|
return globalTemplate;
|
|
return globalTemplate;
|
|
|
}
|
|
}
|
|
@@ -410,12 +405,25 @@ module.exports = function(crowi, app) {
|
|
|
return globalTemplateFinder(globalTemplates, newPath);
|
|
return globalTemplateFinder(globalTemplates, newPath);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const templateFinder = (templates, path, type) => {
|
|
|
|
|
- for (let i = 0; i < templates.length; i++) {
|
|
|
|
|
- if (templates[i].path === `${path}/${type}template`) {
|
|
|
|
|
- return templates[i];
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const templateFinder = (templates, templateUrl) => {
|
|
|
|
|
+ let templateBody;
|
|
|
|
|
+
|
|
|
|
|
+ //get local template
|
|
|
|
|
+ //@tempate: applicable only to immediate decendants
|
|
|
|
|
+ const localTemplate = findTemplateByType(templates, templateUrl, '@');
|
|
|
|
|
+
|
|
|
|
|
+ //get global templates
|
|
|
|
|
+ //_tempate: applicable to all pages under
|
|
|
|
|
+ const globalTemplate = globalTemplateFinder(templates, templateUrl);
|
|
|
|
|
+
|
|
|
|
|
+ if (localTemplate) {
|
|
|
|
|
+ templateBody = localTemplate.revision.body;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (globalTemplate) {
|
|
|
|
|
+ templateBody = globalTemplate.revision.body;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return templateBody;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
actions.deletedPageListShow = function(req, res) {
|
|
actions.deletedPageListShow = function(req, res) {
|