|
@@ -245,6 +245,7 @@ module.exports = function(crowi, app) {
|
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
|
|
|
|
|
|
var isRedirect = false;
|
|
var isRedirect = false;
|
|
|
|
|
+ var originalUrl = path;
|
|
|
Page.findPage(path, req.user, req.query.revision)
|
|
Page.findPage(path, req.user, req.query.revision)
|
|
|
.then(function(page) {
|
|
.then(function(page) {
|
|
|
debug('Page found', page._id, page.path);
|
|
debug('Page found', page._id, page.path);
|
|
@@ -262,6 +263,9 @@ module.exports = function(crowi, app) {
|
|
|
renderVars.path = page.path;
|
|
renderVars.path = page.path;
|
|
|
renderVars.revision = page.revision;
|
|
renderVars.revision = page.revision;
|
|
|
renderVars.author = page.revision.author;
|
|
renderVars.author = page.revision.author;
|
|
|
|
|
+ console.log(renderVars.path);
|
|
|
|
|
+ console.log(renderVars.revision);
|
|
|
|
|
+ console.log(renderVars.author);
|
|
|
|
|
|
|
|
return Revision.findRevisionList(page.path, {})
|
|
return Revision.findRevisionList(page.path, {})
|
|
|
.then(function(tree) {
|
|
.then(function(tree) {
|
|
@@ -307,9 +311,20 @@ module.exports = function(crowi, app) {
|
|
|
})
|
|
})
|
|
|
// page not exists
|
|
// page not exists
|
|
|
.catch(function(err) {
|
|
.catch(function(err) {
|
|
|
- debug('Page not found', path);
|
|
|
|
|
- // change template
|
|
|
|
|
- pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
|
|
+ const pageName = originalUrl.replace(/^\/([^/]*).*$/, '$1');
|
|
|
|
|
+ Page.findPage(`/${pageName}/_template`)
|
|
|
|
|
+ .then(function(page) {
|
|
|
|
|
+ console.log('---------------------------template found');
|
|
|
|
|
+ pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(function(err) {
|
|
|
|
|
+ debug('Page not found', path);
|
|
|
|
|
+ console.log('---------------------------not found');
|
|
|
|
|
+ // change template
|
|
|
|
|
+ pageTeamplate = 'customlayout-selector/not_found';
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
// get list pages
|
|
// get list pages
|
|
|
.then(function() {
|
|
.then(function() {
|
|
@@ -514,7 +529,6 @@ module.exports = function(crowi, app) {
|
|
|
var isMarkdown = req.params[0].match(/.+\.md$/) || false;
|
|
var isMarkdown = req.params[0].match(/.+\.md$/) || false;
|
|
|
|
|
|
|
|
res.locals.path = path;
|
|
res.locals.path = path;
|
|
|
-
|
|
|
|
|
Page.findPage(path, req.user, req.query.revision)
|
|
Page.findPage(path, req.user, req.query.revision)
|
|
|
.then(function(page) {
|
|
.then(function(page) {
|
|
|
debug('Page found', page._id, page.path);
|
|
debug('Page found', page._id, page.path);
|
|
@@ -849,6 +863,7 @@ module.exports = function(crowi, app) {
|
|
|
const pagePath = req.query.path || null;
|
|
const pagePath = req.query.path || null;
|
|
|
const pageId = req.query.page_id || null; // TODO: handling
|
|
const pageId = req.query.page_id || null; // TODO: handling
|
|
|
const revisionId = req.query.revision_id || null;
|
|
const revisionId = req.query.revision_id || null;
|
|
|
|
|
+ console.log('-------path-------', req.query.path);
|
|
|
|
|
|
|
|
if (!pageId && !pagePath) {
|
|
if (!pageId && !pagePath) {
|
|
|
return res.json(ApiResponse.error(new Error('Parameter path or page_id is required.')));
|
|
return res.json(ApiResponse.error(new Error('Parameter path or page_id is required.')));
|
|
@@ -856,7 +871,8 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
|
|
let pageFinder;
|
|
let pageFinder;
|
|
|
if (pageId) { // prioritized
|
|
if (pageId) { // prioritized
|
|
|
- pageFinder = Page.findPageByIdAndGrantedUser(pageId, req.user);
|
|
|
|
|
|
|
+ pageFinder = Page.
|
|
|
|
|
+ ByIdAndGrantedUser(pageId, req.user);
|
|
|
}
|
|
}
|
|
|
else if (pagePath) {
|
|
else if (pagePath) {
|
|
|
pageFinder = Page.findPage(pagePath, req.user, revisionId);
|
|
pageFinder = Page.findPage(pagePath, req.user, revisionId);
|