use of com.eden.orchid.api.theme.assets.AssetPage in project Orchid by JavaEden.
the class FileController method findPage.
@Override
public OrchidResponse findPage(OrchidContext context, String targetPath) {
List<String> possibleMatches = CollectionsKt.listOf(targetPath, targetPath + "/" + indexFiles[0], targetPath + "/" + indexFiles[1]);
OrchidPage matchedPage = null;
for (String possibleMatch : possibleMatches) {
Stream<OrchidPage> indexedPagesStream = context.getIndex().getAllIndexedPages().values().stream().flatMap(it -> it.getFirst().getAllPages().stream());
Stream<AssetPage> assetPagesStream = context.getAssetManager().getAllAssetPages();
Stream<OrchidPage> allOrchidPagesStream = Stream.concat(indexedPagesStream, assetPagesStream);
OrchidPage page = OrchidExtensionsKt.findPageByServerPath(allOrchidPagesStream, possibleMatch);
if (page != null) {
matchedPage = page;
break;
}
}
if (matchedPage != null) {
return new OrchidResponse(context).page(matchedPage).status(200);
} else {
return findFile(context, targetPath);
}
}
Aggregations