Search in sources :

Example 1 with AssetPage

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);
    }
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) OrchidResponse(com.eden.orchid.api.server.OrchidResponse) AssetPage(com.eden.orchid.api.theme.assets.AssetPage)

Aggregations

OrchidResponse (com.eden.orchid.api.server.OrchidResponse)1 AssetPage (com.eden.orchid.api.theme.assets.AssetPage)1 OrchidPage (com.eden.orchid.api.theme.pages.OrchidPage)1