Search in sources :

Example 1 with AdminTheme

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

the class AdminAssetResponse method getResponse.

static OrchidResponse getResponse(OrchidContext context, File targetFile, String targetPath) {
    AdminTheme theme = context.getAdminTheme();
    OrchidResource res = theme.getResourceSource().getResourceEntry(context, targetPath);
    String mimeType = StaticFileResponse.mimeTypes.getOrDefault(FilenameUtils.getExtension(targetFile.getName()), "text/plain");
    Clog.i("Rendering admin File: #{$1}", targetPath);
    if (res != null) {
        if (context.isBinaryExtension(FilenameUtils.getExtension(targetFile.getName()))) {
            InputStream stream = res.getContentStream();
            return new OrchidResponse(context).contentStream(stream).mimeType(mimeType);
        } else {
            OrchidPage page = new OrchidPage(res, RenderService.RenderMode.TEMPLATE, "", null);
            return new OrchidResponse(context).mimeType(mimeType).content(page.getContent()).mimeType(mimeType);
        }
    }
    return null;
}
Also used : OrchidPage(com.eden.orchid.api.theme.pages.OrchidPage) OrchidResponse(com.eden.orchid.api.server.OrchidResponse) InputStream(java.io.InputStream) OrchidResource(com.eden.orchid.api.resources.resource.OrchidResource) AdminTheme(com.eden.orchid.api.theme.AdminTheme)

Aggregations

OrchidResource (com.eden.orchid.api.resources.resource.OrchidResource)1 OrchidResponse (com.eden.orchid.api.server.OrchidResponse)1 AdminTheme (com.eden.orchid.api.theme.AdminTheme)1 OrchidPage (com.eden.orchid.api.theme.pages.OrchidPage)1 InputStream (java.io.InputStream)1