Missing piece of PagesController

pull/10/head
Jens Pelzetter 2021-11-15 18:41:35 +01:00
parent 27b18d8888
commit 36b60b8844
1 changed files with 26 additions and 14 deletions

View File

@ -40,7 +40,6 @@ import org.librecms.pages.models.ContentItemModel;
import org.librecms.pages.models.SiteInfoModel;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@ -48,7 +47,6 @@ import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.StringJoiner;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@ -338,7 +336,6 @@ public class PagesController {
final Pages pages = getPages(domain);
final Category category = getCategory(domain, pages, "/");
final Page page = pageManager.findPageForCategory(category);
page.getDisplayName();
return themesMvc.getMvcTemplate(
uriInfo, "pages", page.getDisplayName()
);
@ -373,8 +370,6 @@ public class PagesController {
@DefaultValue("")
final String preview
) {
// ToDo Check!!!
final String domain = uriInfo.getBaseUri().getHost();
final Pages pages = getPages(domain);
final Category category = getCategory(domain, pages, page);
@ -388,7 +383,10 @@ public class PagesController {
);
} else {
final String itemPath = String.format(
"%s.%s.html", itemName, language
"%s.%s.html%s",
itemName,
language,
buildQueryParamsStr(preview, theme)
);
redirectTo = uriInfo.getPath().replace(itemName, itemPath);
}
@ -405,6 +403,8 @@ public class PagesController {
* @param uriInfo
* @param page
* @param itemName
* @param theme
* @param preview
*
* @return
*/
@ -433,11 +433,17 @@ public class PagesController {
final String redirectTo;
if (uriInfo.getPath().endsWith("/")) {
redirectTo = String.format(
"%sindex.%s.html", uriInfo.getPath(), language
"%sindex.%s.html%s",
uriInfo.getPath(),
language,
buildQueryParamsStr(preview, theme)
);
} else {
final String itemPath = String.format(
"%s.%s.html", itemName, language
"%s.%s.html%s",
itemName,
language,
buildQueryParamsStr(preview, theme)
);
redirectTo = uriInfo.getPath().replace(itemName, itemPath);
}
@ -451,7 +457,7 @@ public class PagesController {
* associated with the category and identified by {@code itemName}.
*
* @param uriInfo
* @param page
* @param pagePath
* @param itemName
* @param language
* @param theme
@ -460,14 +466,14 @@ public class PagesController {
* @return
*/
@GET
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
@Path("/{pagePath:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
@Produces("text/html")
@Transactional(Transactional.TxType.REQUIRED)
public String getPageAsHtml(
@Context
final UriInfo uriInfo,
@PathParam("page")
final String page,
@PathParam("pagePath")
final String pagePath,
@PathParam("name")
final String itemName,
@PathParam("lang")
@ -480,11 +486,17 @@ public class PagesController {
final String preview
) {
final Versions versions = generateFromPreviewParam(preview);
contentItemModel.setItemName(itemName);
contentItemModel.setItemVersion(versions.getContentItemVersion());
final Site site = getSite(uriInfo);
return themesMvc.getMvcTemplate(uriInfo, "pages", "page");
final String domain = uriInfo.getBaseUri().getHost();
final Pages pages = getPages(domain);
final Category category = getCategory(domain, pages, pagePath);
final Page page = pageManager.findPageForCategory(category);
return themesMvc.getMvcTemplate(
uriInfo, "pages", page.getDisplayName()
);
}
private Site getSite(final UriInfo uriInfo) {