Search in sources :

Example 1 with OrchidInternalIndex

use of com.eden.orchid.impl.indexing.OrchidInternalIndex in project Orchid by JavaEden.

the class IndexGenerator method generateIndexFiles.

private void generateIndexFiles() {
    OrchidRootInternalIndex internalIndex = context.getInternalIndex();
    Map<String, OrchidInternalIndex> mappedIndex = internalIndex.getAllIndexedPages();
    OrchidIndex indices = new OrchidInternalIndex("indices");
    // Render an page for each generator's individual index
    mappedIndex.keySet().forEach(key -> {
        OrchidResource resource = new JsonResource(new JSONElement(mappedIndex.get(key).toJSON()), new OrchidReference(context, "meta/" + key + ".index.json"));
        OrchidPage page = new OrchidPage(resource);
        page.renderRaw();
        indices.addToIndex(indices.getOwnKey() + "/" + page.getReference().getPath(), page);
    });
    // Render full composite index page
    OrchidResource compositeIndexResource = new JsonResource(new JSONElement(internalIndex.toJSON()), new OrchidReference(context, "meta/index.json"));
    OrchidPage compositeIndexPage = new OrchidPage(compositeIndexResource);
    compositeIndexPage.renderRaw();
    indices.addToIndex(indices.getOwnKey() + "/" + compositeIndexPage.getReference().getPath(), compositeIndexPage);
    // Render an index of all indices, so individual index pages can be found
    OrchidResource indicesIndexResource = new JsonResource(new JSONElement(indices.toJSON()), new OrchidReference(context, "meta/indices.json"));
    OrchidPage indicesPage = new OrchidPage(indicesIndexResource);
    indicesPage.renderRaw();
}
Also used : OrchidRootInternalIndex(com.eden.orchid.impl.indexing.OrchidRootInternalIndex) OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) OrchidReference(com.eden.orchid.api.theme.pages.OrchidReference) OrchidInternalIndex(com.eden.orchid.impl.indexing.OrchidInternalIndex) JSONElement(com.eden.common.json.JSONElement) OrchidResource(com.eden.orchid.api.resources.resource.OrchidResource) JsonResource(com.eden.orchid.api.resources.resource.JsonResource) OrchidIndex(com.eden.orchid.api.indexing.OrchidIndex)

Example 2 with OrchidInternalIndex

use of com.eden.orchid.impl.indexing.OrchidInternalIndex in project Orchid by JavaEden.

the class OrchidGenerators method indexGenerator.

private void indexGenerator(OrchidGenerator generator) {
    Clog.d("Indexing generator: #{$1}:[#{$2 | className}]", generator.getPriority(), generator);
    List<? extends OrchidPage> generatorPages = generator.startIndexing();
    if (!EdenUtils.isEmpty(generator.getName()) && generatorPages != null && generatorPages.size() > 0) {
        OrchidInternalIndex index = new OrchidInternalIndex(generator.getName());
        for (OrchidPage page : generatorPages) {
            index.addToIndex(generator.getName() + "/" + page.getReference().getPath(), page);
            if (page.getResource() instanceof FreeableResource) {
                ((FreeableResource) page.getResource()).free();
            }
        }
        this.internalIndex.addChildIndex(generator.getName(), index);
    }
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) FreeableResource(com.eden.orchid.api.resources.resource.FreeableResource) OrchidInternalIndex(com.eden.orchid.impl.indexing.OrchidInternalIndex)

Aggregations

OrchidPage (com.eden.orchid.api.theme.pages.OrchidPage)2 OrchidInternalIndex (com.eden.orchid.impl.indexing.OrchidInternalIndex)2 JSONElement (com.eden.common.json.JSONElement)1 OrchidIndex (com.eden.orchid.api.indexing.OrchidIndex)1 FreeableResource (com.eden.orchid.api.resources.resource.FreeableResource)1 JsonResource (com.eden.orchid.api.resources.resource.JsonResource)1 OrchidResource (com.eden.orchid.api.resources.resource.OrchidResource)1 OrchidReference (com.eden.orchid.api.theme.pages.OrchidReference)1 OrchidRootInternalIndex (com.eden.orchid.impl.indexing.OrchidRootInternalIndex)1