|
@@ -240,6 +240,7 @@ module.exports = function(crowi, app) {
|
|
|
tree: [],
|
|
tree: [],
|
|
|
userRelatedGroups: [],
|
|
userRelatedGroups: [],
|
|
|
pageRelatedGroup: null,
|
|
pageRelatedGroup: null,
|
|
|
|
|
+ template: null,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
@@ -308,57 +309,15 @@ module.exports = function(crowi, app) {
|
|
|
})
|
|
})
|
|
|
// page not exists
|
|
// page not exists
|
|
|
.catch(function(err) {
|
|
.catch(function(err) {
|
|
|
- const pageName = originalUrl.replace(/^\/([^\/]*).*$/, '$1');
|
|
|
|
|
- Page.findPage(`/${pageName}/_template`)
|
|
|
|
|
- .then(function(page) {
|
|
|
|
|
- //new page object and do as when found
|
|
|
|
|
- var templateRevision = page.revision;
|
|
|
|
|
-
|
|
|
|
|
- var templatePage = new Page();
|
|
|
|
|
- templatePage.path = originalUrl;
|
|
|
|
|
- templatePage.creator = req.user;
|
|
|
|
|
- templatePage.lastUpdateUser = req.user;
|
|
|
|
|
- templatePage.createdAt = Date.now();
|
|
|
|
|
- templatePage.updatedAt = Date.now();
|
|
|
|
|
- templatePage.redirectTo = null;
|
|
|
|
|
- templatePage.grant = 1;
|
|
|
|
|
- templatePage.status = 'published';
|
|
|
|
|
- templatePage.grantedUsers = [];
|
|
|
|
|
- templatePage.grantedUsers.push(req.user);
|
|
|
|
|
-
|
|
|
|
|
- renderVars.page = templatePage;
|
|
|
|
|
- renderVars.path = templatePage.path;
|
|
|
|
|
- renderVars.revision = templateRevision;
|
|
|
|
|
- renderVars.author = templatePage.revision.author;
|
|
|
|
|
-
|
|
|
|
|
- // redirect
|
|
|
|
|
- if (page.redirectTo) {
|
|
|
|
|
- debug(`Redirect to '${page.redirectTo}'`);
|
|
|
|
|
- isRedirect = true;
|
|
|
|
|
- return res.redirect(encodeURI(page.redirectTo + '?redirectFrom=' + pagePathUtil.encodePagePath(page.path)));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const rootPageName = originalUrl.replace(/^\/([^\/]*).*$/, '$1');
|
|
|
|
|
+ pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
|
|
|
- renderVars.page = templatePage;
|
|
|
|
|
|
|
+ return Page.findPage(`/${rootPageName}/_template`)
|
|
|
|
|
+ .then(function(page) {
|
|
|
|
|
+ //use not_found template and read template into editor if it exists
|
|
|
|
|
+ renderVars.template = page.revision.body;
|
|
|
|
|
|
|
|
- if (page) {
|
|
|
|
|
- renderVars.path = templatePage.path;
|
|
|
|
|
- renderVars.revision = templateRevision;
|
|
|
|
|
- renderVars.author = templatePage.revision.author;
|
|
|
|
|
-
|
|
|
|
|
- // これいる??
|
|
|
|
|
- return Revision.findRevisionList(page.path, {})
|
|
|
|
|
- .then(function(tree) {
|
|
|
|
|
- renderVars.tree = tree;
|
|
|
|
|
- return Promise.resolve();
|
|
|
|
|
- }).then(function() {
|
|
|
|
|
- return Promise.resolve();
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .catch(function(err) {
|
|
|
|
|
- debug('Page not found', path);
|
|
|
|
|
- // change template
|
|
|
|
|
- pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
|
|
+ return Promise.resolve();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|