Some bugfixes for the pages controller
parent
5089929d00
commit
e7cebdd9ff
|
|
@ -246,6 +246,11 @@ public class PagesController {
|
||||||
final Versions versions = generateFromPreviewParam(preview);
|
final Versions versions = generateFromPreviewParam(preview);
|
||||||
final String language = determineLanguage(category, versions);
|
final String language = determineLanguage(category, versions);
|
||||||
|
|
||||||
|
categoryModel.init(
|
||||||
|
pages.getCategoryDomain(),
|
||||||
|
category,
|
||||||
|
generateFromPreviewParam(preview).getContentItemVersion()
|
||||||
|
);
|
||||||
pageUrlModel.init(uriInfo);
|
pageUrlModel.init(uriInfo);
|
||||||
|
|
||||||
final String indexPage = String.format(
|
final String indexPage = String.format(
|
||||||
|
|
@ -277,6 +282,11 @@ public class PagesController {
|
||||||
final Versions versions = generateFromPreviewParam(preview);
|
final Versions versions = generateFromPreviewParam(preview);
|
||||||
final String language = determineLanguage(category, versions);
|
final String language = determineLanguage(category, versions);
|
||||||
|
|
||||||
|
categoryModel.init(
|
||||||
|
pages.getCategoryDomain(),
|
||||||
|
category,
|
||||||
|
generateFromPreviewParam(preview).getContentItemVersion()
|
||||||
|
);
|
||||||
pageUrlModel.init(uriInfo);
|
pageUrlModel.init(uriInfo);
|
||||||
|
|
||||||
final String itemPage = String.format(
|
final String itemPage = String.format(
|
||||||
|
|
@ -309,6 +319,11 @@ public class PagesController {
|
||||||
final Versions versions = generateFromPreviewParam(preview);
|
final Versions versions = generateFromPreviewParam(preview);
|
||||||
final String language = determineLanguage(category, itemName, versions);
|
final String language = determineLanguage(category, itemName, versions);
|
||||||
|
|
||||||
|
categoryModel.init(
|
||||||
|
pages.getCategoryDomain(),
|
||||||
|
category,
|
||||||
|
generateFromPreviewParam(preview).getContentItemVersion()
|
||||||
|
);
|
||||||
pageUrlModel.init(uriInfo);
|
pageUrlModel.init(uriInfo);
|
||||||
|
|
||||||
final String itemPage = String.format(
|
final String itemPage = String.format(
|
||||||
|
|
@ -549,7 +564,7 @@ public class PagesController {
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
pageUrlModel.init(uriInfo);
|
|
||||||
siteInfoModel.setDomain(site.getDomainOfSite());
|
siteInfoModel.setDomain(site.getDomainOfSite());
|
||||||
siteInfoModel.setHost(domain);
|
siteInfoModel.setHost(domain);
|
||||||
siteInfoModel.setName(
|
siteInfoModel.setName(
|
||||||
|
|
@ -557,8 +572,12 @@ public class PagesController {
|
||||||
.ofNullable(site.getDisplayName())
|
.ofNullable(site.getDisplayName())
|
||||||
.orElse("")
|
.orElse("")
|
||||||
);
|
);
|
||||||
|
|
||||||
final Category category = getCategory(domain, pages, pagePath);
|
final Category category = getCategory(domain, pages, pagePath);
|
||||||
categoryModel.init(pages.getCategoryDomain(), category, version);
|
categoryModel.init(pages.getCategoryDomain(), category, version);
|
||||||
|
|
||||||
|
pageUrlModel.init(uriInfo);
|
||||||
|
|
||||||
final Page page = pageManager.findPageForCategory(category);
|
final Page page = pageManager.findPageForCategory(category);
|
||||||
pagePropertiesModel.setProperties(page.getProperties());
|
pagePropertiesModel.setProperties(page.getProperties());
|
||||||
if (itemName.equals("index") || itemName.isBlank()) {
|
if (itemName.equals("index") || itemName.isBlank()) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.pages.models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class BreadcrumbData {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(final String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(final String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,13 +19,16 @@
|
||||||
package org.librecms.pages.models;
|
package org.librecms.pages.models;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.ws.rs.core.PathSegment;
|
import javax.ws.rs.core.PathSegment;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
|
|
@ -41,6 +44,9 @@ import javax.ws.rs.core.UriInfo;
|
||||||
@Named("CmsPagesPageUrlModel")
|
@Named("CmsPagesPageUrlModel")
|
||||||
public class PageUrlModel {
|
public class PageUrlModel {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CategoryModel categoryModel;
|
||||||
|
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
||||||
private String host;
|
private String host;
|
||||||
|
|
@ -53,6 +59,8 @@ public class PageUrlModel {
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
private List<BreadcrumbData> breadcrumbs;
|
||||||
|
|
||||||
private String pageName;
|
private String pageName;
|
||||||
|
|
||||||
private String pageLocale;
|
private String pageLocale;
|
||||||
|
|
@ -112,6 +120,10 @@ public class PageUrlModel {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
breadcrumbs = new ArrayList<>();
|
||||||
|
breadcrumbs = buildBreadcrumbs(categoryModel.getCategoryTree());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProtocol() {
|
public String getProtocol() {
|
||||||
|
|
@ -138,6 +150,10 @@ public class PageUrlModel {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BreadcrumbData> getBreadcrumbs() {
|
||||||
|
return Collections.unmodifiableList(breadcrumbs);
|
||||||
|
}
|
||||||
|
|
||||||
public String getPageName() {
|
public String getPageName() {
|
||||||
return pageName;
|
return pageName;
|
||||||
}
|
}
|
||||||
|
|
@ -212,5 +228,32 @@ public class PageUrlModel {
|
||||||
Collectors.joining("&", "?", "")
|
Collectors.joining("&", "?", "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<BreadcrumbData> buildBreadcrumbs(
|
||||||
|
final CategoryTreeNode category
|
||||||
|
) {
|
||||||
|
return buildBreadcrumbs(category, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<BreadcrumbData> buildBreadcrumbs(
|
||||||
|
final CategoryTreeNode category,
|
||||||
|
final List<BreadcrumbData> breadcrumbs
|
||||||
|
) {
|
||||||
|
final Optional<CategoryTreeNode> selected = category
|
||||||
|
.getSubCategories()
|
||||||
|
.stream()
|
||||||
|
.filter(subCat -> subCat.isSelected())
|
||||||
|
.findAny();
|
||||||
|
|
||||||
|
if (selected.isPresent()) {
|
||||||
|
final BreadcrumbData breadcrumb = new BreadcrumbData();
|
||||||
|
breadcrumb.setPath(selected.get().getCategoryPath());
|
||||||
|
breadcrumb.setTitle(selected.get().getTitle());
|
||||||
|
|
||||||
|
buildBreadcrumbs(selected.get(), breadcrumbs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return breadcrumbs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue