use of org.markdown4j.server.MarkdownProcessor in project blogwt by billy1380.
the class FeedServlet method getFeed.
protected SyndFeed getFeed(HttpServletRequest request) throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
String url = ServletHelper.constructBaseUrl(request);
feed.setTitle(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.TITLE).value);
feed.setLink(url + "/feed");
feed.setDescription(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.EXTENDED_TITLE).value);
List<Post> posts;
Pager pager = PagerHelper.createDefaultPager();
List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry;
SyndContent description;
MarkdownProcessor processor = new MarkdownProcessor();
do {
posts = PostServiceProvider.provide().getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
if (posts != null) {
PagerHelper.moveForward(pager);
for (Post post : posts) {
entry = new SyndEntryImpl();
entry.setTitle(post.title);
entry.setLink(url + "/#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug));
entry.setPublishedDate(post.published);
description = new SyndContentImpl();
description.setType("text/HTML");
description.setValue(processor.process(post.summary));
entry.setDescription(description);
entries.add(entry);
}
}
} while (posts != null && posts.size() >= pager.count.intValue());
feed.setEntries(entries);
return feed;
}
use of org.markdown4j.server.MarkdownProcessor 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>");
}
}
Aggregations