Exemplo n.º 1
0
 private String renderListOfPosts(Page<Post> page, Model model, String activeCategory) {
   Page<PostView> postViewPage = PostView.pageOf(page, dateFactory);
   List<PostView> posts = postViewPage.getContent();
   model.addAttribute("activeCategory", activeCategory);
   model.addAttribute("categories", PostCategory.values());
   model.addAttribute("posts", posts);
   model.addAttribute("paginationInfo", new PaginationInfo(postViewPage));
   model.addAttribute("disqusShortname", service.getDisqusShortname());
   return "blog/index";
 }
Exemplo n.º 2
0
  @RequestMapping(
      value = "/{year:\\d+}/{month:\\d+}/{day:\\d+}/{slug}",
      method = {GET, HEAD})
  public String showPost(
      @PathVariable String year,
      @PathVariable String month,
      @PathVariable String day,
      @PathVariable String slug,
      Model model) {

    String publicSlug = String.format("%s/%s/%s/%s", year, month, day, slug);
    Post post = service.getPublishedPost(publicSlug);
    model.addAttribute("post", PostView.of(post, dateFactory));
    model.addAttribute("categories", PostCategory.values());
    model.addAttribute("activeCategory", post.getCategory().getDisplayName());
    model.addAttribute("disqusShortname", service.getDisqusShortname());
    return "blog/show";
  }