Search in sources :

Example 1 with OrchidReference

use of com.eden.orchid.api.theme.pages.OrchidReference 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 OrchidReference

use of com.eden.orchid.api.theme.pages.OrchidReference in project Orchid by JavaEden.

the class PostsGenerator method buildArchive.

private List<PostArchivePage> buildArchive(String category, List<PostPage> posts) {
    List<PostArchivePage> archivePages = new ArrayList<>();
    int pageSize = 4;
    int pages = (int) Math.ceil(posts.size() / pageSize);
    for (int i = 0; i <= pages; i++) {
        String pageName = (!EdenUtils.isEmpty(category)) ? "archive/" + category + "/" + (i + 1) + ".html" : "archive/" + (i + 1) + ".html";
        OrchidReference pageRef = new OrchidReference(context, pageName);
        pageRef.setUsePrettyUrl(true);
        pageRef.setTitle("Archives (Page " + (i + 1) + ")");
        PostArchivePage page = new PostArchivePage(new StringResource("", pageRef));
        page.setPage(i + 1);
        page.setPageSize(pageSize);
        page.setTotalPages(posts.size());
        if (!EdenUtils.isEmpty(category)) {
            page.setCategory(category);
        }
        archivePages.add(page);
    }
    int i = 0;
    for (PostArchivePage post : archivePages) {
        if (next(posts, i) != null) {
            post.setNext(next(archivePages, i));
        }
        if (previous(posts, i) != null) {
            post.setPrevious(previous(archivePages, i));
        }
        i++;
    }
    return archivePages;
}
Also used : StringResource(com.eden.orchid.api.resources.resource.StringResource) OrchidReference(com.eden.orchid.api.theme.pages.OrchidReference) ArrayList(java.util.ArrayList)

Example 3 with OrchidReference

use of com.eden.orchid.api.theme.pages.OrchidReference in project Orchid by JavaEden.

the class ClassDocParser method getReference.

public OrchidReference getReference(ClassDoc classDoc) {
    OrchidReference ref = new OrchidReference(context, "javadoc/" + classDoc.qualifiedTypeName().replaceAll("\\.", File.separator) + ".html");
    ref.setUsePrettyUrl(true);
    return ref;
}
Also used : OrchidReference(com.eden.orchid.api.theme.pages.OrchidReference)

Aggregations

OrchidReference (com.eden.orchid.api.theme.pages.OrchidReference)3 JSONElement (com.eden.common.json.JSONElement)1 OrchidIndex (com.eden.orchid.api.indexing.OrchidIndex)1 JsonResource (com.eden.orchid.api.resources.resource.JsonResource)1 OrchidResource (com.eden.orchid.api.resources.resource.OrchidResource)1 StringResource (com.eden.orchid.api.resources.resource.StringResource)1 OrchidPage (com.eden.orchid.api.theme.pages.OrchidPage)1 OrchidInternalIndex (com.eden.orchid.impl.indexing.OrchidInternalIndex)1 OrchidRootInternalIndex (com.eden.orchid.impl.indexing.OrchidRootInternalIndex)1 ArrayList (java.util.ArrayList)1