|
|
@@ -104,11 +104,6 @@ export class PageQueryBuilder {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- addConditionToExcludeRedirect() {
|
|
|
- this.query = this.query.and({ redirectTo: null });
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* generate the query to find the pages '{path}/*' and '{path}' self.
|
|
|
* If top page, return without doing anything.
|
|
|
@@ -690,10 +685,6 @@ export const getPageSchema = (crowi) => {
|
|
|
return queryBuilder.query.exec();
|
|
|
};
|
|
|
|
|
|
- pageSchema.statics.findByRedirectTo = function(path) {
|
|
|
- return this.findOne({ redirectTo: path });
|
|
|
- };
|
|
|
-
|
|
|
/**
|
|
|
* find pages that is match with `path` and its descendants
|
|
|
*/
|
|
|
@@ -714,7 +705,6 @@ export const getPageSchema = (crowi) => {
|
|
|
|
|
|
const builder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
builder.addConditionToListWithDescendants(page.path, option);
|
|
|
- builder.addConditionToExcludeRedirect();
|
|
|
|
|
|
// add grant conditions
|
|
|
await addConditionToFilteringByViewerToEdit(builder, user);
|
|
|
@@ -765,9 +755,6 @@ export const getPageSchema = (crowi) => {
|
|
|
const opt = Object.assign({}, option);
|
|
|
const builder = new PageQueryBuilder(this.find({ _id: { $in: ids } }));
|
|
|
|
|
|
- if (excludeRedirect) {
|
|
|
- builder.addConditionToExcludeRedirect();
|
|
|
- }
|
|
|
builder.addConditionToPagenate(opt.offset, opt.limit);
|
|
|
|
|
|
// count
|
|
|
@@ -804,10 +791,6 @@ export const getPageSchema = (crowi) => {
|
|
|
if (!opt.includeTrashed) {
|
|
|
builder.addConditionToExcludeTrashed();
|
|
|
}
|
|
|
- // exclude redirect pages
|
|
|
- if (!opt.includeRedirect) {
|
|
|
- builder.addConditionToExcludeRedirect();
|
|
|
- }
|
|
|
|
|
|
// add grant conditions
|
|
|
await addConditionToFilteringByViewerForList(builder, user, showAnyoneKnowsLink);
|
|
|
@@ -1009,7 +992,6 @@ export const getPageSchema = (crowi) => {
|
|
|
const Page = this;
|
|
|
const Revision = crowi.model('Revision');
|
|
|
const format = options.format || 'markdown';
|
|
|
- const redirectTo = options.redirectTo || null;
|
|
|
const grantUserGroupId = options.grantUserGroupId || null;
|
|
|
|
|
|
// sanitize path
|
|
|
@@ -1031,7 +1013,6 @@ export const getPageSchema = (crowi) => {
|
|
|
page.path = path;
|
|
|
page.creator = user;
|
|
|
page.lastUpdateUser = user;
|
|
|
- page.redirectTo = redirectTo;
|
|
|
page.status = STATUS_PUBLISHED;
|
|
|
|
|
|
await validateAppliedScope(user, grant, grantUserGroupId);
|
|
|
@@ -1077,8 +1058,6 @@ export const getPageSchema = (crowi) => {
|
|
|
const builder = new PageQueryBuilder(this.find());
|
|
|
builder.addConditionToListWithDescendants(parentPage.path);
|
|
|
|
|
|
- builder.addConditionToExcludeRedirect();
|
|
|
-
|
|
|
// add grant conditions
|
|
|
await addConditionToFilteringByViewerToEdit(builder, user);
|
|
|
|
|
|
@@ -1103,29 +1082,6 @@ export const getPageSchema = (crowi) => {
|
|
|
return this.findOneAndRemove({ path }).exec();
|
|
|
};
|
|
|
|
|
|
- /**
|
|
|
- * remove the page that is redirecting to specified `pagePath` recursively
|
|
|
- * ex: when
|
|
|
- * '/page1' redirects to '/page2' and
|
|
|
- * '/page2' redirects to '/page3'
|
|
|
- * and given '/page3',
|
|
|
- * '/page1' and '/page2' will be removed
|
|
|
- *
|
|
|
- * @param {string} pagePath
|
|
|
- */
|
|
|
- pageSchema.statics.removeRedirectOriginPageByPath = async function(pagePath) {
|
|
|
- const redirectPage = await this.findByRedirectTo(pagePath);
|
|
|
-
|
|
|
- if (redirectPage == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // remove
|
|
|
- await this.findByIdAndRemove(redirectPage.id);
|
|
|
- // remove recursive
|
|
|
- await this.removeRedirectOriginPageByPath(redirectPage.path);
|
|
|
- };
|
|
|
-
|
|
|
pageSchema.statics.findListByPathsArray = async function(paths, includeEmpty = false) {
|
|
|
const queryBuilder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
queryBuilder.addConditionToListByPathsArray(paths);
|