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