Example #1
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";
  }