use of com.nixmash.blog.jpa.model.PostMeta in project nixmash-blog by mintster.
the class PermaPostsController method post.
// endregion
@GetMapping(value = "/post/{postName}")
public String post(@PathVariable("postName") String postName, @RequestParam(value = "preview", required = false, defaultValue = "false") Boolean inPreviewMode, Model model, CurrentUser currentUser) throws PostNotFoundException {
Post post = postService.getPost(postName);
Date postCreated = Date.from(post.getPostDate().toInstant());
post.setIsOwner(PostUtils.isPostOwner(currentUser, post.getUserId()));
post.setPostContent(PostUtils.formatPostContent(post));
if (!inPreviewMode) {
if (applicationSettings.getMoreLikeThisDisplay()) {
// Solr must be active and number of postDocs retrieved must not be null
if (postDocService.getMoreLikeThis(post.getPostId()) != null) {
model.addAttribute("moreLikeThisDisplay", true);
model.addAttribute("postId", post.getPostId());
model.addAttribute("moreLikeThisHeading", webUI.getMessage(MORELIKETHIS_HEADING));
}
}
PostMeta postMeta = postService.buildTwitterMetaTagsForDisplay(post);
if (postMeta != null) {
model.addAttribute("twitterMetatags", fmService.getTwitterTemplate(postMeta));
}
}
model.addAttribute("post", post);
model.addAttribute("postCreated", postCreated);
model.addAttribute("shareSiteName", StringUtils.deleteWhitespace(applicationSettings.getSiteName()));
model.addAttribute("shareUrl", String.format("%s/post/%s", applicationSettings.getBaseUrl(), post.getPostName()));
return POSTS_PERMALINK_VIEW;
}
use of com.nixmash.blog.jpa.model.PostMeta in project nixmash-blog by mintster.
the class AdminPostsControllerTests method newPostContainsTwitterCardInfo.
// endregion
// region Post MetaData
@Test
public void newPostContainsTwitterCardInfo() throws Exception {
mvc.perform(addTwitterCardPostRequest("bigtwitter", TwitterCardType.SUMMARY_LARGE_IMAGE, PostDisplayType.POST));
Post post = postService.getPost("my-title-bigtwitter");
assertEquals(post.getPostMeta().getTwitterCardType(), TwitterCardType.SUMMARY_LARGE_IMAGE);
PostMeta postMeta = postService.getPostMetaById(post.getPostId());
assertNotNull(postMeta);
}
use of com.nixmash.blog.jpa.model.PostMeta in project nixmash-blog by mintster.
the class FmServiceTests method twitterSummaryLargeImageTemplate.
@Test
public void twitterSummaryLargeImageTemplate() throws PostNotFoundException {
// H2 Post 10L SolrRama is SUMMARY_LARGE_IMAGE
Post post = postService.getPostById(10L);
PostMeta postMeta = postService.buildTwitterMetaTagsForDisplay(post);
String result = fmService.getTwitterTemplate(postMeta);
assertThat(result, containsString("summary_large_image"));
}
use of com.nixmash.blog.jpa.model.PostMeta in project nixmash-blog by mintster.
the class JsoupServiceImpl method updatePostMeta.
@Override
@Transactional
public PostMeta updatePostMeta(PostDTO postDTO) {
PostMeta postMeta = buildPostMetaToSave(postDTO);
PostMeta updated = postMetaRepository.findByPostId(postDTO.getPostId());
updated.update(postMeta.getTwitterImage(), postMeta.getTwitterCreator(), postMeta.getTwitterDescription(), postMeta.getTwitterCardType());
return updated;
}
use of com.nixmash.blog.jpa.model.PostMeta in project nixmash-blog by mintster.
the class JsoupPostMetaTests method updatePostMeta.
@Test
public void updatePostMeta() throws PostNotFoundException {
String NA = "na";
PostMeta postMeta = postService.getPostMetaById(1L);
assertEquals(postMeta.getTwitterDescription(), NA);
PostDTO postDTO = PostUtils.postToPostDTO(postService.getPostById(1L));
jsoupService.updatePostMeta(postDTO);
postMeta = postService.getPostMetaById(1L);
assertNotEquals(postMeta.getTwitterDescription(), NA);
}
Aggregations