|
@@ -16,8 +16,6 @@ module.exports = (crowi) => {
|
|
|
const loginRequired = require('../../middlewares/login-required')(crowi, true);
|
|
const loginRequired = require('../../middlewares/login-required')(crowi, true);
|
|
|
const adminRequired = require('../../middlewares/admin-required')(crowi);
|
|
const adminRequired = require('../../middlewares/admin-required')(crowi);
|
|
|
const csrf = require('../../middlewares/csrf')(crowi);
|
|
const csrf = require('../../middlewares/csrf')(crowi);
|
|
|
- const pathUtils = require('growi-commons').pathUtils;
|
|
|
|
|
- const ApiResponse = require('../../util/apiResponse');
|
|
|
|
|
|
|
|
|
|
const Page = crowi.model('Page');
|
|
const Page = crowi.model('Page');
|
|
|
|
|
|
|
@@ -84,37 +82,6 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * GW-3143 edit swagger
|
|
|
|
|
- */
|
|
|
|
|
- router.post('/duplicate', async(req, res) => {
|
|
|
|
|
- const { pageId, pageNameInput } = req.body;
|
|
|
|
|
- let newPagePath = pathUtils.normalizePath(pageNameInput);
|
|
|
|
|
-
|
|
|
|
|
- const page = await Page.findByIdAndViewer(pageId, req.user);
|
|
|
|
|
-
|
|
|
|
|
- if (page == null) {
|
|
|
|
|
- return res.json(ApiResponse.error(`Page '${pageId}' is not found or forbidden`, 'notfound_or_forbidden'));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // check whether path starts slash
|
|
|
|
|
- newPagePath = pathUtils.addHeadingSlash(newPagePath);
|
|
|
|
|
-
|
|
|
|
|
- await page.populateDataToShowRevision();
|
|
|
|
|
- const originTags = await page.findRelatedTagsById();
|
|
|
|
|
-
|
|
|
|
|
- req.body.path = newPagePath;
|
|
|
|
|
- req.body.body = page.revision.body;
|
|
|
|
|
- req.body.grant = page.grant;
|
|
|
|
|
- req.body.grantedUsers = page.grantedUsers;
|
|
|
|
|
- req.body.grantUserGroupId = page.grantedGroup;
|
|
|
|
|
- req.body.pageTags = originTags;
|
|
|
|
|
-
|
|
|
|
|
- // return api.create(req, res);
|
|
|
|
|
- // 以下はダミーです
|
|
|
|
|
- return res.apiv3({});
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
router.get('/duplicate', loginRequired, async(req, res) => {
|
|
router.get('/duplicate', loginRequired, async(req, res) => {
|
|
|
const { path, pageId } = req.query;
|
|
const { path, pageId } = req.query;
|
|
|
const searchWord = new RegExp(`^${path}`);
|
|
const searchWord = new RegExp(`^${path}`);
|