Search in sources :

Example 1 with OrchidPage

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

the class HomepageGenerator method startIndexing.

@Override
public List<? extends OrchidPage> startIndexing() {
    List<OrchidPage> pages = new ArrayList<>();
    OrchidResource resource = new StringResource(context, "index.twig", "");
    OrchidPage page = new OrchidPage(resource);
    page.getReference().setTitle("Home");
    page.setType("frontPage");
    page.addComponent("readme", ReadmeComponent.class);
    page.addComponent("license", LicenseComponent.class);
    pages.add(page);
    return pages;
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) StringResource(com.eden.orchid.api.resources.resource.StringResource) OrchidResource(com.eden.orchid.api.resources.resource.OrchidResource) ArrayList(java.util.ArrayList)

Example 2 with OrchidPage

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

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

the class OrchidRootInternalIndex method addChildIndex.

public void addChildIndex(String key, OrchidInternalIndex index) {
    allIndexedPages.put(key, index);
    List<OrchidPage> indexPages = index.getAllPages();
    for (OrchidPage page : indexPages) {
        this.addToIndex(page.getReference().getPath(), page);
    }
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage)

Example 4 with OrchidPage

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

the class OrchidIndex method fromJSON.

public static OrchidIndex fromJSON(OrchidContext context, JSONObject source) {
    OrchidExternalIndex index = new OrchidExternalIndex(source.getString("ownKey"));
    if (source.has("ownPages")) {
        JSONArray ownPagesJson = source.getJSONArray("ownPages");
        List<OrchidPage> ownPages = new ArrayList<>();
        for (int i = 0; i < ownPagesJson.length(); i++) {
            OrchidPage externalPage = OrchidPage.fromJSON(context, ownPagesJson.getJSONObject(i));
            ownPages.add(externalPage);
        }
        index.ownPages = ownPages;
    }
    if (source.has("childrenPages")) {
        JSONObject childrenPagesJson = source.getJSONObject("childrenPages");
        Map<String, OrchidIndex> childrenPages = new HashMap<>();
        for (String key : childrenPagesJson.keySet()) {
            OrchidIndex childIndex = OrchidIndex.fromJSON(context, childrenPagesJson.getJSONObject(key));
            childrenPages.put(key, childIndex);
        }
        index.childrenPages = childrenPages;
    }
    return index;
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) OrchidExternalIndex(com.eden.orchid.impl.indexing.OrchidExternalIndex)

Example 5 with OrchidPage

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

the class Theme method styles.

public String styles() {
    String styles = "<!-- start:inject styles -->";
    for (OrchidPage style : context.getIndex().find("assets/css")) {
        styles += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + style.getLink() + "\"/>";
    }
    styles += "<!-- end:inject styles -->";
    return styles;
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage)

Aggregations

OrchidPage (com.eden.orchid.api.theme.pages.OrchidPage)22 OrchidResource (com.eden.orchid.api.resources.resource.OrchidResource)7 HashMap (java.util.HashMap)7 OrchidContext (com.eden.orchid.api.OrchidContext)6 ArrayList (java.util.ArrayList)5 TemplateTag (com.eden.orchid.api.compilers.TemplateTag)4 StringResource (com.eden.orchid.api.resources.resource.StringResource)4 OrchidResponse (com.eden.orchid.api.server.OrchidResponse)4 OrchidReference (com.eden.orchid.api.theme.pages.OrchidReference)4 PebbleWrapperTemplateTag (com.eden.orchid.impl.compilers.pebble.PebbleWrapperTemplateTag)4 Map (java.util.Map)4 JSONArray (org.json.JSONArray)4 JSONObject (org.json.JSONObject)3 TemplateFunction (com.eden.orchid.api.compilers.TemplateFunction)2 AssetPage (com.eden.orchid.api.theme.assets.AssetPage)2 OrchidInternalIndex (com.eden.orchid.impl.indexing.OrchidInternalIndex)2 SafeString (com.mitchellbosecke.pebble.extension.escaper.SafeString)2 Clog (com.caseyjbrooks.clog.Clog)1 JSONElement (com.eden.common.json.JSONElement)1 EdenPair (com.eden.common.util.EdenPair)1