use of com.nixmash.blog.jsoup.dto.JsoupPostDTO in project nixmash-blog by mintster.
the class JsoupServiceImpl method getJsoupPostDTO.
private JsoupPostDTO getJsoupPostDTO(PostDTO postDTO) {
Document doc = Jsoup.parse(postDTO.getPostContent());
JsoupPostDTO jsoupPostDTO = jsoupPostParser.parse(doc);
if (jsoupPostDTO.hasImages()) {
String imageUrl = jsoupPostDTO.getImagesInContent().get(0).getSrc();
try {
jsoupPostDTO.setTwitterImagePath(JsoupUtil.removeBaseUri(imageUrl));
} catch (MalformedURLException e) {
jsoupPostDTO.setTwitterImagePath(applicationSettings.getTwitterImage());
}
} else
jsoupPostDTO.setTwitterImagePath(getTwitterImage(postDTO));
jsoupPostDTO.setTwitterDescription(JsoupUtil.getTwitterDescription(jsoupPostDTO.getBodyText()));
return jsoupPostDTO;
}
use of com.nixmash.blog.jsoup.dto.JsoupPostDTO in project nixmash-blog by mintster.
the class JsoupServiceImpl method buildPostMetaToSave.
private PostMeta buildPostMetaToSave(PostDTO postDTO) {
if (!postDTO.getTwitterCardType().equals(TwitterCardType.NONE)) {
String twitterCreator = applicationSettings.getTwitterCreator();
JsoupPostDTO jsoupPostDTO = getJsoupPostDTO(postDTO);
String twitterImage = jsoupPostDTO.getTwitterImagePath();
String twitterDescription = jsoupPostDTO.getTwitterDescription();
return PostMeta.getUpdated(postDTO.getTwitterCardType(), twitterImage, twitterDescription).twitterCreator(twitterCreator).postId(postDTO.getPostId()).build();
} else
return PostMeta.getEmpty(postDTO.getPostId(), TwitterCardType.NONE).build();
}
Aggregations