public String title(Post post) { if (post.getSeo() != null && post.getSeo().getTitle() != null) { return post.getSeo().getTitle(); } Blog blog = blogService.readBlogById(Blog.DEFAULT_ID); return String.format( "%s | %s", post.getTitle(), blog.getTitle(processingContext.getContext().getLocale().getLanguage())); }
public String body(Post post) { if (!StringUtils.hasText(post.getBody())) { return null; } // Blog blog = blogService.readBlogById(Blog.DEFAULT_ID); Document document = Jsoup.parse(post.getBody()); Elements elements = document.select("img"); for (Element element : elements) { String src = element.attr("src"); if (src.startsWith(wallRideProperties.getMediaUrlPrefix())) { String style = element.attr("style"); Pattern pattern = Pattern.compile("width: ([0-9]+)px;"); Matcher matcher = pattern.matcher(element.attr("style")); if (matcher.find()) { String replaced = src + "?w=" + matcher.group(1); element.attr("src", replaced); } } } return document.body().html(); }
public String summary(Post post, int length) { Document document = Jsoup.parse(post.getBody()); String summary = document.text(); if (!StringUtils.hasText(summary)) { return summary; } summary = summary.replaceAll("<.+?>", ""); if (!StringUtils.hasText(summary)) { return summary; } if (summary.length() <= length) { return summary; } return summary.substring(0, length) + "..."; }
public String ogTitle(Post post) { return post.getTitle(); }
public String metaDescription(Post post) { return post.getSeo() != null ? post.getSeo().getDescription() : null; }
public String metaKeywords(Post post) { return post.getSeo() != null ? post.getSeo().getKeywords() : null; }