Package: DefaultHtmlFragmentViewController
DefaultHtmlFragmentViewController
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DefaultHtmlFragmentViewController(HtmlFragmentView, SiteNode, Site) |
|
|
|
|
|
||||||||||||||||||||
lambda$renderView$0(String) |
|
|
|
|
|
||||||||||||||||||||
lambda$renderView$1(ResourceProperties) |
|
|
|
|
|
||||||||||||||||||||
renderView(RenderContext) |
|
|
|
|
|
||||||||||||||||||||
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.htmlfragment;
28:
29: import javax.annotation.Nonnull;
30: import it.tidalwave.northernwind.core.model.Resource;
31: import it.tidalwave.northernwind.core.model.Site;
32: import it.tidalwave.northernwind.core.model.SiteNode;
33: import it.tidalwave.northernwind.frontend.ui.RenderContext;
34: import lombok.RequiredArgsConstructor;
35: import lombok.extern.slf4j.Slf4j;
36: import static java.util.Collections.emptyList;
37: import static java.util.stream.Collectors.*;
38: import static it.tidalwave.northernwind.core.model.Content.*;
39: import static it.tidalwave.northernwind.frontend.ui.component.Properties.*;
40:
41: /***********************************************************************************************************************
42: *
43: * A default implementation of {@link HtmlFragmentViewController}.
44: *
45: * @author Fabrizio Giudici
46: *
47: **********************************************************************************************************************/
48: @RequiredArgsConstructor @Slf4j
49: public class DefaultHtmlFragmentViewController implements HtmlFragmentViewController
50: {
51: @Nonnull
52: private final HtmlFragmentView view;
53:
54: @Nonnull
55: private final SiteNode siteNode;
56:
57: @Nonnull
58: private final Site site;
59:
60: /*******************************************************************************************************************
61: *
62: * {@inheritDoc}
63: *
64: ******************************************************************************************************************/
65: @Override
66: public void renderView (@Nonnull final RenderContext context)
67: {
68: final var viewProperties = siteNode.getPropertyGroup(view.getId());
69: view.setContent(viewProperties.getProperty(P_CONTENT_PATHS).orElse(emptyList())
70: .stream()
71: .flatMap(path -> site.find(_Content_).withRelativePath(path).stream())
72: .map(Resource::getProperties)
73: .map(properties -> properties.getProperty(P_FULL_TEXT) // TODO: use multi-key
74: .orElse(properties.getProperty(P_TEMPLATE)
75: .orElse("")))
76: .collect(joining("\n")));
77: view.setClassName(viewProperties.getProperty(P_CLASS).orElse("nw-" + view.getId()));
78: }
79: }