예제 #1
0
 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()));
 }
예제 #2
0
  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();
  }
예제 #3
0
 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) + "...";
 }
예제 #4
0
 public String ogTitle(Post post) {
   return post.getTitle();
 }
예제 #5
0
 public String metaDescription(Post post) {
   return post.getSeo() != null ? post.getSeo().getDescription() : null;
 }
예제 #6
0
 public String metaKeywords(Post post) {
   return post.getSeo() != null ? post.getSeo().getKeywords() : null;
 }