All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.sinri.keel.web.http.fastdocs.page.MarkdownCssBuilder Maven / Gradle / Ivy

Go to download

A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.

The newest version!
package io.github.sinri.keel.web.http.fastdocs.page;

import io.vertx.core.Future;
import io.vertx.ext.web.RoutingContext;

import java.io.IOException;
import java.io.InputStream;

/**
 * @since 1.12
 */
public class MarkdownCssBuilder implements FastDocsContentResponder {

    private static String cssFileContent = null;
    private final PageBuilderOptions options;

    public MarkdownCssBuilder(PageBuilderOptions options) {
        this.options = options;
    }

    protected String buildPage() {
        if (cssFileContent == null) {
            InputStream resourceAsStream = MarkdownCssBuilder.class.getClassLoader()
                    .getResourceAsStream("web-fastdocs-css/github-markdown.4.0.0.min.css");
            if (resourceAsStream != null) {
                try {
                    cssFileContent = new String(resourceAsStream.readAllBytes());
                } catch (IOException e) {
                    return "";
                }
            } else {
                return "";
            }
        }
        return cssFileContent;
    }

    @Override
    public void setRoutingContext(RoutingContext ctx) {
        this.options.ctx = ctx;
    }

    @Override
    public Future respond() {
        return this.options.ctx.response()
                .putHeader("Content-Type", "text/css")
                .end(this.buildPage());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy