Package: HtmlTemplateBlogView
HtmlTemplateBlogView
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
HtmlTemplateBlogView(Id, Site) |
|
|
|
|
|
||||||||||||||||||||
renderPosts(Optional, Template.Aggregates, Template.Aggregates, Template.Aggregates) |
|
|
|
|
|
||||||||||||||||||||
renderTagCloud(Optional, Template.Aggregates) |
|
|
|
|
|
||||||||||||||||||||
setTitle(String) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.ui.component.blog.htmltemplate;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Optional;
31: import it.tidalwave.util.Id;
32: import it.tidalwave.northernwind.core.model.ResourcePath;
33: import it.tidalwave.northernwind.core.model.Site;
34: import it.tidalwave.northernwind.core.model.Template.Aggregates;
35: import it.tidalwave.northernwind.frontend.ui.annotation.ViewMetadata;
36: import it.tidalwave.northernwind.frontend.ui.component.htmltemplate.HtmlHolder;
37: import it.tidalwave.northernwind.frontend.ui.component.blog.BlogView;
38: import it.tidalwave.northernwind.frontend.ui.component.htmlfragment.htmltemplate.HtmlTemplateHtmlFragmentView;
39:
40: /***********************************************************************************************************************
41: *
42: * <p>An implementation of {@link BlogView} based on HTML templates.</p>
43: *
44: * @see HtmlTemplateBlogViewController
45: * @author Fabrizio Giudici
46: *
47: **********************************************************************************************************************/
48: @ViewMetadata(typeUri="http://northernwind.tidalwave.it/component/Blog/#v1.0",
49: controlledBy=HtmlTemplateBlogViewController.class)
50: public class HtmlTemplateBlogView extends HtmlTemplateHtmlFragmentView implements BlogView
51: {
52: @Nonnull
53: private final Site site;
54:
55: private String title;
56:
57: /*******************************************************************************************************************
58: *
59: * Creates an instance with the given id.
60: *
61: * @param id the id of this view
62: * @param site the site
63: *
64: ******************************************************************************************************************/
65: public HtmlTemplateBlogView (@Nonnull final Id id, @Nonnull final Site site)
66: {
67: super(id);
68: this.site= site;
69:• }
70:
71: /*******************************************************************************************************************
72: *
73: * {@inheritDoc}
74: *
75: ******************************************************************************************************************/
76: @Override
77: public void setTitle (@Nonnull final String title)
78: {
79: this.title = title;
80: }
81:
82: /*******************************************************************************************************************
83: *
84: * Renders the blog contents. See {@link HtmlTemplateBlogViewController} for more information.
85: *
86: * @see HtmlTemplateBlogViewController
87: * @param templatePath the path of an optional template for the rendering
88: * @param fullPosts the posts to be rendered in full
89: * @param leadinPosts the posts to be rendered as lead-in text
90: * @param linkedPosts the posts to be rendered as links
91: *
92: ******************************************************************************************************************/
93: public void renderPosts (@Nonnull final Optional<ResourcePath> templatePath,
94: @Nonnull final Aggregates fullPosts,
95: @Nonnull final Aggregates leadinPosts,
96: @Nonnull final Aggregates linkedPosts)
97: {
98: // final Template postTemplate = templateHelper.getTemplate("/Templates/Blog/Post", "Post.st");
99: // postsTemplate.include("/singlePost", postTemplate);
100: final var postsTemplate = site.getTemplate(getClass(), templatePath, "Posts.st");
101: postsTemplate.addAttribute("title", title);
102: addComponent(new HtmlHolder(postsTemplate.render(fullPosts, leadinPosts, linkedPosts)));
103: }
104:
105: /*******************************************************************************************************************
106: *
107: * Renders the tag cloud. See {@link HtmlTemplateBlogViewController} for more information.
108: *
109: * @see HtmlTemplateBlogViewController
110: * @param templatePath the path of an optional template for the rendering
111: * @param tags the tags to render in the cloud
112: *
113: ******************************************************************************************************************/
114: public void renderTagCloud (@Nonnull final Optional<ResourcePath> templatePath, @Nonnull final Aggregates tags)
115: {
116: final var tagCloudTemplate = site.getTemplate(getClass(), templatePath, "TagCloud.st");
117: tagCloudTemplate.addAttribute("title", title);
118: addComponent(new HtmlHolder(tagCloudTemplate.render(tags)));
119: }
120: }