|
@@ -309,35 +309,6 @@ module.exports = function(crowi, app) {
|
|
|
})
|
|
})
|
|
|
// look for templates if page not exists
|
|
// look for templates if page not exists
|
|
|
.catch(function(err) {
|
|
.catch(function(err) {
|
|
|
- // use not_found pageTempalte for both a new page with either tempalte and a new page with no templates
|
|
|
|
|
- // pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
-
|
|
|
|
|
- // const lastSlash = originalUrl.lastIndexOf('/');
|
|
|
|
|
- // const templateUrl = `${originalUrl.substr(0, lastSlash)}/@template`;
|
|
|
|
|
-
|
|
|
|
|
- // // @tempate: applicable only to immediate decendants
|
|
|
|
|
- // const getLocalTemplate = Page.findPage(templateUrl)
|
|
|
|
|
- // .then(function(page) {
|
|
|
|
|
- // return Promise.resolve(page.path);
|
|
|
|
|
- // })
|
|
|
|
|
- // .catch(function(err) {
|
|
|
|
|
- // console.log('no @template for you');
|
|
|
|
|
- // return Promise.resolve();
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
- // //FIXME
|
|
|
|
|
- // const rootPageName = originalUrl.replace(/^\/([^\/]*).*$/, '$1');
|
|
|
|
|
-
|
|
|
|
|
- // // _tempate: applicable to all pages under
|
|
|
|
|
- // const getGlobalTemplate = Page.findPage(`/${rootPageName}/_template`)
|
|
|
|
|
- // .then(page => {
|
|
|
|
|
- // return Promise.resolve(page.path);
|
|
|
|
|
- // })
|
|
|
|
|
- // .catch(function(err) {
|
|
|
|
|
- // console.log('no _template for you');
|
|
|
|
|
- // return Promise.resolve();
|
|
|
|
|
- // });
|
|
|
|
|
-
|
|
|
|
|
pageTeamplate = 'customlayout-selector/not_found';
|
|
pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
|
|
|
const lastSlash = originalUrl.lastIndexOf('/');
|
|
const lastSlash = originalUrl.lastIndexOf('/');
|
|
@@ -350,7 +321,6 @@ module.exports = function(crowi, app) {
|
|
|
//@tempate: applicable only to immediate decendants
|
|
//@tempate: applicable only to immediate decendants
|
|
|
const localTemplate = templateFinder(templates, templateUrl, '@');
|
|
const localTemplate = templateFinder(templates, templateUrl, '@');
|
|
|
if (localTemplate) {
|
|
if (localTemplate) {
|
|
|
- console.log('l temp found ', localTemplate.path);
|
|
|
|
|
renderVars.template = localTemplate.revision.body;
|
|
renderVars.template = localTemplate.revision.body;
|
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|
|
|
}
|
|
}
|
|
@@ -359,33 +329,11 @@ module.exports = function(crowi, app) {
|
|
|
//_tempate: applicable to all pages under
|
|
//_tempate: applicable to all pages under
|
|
|
const globalTemplate = globalTemplateFinder(templates, templateUrl);
|
|
const globalTemplate = globalTemplateFinder(templates, templateUrl);
|
|
|
if (globalTemplate) {
|
|
if (globalTemplate) {
|
|
|
- console.log('g temp found ', globalTemplate.path);
|
|
|
|
|
renderVars.template = globalTemplate.revision.body;
|
|
renderVars.template = globalTemplate.revision.body;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return Promise.resolve();
|
|
|
|
|
- })
|
|
|
|
|
- .catch(err => {
|
|
|
|
|
- console.log('no templates found');
|
|
|
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // return Promise.all([getGlobalTemplate, getLocalTemplate])
|
|
|
|
|
- // .then(function(templates) {
|
|
|
|
|
- // const globalTemplate = templates[0];
|
|
|
|
|
- // const localTemplate = templates[1];
|
|
|
|
|
-
|
|
|
|
|
- // if (globalTemplate) {
|
|
|
|
|
- // renderVars.template = globalTemplate.revision.body;
|
|
|
|
|
- // }
|
|
|
|
|
- // else if (localTemplate) {
|
|
|
|
|
- // renderVars.template = localTemplate.revision.body;
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
})
|
|
})
|
|
|
// get list pages
|
|
// get list pages
|
|
|
.then(function() {
|
|
.then(function() {
|
|
@@ -448,14 +396,12 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const globalTemplateFinder = (globalTemplates, path) => {
|
|
const globalTemplateFinder = (globalTemplates, path) => {
|
|
|
- console.log(path);
|
|
|
|
|
const globalTemplate = templateFinder(globalTemplates, path, '_');
|
|
const globalTemplate = templateFinder(globalTemplates, path, '_');
|
|
|
if (globalTemplate) {
|
|
if (globalTemplate) {
|
|
|
return globalTemplate;
|
|
return globalTemplate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (path === '') {
|
|
if (path === '') {
|
|
|
- console.log('default template');
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|