Search in sources :

Example 1 with IncludePlugin

use of org.markdown4j.server.IncludePlugin in project blogwt by billy1380.

the class StaticPosts method showPosts.

protected void showPosts(List<Post> posts, StringBuffer markup) {
    MarkdownProcessor processor = new MarkdownProcessor();
    processor.registerPlugins(new IncludePlugin());
    String link, body;
    for (Post post : posts) {
        body = "Empty... :imp:";
        if (post.summary != null && post.summary.length() > 0) {
            body = post.summary;
        }
        link = "/#" + PageType.PostDetailPageType.asTargetHistoryToken(PostHelper.getSlug(post));
        markup.append("<div><a href=\"");
        markup.append(link);
        markup.append("\">");
        markup.append(process("##" + post.title));
        markup.append("</a><div><span>");
        markup.append(DateTimeHelper.ago(post.published));
        markup.append("</span> by <img src=\"");
        markup.append(post.author.avatar);
        markup.append("?s=");
        markup.append(UserHelper.AVATAR_HEADER_SIZE);
        markup.append("&default=retro\" /> ");
        markup.append(UserHelper.handle(post.author));
        markup.append("</div><div>");
        markup.append(process(body));
        markup.append("</div><a href=\"");
        markup.append(link);
        markup.append("\">Read More</a></div>");
    }
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) IncludePlugin(org.markdown4j.server.IncludePlugin) MarkdownProcessor(org.markdown4j.server.MarkdownProcessor)

Aggregations

Post (com.willshex.blogwt.shared.api.datatype.Post)1 IncludePlugin (org.markdown4j.server.IncludePlugin)1 MarkdownProcessor (org.markdown4j.server.MarkdownProcessor)1