Bugfixes for pagem model components and FTL libs
parent
b38cfb0a77
commit
adb4506552
|
|
@ -106,6 +106,8 @@ public class CategoryTreeComponentRenderer
|
||||||
|
|
||||||
final Category rootCategory = findRootCategory(category);
|
final Category rootCategory = findRootCategory(category);
|
||||||
|
|
||||||
|
result.put("categoryId", Long.toString(rootCategory.getObjectId()));
|
||||||
|
result.put("uuid", rootCategory.getUuid());
|
||||||
result.put("categoryName", rootCategory.getName());
|
result.put("categoryName", rootCategory.getName());
|
||||||
result.put("categoryPath",
|
result.put("categoryPath",
|
||||||
categoryManager.getCategoryPath(rootCategory));
|
categoryManager.getCategoryPath(rootCategory));
|
||||||
|
|
@ -141,6 +143,8 @@ public class CategoryTreeComponentRenderer
|
||||||
final Locale language) {
|
final Locale language) {
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
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("categoryName", category.getName());
|
||||||
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
||||||
result.put("categoryTitle", category.getTitle().getValue(language));
|
result.put("categoryTitle", category.getTitle().getValue(language));
|
||||||
|
|
@ -153,6 +157,8 @@ public class CategoryTreeComponentRenderer
|
||||||
final Locale language) {
|
final Locale language) {
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
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("categoryName", category.getName());
|
||||||
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
result.put("categoryPath", categoryManager.getCategoryPath(category));
|
||||||
result.put("categoryTitle", category.getTitle().getValue(language));
|
result.put("categoryTitle", category.getTitle().getValue(language));
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import static org.apache.logging.log4j.ThreadContext.*;
|
|
||||||
import static org.librecms.pages.PagesConstants.*;
|
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 = "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_NAME = "categoryName";
|
||||||
|
|
||||||
protected static final String PAGE_PATH_CATEGORY_TITLE = "categoryTitle";
|
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 = "siteInfo";
|
||||||
|
|
||||||
protected static final String SITE_INFO_NAME = "name";
|
protected static final String SITE_INFO_NAME = "name";
|
||||||
|
|
@ -329,7 +332,7 @@ public class PagesRouter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}")
|
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public Response getPage(
|
public Response getPage(
|
||||||
@Context final UriInfo uriInfo,
|
@Context final UriInfo uriInfo,
|
||||||
|
|
@ -369,7 +372,7 @@ public class PagesRouter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.html")
|
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.html")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public Response getPageAsHtml(
|
public Response getPageAsHtml(
|
||||||
@Context final UriInfo uriInfo,
|
@Context final UriInfo uriInfo,
|
||||||
|
|
@ -411,7 +414,7 @@ public class PagesRouter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
|
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.html")
|
||||||
@Produces("text/html")
|
@Produces("text/html")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String getPageAsHtml(
|
public String getPageAsHtml(
|
||||||
|
|
@ -466,7 +469,7 @@ public class PagesRouter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json")
|
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json")
|
||||||
@Produces("application/json")
|
@Produces("application/json")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String getPageAsJson(
|
public String getPageAsJson(
|
||||||
|
|
@ -521,7 +524,7 @@ public class PagesRouter {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.xml")
|
@Path("/{page:[\\w\\-/]+}/{name:[\\w\\-]+}.{lang:\\w+}.xml")
|
||||||
@Produces("text/xml")
|
@Produces("text/xml")
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public String getPageAsXml(
|
public String getPageAsXml(
|
||||||
|
|
@ -783,6 +786,8 @@ public class PagesRouter {
|
||||||
) {
|
) {
|
||||||
|
|
||||||
final Map<String, Object> result = new HashMap<>();
|
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_NAME, category.getName());
|
||||||
result.put(
|
result.put(
|
||||||
PAGE_PATH_CATEGORY_TITLE, category.getTitle().getValue(language)
|
PAGE_PATH_CATEGORY_TITLE, category.getTitle().getValue(language)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
<#if isRootPage()>
|
<#if isRootPage()>
|
||||||
<#return null>
|
<#return null>
|
||||||
<#elseif getPagePath()??>
|
<#elseif getPagePath()??>
|
||||||
<#return getPathPath()?last>
|
<#return getPagePath()?last>
|
||||||
<#else>
|
<#else>
|
||||||
<#return null>
|
<#return null>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
@ -49,7 +49,11 @@
|
||||||
@return The ID of the currently selected category.
|
@return The ID of the currently selected category.
|
||||||
-->
|
-->
|
||||||
<#function getSelectedCategoryId>
|
<#function getSelectedCategoryId>
|
||||||
<#return getSelectedCategory().categoryId>
|
<#if getSelectedCategory()??>
|
||||||
|
<#return getSelectedCategory().categoryId>
|
||||||
|
<#else>
|
||||||
|
<#return "">
|
||||||
|
</#if>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
|
|
@ -58,10 +62,12 @@
|
||||||
@param The model of a category as returned by several functions in this
|
@param The model of a category as returned by several functions in this
|
||||||
library.
|
library.
|
||||||
|
|
||||||
|
@depcrecated Use the title property directly
|
||||||
|
|
||||||
@return The title of the category.
|
@return The title of the category.
|
||||||
-->
|
-->
|
||||||
<#function getCategoryTitle category>
|
<#function getCategoryTitle category>
|
||||||
<#return category.title>
|
<#return category.categoryTitle>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
|
|
@ -70,6 +76,8 @@
|
||||||
@param The model of a category as returned by several functions in this
|
@param The model of a category as returned by several functions in this
|
||||||
library.
|
library.
|
||||||
|
|
||||||
|
@depcrecated Use the categoryId of uuid property directly
|
||||||
|
|
||||||
@return The ID of the provided category.
|
@return The ID of the provided category.
|
||||||
-->
|
-->
|
||||||
<#function getCategoryId category>
|
<#function getCategoryId category>
|
||||||
|
|
@ -82,10 +90,12 @@
|
||||||
@param The model of a category as returned by several functions in this
|
@param The model of a category as returned by several functions in this
|
||||||
library.
|
library.
|
||||||
|
|
||||||
|
@depcrecated Use the selected property directly
|
||||||
|
|
||||||
@return `true` if the category is selected, `false` if not.
|
@return `true` if the category is selected, `false` if not.
|
||||||
-->
|
-->
|
||||||
<#function isCategorySelected category>
|
<#function isCategorySelected category>
|
||||||
<#return category.isSelected>
|
<#return category.selected>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
|
|
@ -98,7 +108,7 @@
|
||||||
provided ID.
|
provided ID.
|
||||||
-->
|
-->
|
||||||
<#function getNavigationRootUrl navigationId="categoryTree" containerId="container">
|
<#function getNavigationRootUrl navigationId="categoryTree" containerId="container">
|
||||||
<#return [container][navigationId].url>
|
<#return containerId?eval[navigationId].categoryPath>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
|
|
@ -107,23 +117,25 @@
|
||||||
@param navigationId The ID of the navigation system to use.
|
@param navigationId The ID of the navigation system to use.
|
||||||
@param containerId Container of the category menu
|
@param containerId Container of the category menu
|
||||||
|
|
||||||
|
@depcrecated Without replacement
|
||||||
|
|
||||||
@return The title of the navigation.
|
@return The title of the navigation.
|
||||||
-->
|
-->
|
||||||
<#function getNavigationTitle navigationId="categoryMenu" containerId="container">
|
<#function getNavigationTitle navigationId="categoryMenu" containerId="container">
|
||||||
<#return [containerId][navigationId].categoryTitle>
|
<#return containerId?eval[navigationId].categoryTitle>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
Retrieves the first level of categories from the category hierachy with the
|
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
|
@param containerId Container of the category hierarchy
|
||||||
|
|
||||||
@return The first level of categories in the hierarchy.
|
@return The first level of categories in the hierarchy.
|
||||||
-->
|
-->
|
||||||
<#function getCategoryHierarchy hierarchyId="categoryNav" containerId="container">
|
<#function getCategoryHierarchy hierarchyId="categoryTree" containerId="container">
|
||||||
<#return [containerId][hierarchyId].subCategories>
|
<#return containerId?eval[hierarchyId].subCategories>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
|
|
@ -131,10 +143,12 @@
|
||||||
|
|
||||||
@param ofCategory The model of the category.
|
@param ofCategory The model of the category.
|
||||||
|
|
||||||
|
@depcrected Use the subCategories property directly
|
||||||
|
|
||||||
@return The sub categories of the provided category.
|
@return The sub categories of the provided category.
|
||||||
-->
|
-->
|
||||||
<#function getSubCategories ofCategory>
|
<#function getSubCategories ofCategory>
|
||||||
<#return ofCategory.subcategories>
|
<#return ofCategory.subCategories>
|
||||||
</#function>
|
</#function>
|
||||||
|
|
||||||
<#--doc
|
<#--doc
|
||||||
|
|
@ -142,6 +156,8 @@
|
||||||
|
|
||||||
@param categoryId The ID of the category to use.
|
@param categoryId The ID of the category to use.
|
||||||
|
|
||||||
|
@depcrecated Without replacement
|
||||||
|
|
||||||
@return Nothing
|
@return Nothing
|
||||||
-->
|
-->
|
||||||
<#function getSubCategoriesOfCategoryWithId categoryId>
|
<#function getSubCategoriesOfCategoryWithId categoryId>
|
||||||
|
|
@ -156,6 +172,20 @@
|
||||||
|
|
||||||
@return The model of the index item.
|
@return The model of the index item.
|
||||||
-->
|
-->
|
||||||
<#function getGreetingItem containerId="container">
|
<#function getIndexItem containerId="container">
|
||||||
<#return eval(containerId).greetingItem>
|
<#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>
|
</#function>
|
||||||
|
|
@ -126,7 +126,7 @@
|
||||||
<dt>Name</dt>
|
<dt>Name</dt>
|
||||||
<dd>${cat.categoryName}</dd>
|
<dd>${cat.categoryName}</dd>
|
||||||
<dt>Title</dt>
|
<dt>Title</dt>
|
||||||
<dd>${cat.categoryTitle}</dd>
|
<dd>${cat.categoryTitle!""}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
</#items>
|
</#items>
|
||||||
|
|
@ -146,7 +146,7 @@
|
||||||
<dt>Name</dt>
|
<dt>Name</dt>
|
||||||
<dd>${cat.categoryName}</dd>
|
<dd>${cat.categoryName}</dd>
|
||||||
<dt>Title</dt>
|
<dt>Title</dt>
|
||||||
<dd>${cat.categoryTitle}</dd>
|
<dd>${cat.categoryTitle!""}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
</#items>
|
</#items>
|
||||||
|
|
@ -162,12 +162,50 @@
|
||||||
<dt>Pages.getSelectedCategory()</dt>
|
<dt>Pages.getSelectedCategory()</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<#if Pages.getSelectedCategory()??>
|
<#if Pages.getSelectedCategory()??>
|
||||||
${Pages.getSelectedCategory()}
|
${Pages.getSelectedCategory().categoryName}
|
||||||
<#else>
|
<#else>
|
||||||
No category selected.
|
No category selected.
|
||||||
</#if>
|
</#if>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</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>
|
</dl>
|
||||||
<h2>ccm-navigation/navigation.ftl as Navigation</h2>
|
<h2>ccm-navigation/navigation.ftl as Navigation</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|
@ -176,7 +214,23 @@
|
||||||
<dl>
|
<dl>
|
||||||
<div>
|
<div>
|
||||||
<dt>Navigation.getCategoryPath</dt>
|
<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>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue