|
|
|
@ -32,6 +32,7 @@ class Misc extends Controller {
|
|
|
|
|
|
|
|
|
|
const Page = this.models.get('api:Page')
|
|
|
|
|
const Node = this.models.get('api:Node')
|
|
|
|
|
const Codium = this.models.get('api:Codium')
|
|
|
|
|
|
|
|
|
|
const all_user_page_ids = (await req.user.get_accessible_pages()).map(x => x.UUID)
|
|
|
|
|
const results = []
|
|
|
|
@ -73,6 +74,27 @@ class Misc extends Controller {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const matching_codiums = await Codium.find({
|
|
|
|
|
PageId: { $in: all_user_page_ids },
|
|
|
|
|
$text: { $search: query },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for ( const codium of matching_codiums ) {
|
|
|
|
|
const page = await codium.page
|
|
|
|
|
results.push({
|
|
|
|
|
title: codium.code,
|
|
|
|
|
short_title: `${codium.code.slice(0, snip_length)}${codium.code.length > snip_length ? '...' : ''}`,
|
|
|
|
|
type: 'code',
|
|
|
|
|
id: codium.NodeId,
|
|
|
|
|
associated: {
|
|
|
|
|
title: page.Name,
|
|
|
|
|
short_title: `${page.Name.slice(0, snip_length)}${page.Name.length > snip_length ? '...' : ''}`,
|
|
|
|
|
type: 'page',
|
|
|
|
|
id: page.UUID,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res.api({results})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|