Bugfixes for pagem model components and FTL libs

Jens Pelzetter 2019-12-21 17:05:37 +01:00
parent 9e466cf273
commit 07c57f21f8
4 changed files with 119 additions and 24 deletions

View File

@ -106,6 +106,8 @@ public class CategoryTreeComponentRenderer
final Category rootCategory = findRootCategory(category);
result.put("categoryId", Long.toString(rootCategory.getObjectId()));
result.put("uuid", rootCategory.getUuid());
result.put("categoryName", rootCategory.getName());
result.put("categoryPath",
categoryManager.getCategoryPath(rootCategory));
@ -141,6 +143,8 @@ public class CategoryTreeComponentRenderer
final Locale language) {
final Map<String, Object> result = new HashMap<>();
result.put("categoryId", Long.toString(category.getObjectId()));
result.put("uuid", category.getUuid());
result.put("categoryName", category.getName());
result.put("categoryPath", categoryManager.getCategoryPath(category));
result.put("categoryTitle", category.getTitle().getValue(language));
@ -153,6 +157,8 @@ public class CategoryTreeComponentRenderer
final Locale language) {
final Map<String, Object> result = new HashMap<>();
result.put("categoryId", Long.toString(category.getObjectId()));
result.put("uuid", category.getUuid());
result.put("categoryName", category.getName());
result.put("categoryPath", categoryManager.getCategoryPath(category));
result.put("categoryTitle", category.getTitle().getValue(language));

View File

@ -67,7 +67,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import static org.apache.logging.log4j.ThreadContext.*;
import static org.librecms.pages.PagesConstants.*;
/**
@ -81,10 +80,14 @@ public class PagesRouter {
protected static final String PAGE_PATH = "pagePath";
protected static final String PAGE_PATH_CATEGORY_ID = "categoryId";
protected static final String PAGE_PATH_CATEGORY_NAME = "categoryName";
protected static final String PAGE_PATH_CATEGORY_TITLE = "categoryTitle";
protected static final String PAGE_PATH_CATEGORY_UUID = "uuid";
protected static final String SITE_INFO = "siteInfo";
protected static final String SITE_INFO_NAME = "name";
@ -329,7 +332,7 @@ public class PagesRouter {
* @return
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}")
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}")
@Transactional(Transactional.TxType.REQUIRED)
public Response getPage(
@Context final UriInfo uriInfo,
@ -369,7 +372,7 @@ public class PagesRouter {
* @return
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.html")
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.html")
@Transactional(Transactional.TxType.REQUIRED)
public Response getPageAsHtml(
@Context final UriInfo uriInfo,
@ -411,7 +414,7 @@ public class PagesRouter {
* @return
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
@Produces("text/html")
@Transactional(Transactional.TxType.REQUIRED)
public String getPageAsHtml(
@ -466,7 +469,7 @@ public class PagesRouter {
* @return
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json")
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json")
@Produces("application/json")
@Transactional(Transactional.TxType.REQUIRED)
public String getPageAsJson(
@ -521,7 +524,7 @@ public class PagesRouter {
* @return
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.xml")
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.xml")
@Produces("text/xml")
@Transactional(Transactional.TxType.REQUIRED)
public String getPageAsXml(
@ -783,6 +786,8 @@ public class PagesRouter {
) {
final Map<String, Object> result = new HashMap<>();
result.put(PAGE_PATH_CATEGORY_ID, Long.toString(category.getObjectId()));
result.put(PAGE_PATH_CATEGORY_UUID, category.getUuid());
result.put(PAGE_PATH_CATEGORY_NAME, category.getName());
result.put(
PAGE_PATH_CATEGORY_TITLE, category.getTitle().getValue(language)

View File

@ -37,7 +37,7 @@
<#if isRootPage()>
<#return null>
<#elseif getPagePath()??>
<#return getPathPath()?last>
<#return getPagePath()?last>
<#else>
<#return null>
</#if>
@ -49,7 +49,11 @@
@return The ID of the currently selected category.
-->
<#function getSelectedCategoryId>
<#return getSelectedCategory().categoryId>
<#if getSelectedCategory()??>
<#return getSelectedCategory().categoryId>
<#else>
<#return "">
</#if>
</#function>
<#--doc
@ -58,10 +62,12 @@
@param The model of a category as returned by several functions in this
library.
@depcrecated Use the title property directly
@return The title of the category.
-->
<#function getCategoryTitle category>
<#return category.title>
<#return category.categoryTitle>
</#function>
<#--
@ -70,6 +76,8 @@
@param The model of a category as returned by several functions in this
library.
@depcrecated Use the categoryId of uuid property directly
@return The ID of the provided category.
-->
<#function getCategoryId category>
@ -82,10 +90,12 @@
@param The model of a category as returned by several functions in this
library.
@depcrecated Use the selected property directly
@return `true` if the category is selected, `false` if not.
-->
<#function isCategorySelected category>
<#return category.isSelected>
<#return category.selected>
</#function>
<#--doc
@ -98,7 +108,7 @@
provided ID.
-->
<#function getNavigationRootUrl navigationId="categoryTree" containerId="container">
<#return [container][navigationId].url>
<#return containerId?eval[navigationId].categoryPath>
</#function>
<#--doc
@ -107,23 +117,25 @@
@param navigationId The ID of the navigation system to use.
@param containerId Container of the category menu
@depcrecated Without replacement
@return The title of the navigation.
-->
<#function getNavigationTitle navigationId="categoryMenu" containerId="container">
<#return [containerId][navigationId].categoryTitle>
<#return containerId?eval[navigationId].categoryTitle>
</#function>
<#--doc
Retrieves the first level of categories from the category hierachy with the
provided ID. If no id is provided 'categoryNav' is used.
provided ID. If no id is provided 'categoryTree' is used.
@param hierarchyId The ID of the category hierachy to use.
@param hierarchyId The ID of the category hierarchy to use.
@param containerId Container of the category hierarchy
@return The first level of categories in the hierarchy.
-->
<#function getCategoryHierarchy hierarchyId="categoryNav" containerId="container">
<#return [containerId][hierarchyId].subCategories>
<#function getCategoryHierarchy hierarchyId="categoryTree" containerId="container">
<#return containerId?eval[hierarchyId].subCategories>
</#function>
<#--doc
@ -131,10 +143,12 @@
@param ofCategory The model of the category.
@depcrected Use the subCategories property directly
@return The sub categories of the provided category.
-->
<#function getSubCategories ofCategory>
<#return ofCategory.subcategories>
<#return ofCategory.subCategories>
</#function>
<#--doc
@ -142,6 +156,8 @@
@param categoryId The ID of the category to use.
@depcrecated Without replacement
@return Nothing
-->
<#function getSubCategoriesOfCategoryWithId categoryId>
@ -156,6 +172,20 @@
@return The model of the index item.
-->
<#function getGreetingItem containerId="container">
<#return eval(containerId).greetingItem>
<#function getIndexItem containerId="container">
<#return containerId?eval.greetingItem>
</#function>
<#--doc
Gets the greeting/index item of the current navigation page. The returned
model can be processed with usual functions for processing content items.
@param containerId Container of the index item.
@depcrecated Use getIndexItem
@return The model of the index item.
-->
<#function getGreetingItem containerId="container">
<#return getIndexItem(containerId)>
</#function>

View File

@ -126,7 +126,7 @@
<dt>Name</dt>
<dd>${cat.categoryName}</dd>
<dt>Title</dt>
<dd>${cat.categoryTitle}</dd>
<dd>${cat.categoryTitle!""}</dd>
</dl>
</li>
</#items>
@ -146,7 +146,7 @@
<dt>Name</dt>
<dd>${cat.categoryName}</dd>
<dt>Title</dt>
<dd>${cat.categoryTitle}</dd>
<dd>${cat.categoryTitle!""}</dd>
</dl>
</li>
</#items>
@ -162,12 +162,50 @@
<dt>Pages.getSelectedCategory()</dt>
<dd>
<#if Pages.getSelectedCategory()??>
${Pages.getSelectedCategory()}
${Pages.getSelectedCategory().categoryName}
<#else>
No category selected.
</#if>
</dd>
</div>
<div>
<dt>Pages.getSelectedCategoryId()</dt>
<dd>
${Pages.getSelectedCategoryId()}
</dd>
</div>
<div>
<dt>Pages.getNavigationRootUrl()</dt>
</dd>${Pages.getNavigationRootUrl()}</dd>
</div>
<div>
<dt>Pages.getCategoryHierarchy()</dt>
<dd>
<#list Pages.getCategoryHierarchy()>
<ul>
<#items as cat>
<li>
${cat.categoryId}:${cat.categoryName}
</li>
</#items>
</ul>
<#else>
No categories in hierarchy.
</#list>
</dd>
</div>
<div>
<dt>Pages.getIndexItem()</dt>
<dd>
<#assign indexItem = Pages.getIndexItem()>
<#if (indexItem?keys?size > 0)>
${indexItem.uuid}:${indexItem.name}:${indexItem.title}
<#else>
No index item
</#if>
</dd>
</div>
</dl>
<h2>ccm-navigation/navigation.ftl as Navigation</h2>
<p>
@ -176,7 +214,23 @@
<dl>
<div>
<dt>Navigation.getCategoryPath</dt>
<dd>${Navigation.getCategoryPath()}</dd>
<dd>
Path length: ${Navigation.getCategoryPath()?size}
<#list Navigation.getCategoryPath()>
<ul>
<#items as cat>
<li>
<dl>
<dt>Name</dt>
<dd>${cat.categoryName}</dd>
<dt>Title</dt>
<dd>${cat.categoryTitle!""}</dd>
</dl>
</li>
</#items>
</ul>
</#list>
</dd>
</div>
</dl>
</body>