private String path(UriComponentsBuilder builder, Page page, boolean encode) { Map<String, Object> params = new HashMap<>(); PageTree pageTree = (PageTree) processingContext.getContext().getVariables().get("PAGE_TREE_ALL"); // PageTree pageTree = // defaultModelAttributeService.readPageTree(LocaleContextHolder.getLocale().getLanguage()); List<String> codes = new LinkedList<>(); Page parent = page.getParent(); while (parent != null) { codes.add(parent.getCode()); parent = (parent.getParent() != null) ? pageTree.getPageByCode(parent.getParent().getCode()) : null; } Collections.reverse(codes); codes.add(page.getCode()); for (int i = 0; i < codes.size(); i++) { String key = "code" + i; builder.path("/{" + key + "}"); params.put(key, codes.get(i)); } UriComponents components = builder.buildAndExpand(params); if (encode) { components = components.encode(); } return components.toUriString(); }
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())); }
public String ogSiteName(Post post) { Blog blog = blogService.readBlogById(Blog.DEFAULT_ID); return blog.getTitle(processingContext.getContext().getLocale().getLanguage()); }