|
|
@@ -146,16 +146,12 @@ module.exports = function(crowi, app) {
|
|
|
const ApiResponse = require('../util/apiResponse');
|
|
|
const getToday = require('../util/getToday');
|
|
|
|
|
|
- const { configManager, slackNotificationService } = crowi;
|
|
|
+ const { slackNotificationService } = crowi;
|
|
|
const interceptorManager = crowi.getInterceptorManager();
|
|
|
const globalNotificationService = crowi.getGlobalNotificationService();
|
|
|
|
|
|
const actions = {};
|
|
|
|
|
|
- const PORTAL_STATUS_NOT_EXISTS = 0;
|
|
|
- const PORTAL_STATUS_EXISTS = 1;
|
|
|
- const PORTAL_STATUS_FORBIDDEN = 2;
|
|
|
-
|
|
|
// register page events
|
|
|
|
|
|
const pageEvent = crowi.event('page');
|
|
|
@@ -342,27 +338,17 @@ module.exports = function(crowi, app) {
|
|
|
const portalPath = pathUtils.addTrailingSlash(getPathFromRequest(req));
|
|
|
const revisionId = req.query.revision;
|
|
|
|
|
|
- // check whether this page has portal page
|
|
|
- const portalPageStatus = await getPortalPageState(portalPath, req.user);
|
|
|
-
|
|
|
- let view = 'customlayout-selector/page_list';
|
|
|
+ const view = 'customlayout-selector/page_list';
|
|
|
const renderVars = { path: portalPath };
|
|
|
|
|
|
- if (portalPageStatus === PORTAL_STATUS_FORBIDDEN) {
|
|
|
- // inject to req
|
|
|
- req.isForbidden = true;
|
|
|
- view = 'customlayout-selector/forbidden';
|
|
|
- }
|
|
|
- else if (portalPageStatus === PORTAL_STATUS_EXISTS) {
|
|
|
- let portalPage = await Page.findByPathAndViewer(portalPath, req.user);
|
|
|
- portalPage.initLatestRevisionField(revisionId);
|
|
|
+ let portalPage = await Page.findByPathAndViewer(portalPath, req.user);
|
|
|
+ portalPage.initLatestRevisionField(revisionId);
|
|
|
|
|
|
- // populate
|
|
|
- portalPage = await portalPage.populateDataToShowRevision();
|
|
|
+ // populate
|
|
|
+ portalPage = await portalPage.populateDataToShowRevision();
|
|
|
|
|
|
- addRendarVarsForPage(renderVars, portalPage);
|
|
|
- await addRenderVarsForSlack(renderVars, portalPage);
|
|
|
- }
|
|
|
+ addRendarVarsForPage(renderVars, portalPage);
|
|
|
+ await addRenderVarsForSlack(renderVars, portalPage);
|
|
|
|
|
|
const limit = 50;
|
|
|
const offset = parseInt(req.query.offset) || 0;
|
|
|
@@ -427,25 +413,6 @@ module.exports = function(crowi, app) {
|
|
|
return channels;
|
|
|
};
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param {string} path
|
|
|
- * @param {User} user
|
|
|
- * @returns {number} PORTAL_STATUS_NOT_EXISTS(0) or PORTAL_STATUS_EXISTS(1) or PORTAL_STATUS_FORBIDDEN(2)
|
|
|
- */
|
|
|
- async function getPortalPageState(path, user) {
|
|
|
- const portalPath = Page.addSlashOfEnd(path);
|
|
|
- const page = await Page.findByPathAndViewer(portalPath, user);
|
|
|
-
|
|
|
- if (page == null) {
|
|
|
- // check the page is forbidden or just does not exist.
|
|
|
- const isForbidden = await Page.count({ path: portalPath }) > 0;
|
|
|
- return isForbidden ? PORTAL_STATUS_FORBIDDEN : PORTAL_STATUS_NOT_EXISTS;
|
|
|
- }
|
|
|
- return PORTAL_STATUS_EXISTS;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
actions.showTopPage = function(req, res) {
|
|
|
return showPageListForCrowiBehavior(req, res);
|
|
|
};
|
|
|
@@ -455,16 +422,9 @@ module.exports = function(crowi, app) {
|
|
|
*/
|
|
|
/* eslint-disable no-else-return */
|
|
|
actions.showPageWithEndOfSlash = function(req, res, next) {
|
|
|
- const behaviorType = configManager.getConfig('crowi', 'customize:behavior');
|
|
|
-
|
|
|
- if (behaviorType === 'crowi') {
|
|
|
- return showPageListForCrowiBehavior(req, res, next);
|
|
|
- }
|
|
|
- else {
|
|
|
- const path = getPathFromRequest(req); // end of slash should be omitted
|
|
|
- // redirect and showPage action will be triggered
|
|
|
- return res.redirect(path);
|
|
|
- }
|
|
|
+ const path = getPathFromRequest(req); // end of slash should be omitted
|
|
|
+ // redirect and showPage action will be triggered
|
|
|
+ return res.redirect(path);
|
|
|
};
|
|
|
/* eslint-enable no-else-return */
|
|
|
|
|
|
@@ -478,20 +438,6 @@ module.exports = function(crowi, app) {
|
|
|
if (req.query.presentation) {
|
|
|
return showPageForPresentation(req, res, next);
|
|
|
}
|
|
|
-
|
|
|
- const behaviorType = configManager.getConfig('crowi', 'customize:behavior');
|
|
|
-
|
|
|
- // check whether this page has portal page
|
|
|
- if (behaviorType === 'crowi') {
|
|
|
- const portalPagePath = pathUtils.addTrailingSlash(getPathFromRequest(req));
|
|
|
- const hasPortalPage = await Page.count({ path: portalPagePath }) > 0;
|
|
|
-
|
|
|
- if (hasPortalPage) {
|
|
|
- logger.debug('The portal page is found', portalPagePath);
|
|
|
- return res.redirect(encodeURI(`${portalPagePath}?redirectFrom=${pathUtils.encodePagePath(req.path)}`));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// delegate to showPageForGrowiBehavior
|
|
|
return showPageForGrowiBehavior(req, res, next);
|
|
|
};
|
|
|
@@ -501,16 +447,8 @@ module.exports = function(crowi, app) {
|
|
|
*/
|
|
|
/* eslint-disable no-else-return */
|
|
|
actions.trashPageListShowWrapper = function(req, res) {
|
|
|
- const behaviorType = configManager.getConfig('crowi', 'customize:behavior');
|
|
|
-
|
|
|
- if (behaviorType === 'crowi') {
|
|
|
- // Crowi behavior for '/trash/*'
|
|
|
- return actions.deletedPageListShow(req, res);
|
|
|
- }
|
|
|
- else {
|
|
|
- // redirect to '/trash'
|
|
|
- return res.redirect('/trash');
|
|
|
- }
|
|
|
+ // redirect to '/trash'
|
|
|
+ return res.redirect('/trash');
|
|
|
};
|
|
|
/* eslint-enable no-else-return */
|
|
|
|
|
|
@@ -519,16 +457,8 @@ module.exports = function(crowi, app) {
|
|
|
*/
|
|
|
/* eslint-disable no-else-return */
|
|
|
actions.trashPageShowWrapper = function(req, res) {
|
|
|
- const behaviorType = configManager.getConfig('crowi', 'customize:behavior');
|
|
|
-
|
|
|
- if (behaviorType === 'crowi') {
|
|
|
- // redirect to '/trash/'
|
|
|
- return res.redirect('/trash/');
|
|
|
- }
|
|
|
- else {
|
|
|
- // Crowi behavior for '/trash/*'
|
|
|
- return actions.deletedPageListShow(req, res);
|
|
|
- }
|
|
|
+ // Crowi behavior for '/trash/*'
|
|
|
+ return actions.deletedPageListShow(req, res);
|
|
|
};
|
|
|
/* eslint-enable no-else-return */
|
|
|
|
|
|
@@ -537,16 +467,8 @@ module.exports = function(crowi, app) {
|
|
|
*/
|
|
|
/* eslint-disable no-else-return */
|
|
|
actions.deletedPageListShowWrapper = function(req, res) {
|
|
|
- const behaviorType = configManager.getConfig('crowi', 'customize:behavior');
|
|
|
-
|
|
|
- if (behaviorType === 'crowi') {
|
|
|
- // Crowi behavior for '/trash/*'
|
|
|
- return actions.deletedPageListShow(req, res);
|
|
|
- }
|
|
|
- else {
|
|
|
- const path = `/trash${getPathFromRequest(req)}`;
|
|
|
- return res.redirect(path);
|
|
|
- }
|
|
|
+ const path = `/trash${getPathFromRequest(req)}`;
|
|
|
+ return res.redirect(path);
|
|
|
};
|
|
|
/* eslint-enable no-else-return */
|
|
|
|