Package: HtmlTemplateSitemapView
HtmlTemplateSitemapView
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
HtmlTemplateSitemapView(Id, Site) |
|
|
|
|
|
||||||||||||||||||||
render(Optional, Template.Aggregates) |
|
|
|
|
|
||||||||||||||||||||
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.sitemap.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.htmlfragment.htmltemplate.HtmlTemplateHtmlFragmentView;
38: import it.tidalwave.northernwind.frontend.ui.component.sitemap.SitemapView;
39:
40: /***********************************************************************************************************************
41: *
42: * <p>An implementation of {@link SitemapView} based on HTML templates.</p>
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @ViewMetadata(typeUri="http://northernwind.tidalwave.it/component/Sitemap/#v1.0",
48: controlledBy=HtmlTemplateSitemapViewController.class)
49: public class HtmlTemplateSitemapView extends HtmlTemplateHtmlFragmentView implements SitemapView
50: {
51: @Nonnull
52: private final Site site;
53:
54: /*******************************************************************************************************************
55: *
56: * Creates an instance with the given id.
57: *
58: * @param id the id of this view
59: * @param site the site
60: *
61: ******************************************************************************************************************/
62: public HtmlTemplateSitemapView (@Nonnull final Id id, @Nonnull final Site site)
63: {
64: super(id);
65: this.site= site;
66:• }
67:
68: /*******************************************************************************************************************
69: *
70: * Renders the sitemap contents. See {@link HtmlTemplateSitemapViewController} for more information.
71: *
72: * @see HtmlTemplateSitemapViewController
73: * @param templatePath the path of an optional template for the rendering
74: * @param entries the entries to render
75: *
76: ******************************************************************************************************************/
77: public void render (@Nonnull final Optional<ResourcePath> templatePath, @Nonnull final Aggregates entries)
78: {
79: final var template = site.getTemplate(getClass(), templatePath, "Sitemap.st");
80: addComponent(new HtmlHolder(template.render(entries)));
81: }
82: }