Understanding the Layout Manager
This document explains how the PageSeeder user interface (UI) components, including pages, blocks, and menus, are controlled by the Layout Manager Configuration file (Layout Manager Config 1.4 (obsolete)).
The layout manager is a project-level configuration. So any changes affect all groups in the project.
Updating the user interface is deprecated and is removed in PageSeeder v6. Where a customized interface is required for specific use cases, consider using Berlioz . It can leverage PageSeeder functionality but is easier to learn and has more flexible deployment options.
Overview
The configuration file is an XML file that must be valid against the layout manager DTD. Following are explanations of the main rules:
- The root element is
<layout-config>
plus a@version
attribute. -
The children elements are the following:
<content-security-policy>
– to specify a Content Security Policy .<navigation>
– determines the tabs at the top of the page.<blocks>
,<dialogs>
,<pages>
– determines the rest of the interface components.
Following is a example configuration file to illustrate the basic logic of the layout manager.
<layout-config version="1.4"> <content-security-policy> ... </content-security-policy> <navigation> ... </navigation> <blocks> ... </blocks> <dialogs> ... </dialogs> <pages> ... </pages </layout-config>
Note: Before making any changes to config.xml
, read the Developer Guidelines for customizing the user interface.
Content Security Policy
The layout manager can automatically include the Content-Security-Policy
HTTP header to all pages based on your configuration.
Content Security Policy (CSP) helps to detect and mitigate certain types of malicious activity, including Cross Site Scripting (XSS) and data injection attacks. By default, PageSeeder excludes any content sourced from other sites.
<content-security-policy> <directive name="default-src" value="'self'"/> <directive name="script-src" value="'self' 'unsafe-inline' 'unsafe-eval'"/> <directive name="style-src" value="'self' 'unsafe-inline'"/> <directive name="object-src" value="'none'"/> <directive name="img-src" value="'self' data:"/> </content-security-policy>
<content-security-policy>
element
The <content-security-policy>
element is a container for a list of <directive>
elements.
<directive>
element
The <directive>
element defines the directives to include in the security policy. It supports the following attributes.
Attributes | Description |
---|---|
@name | The name of the security policy directive (for example, default-src , img-src , etc...) |
@value | The value for that directive |
For example:
<content-security-policy> <directive name="default-src" value="'self'"/> <directive name="img-src" value="*"/> <directive name="media-src" value="media.example.org asset.example.net"/> <directive name="script-src" value="cdn.example.com"/> </content-security-policy>
Would automatically send the following header:
Content-Security-Policy: default-src 'self'; img-src *; media-src media.example.org asset.example.net; script-src cdn.example.com
(space added for readability)
For more details, see the following:
Navigation
The navigation element contains a list of <menu>
elements that each contain a list of <link>
elements.
<menu> element
Each menu supports the following attributes.
Attributes | Description |
---|---|
@behaviour | This optional attribute specifies how the menu should redefine an existing menu (i.e. matching the same name). The attribute value override (default) ignores the original menu while the value inherit inherits the links from the original menu and appends the new ones. |
@name | A unique name for reference, when specified, this attribute acts like an ID for the menu in place of the title. |
@permission | This optional attribute defines the permission that the current user must have in order for the menu to be displayed. |
@role | This optional attribute can be used by the layout to customize the display of this menu. |
@scope | Defines in which contexts this menu should be displayed. The value is a comma-separated list of any combination of the values document , group , project , server . |
@title | The title of the menu that appears on the user interface. This attribute is required. |
<link> elements
Menus contain links which are defined by link elements. <link>
elements are empty elements and support the following attributes.
Attributes | Description |
---|---|
@also | A list of page IDs other than @ idref that should make this link appear active. |
@idref | The ID of the page to go to when the link is clicked. It must point to a valid page ID. When the user is visiting that page, this is used to make this link appear active. |
@name | A unique name for reference. When specified, this attribute acts like an ID for the link in place of the title. |
@optional | An optional boolean attribute (true or false ) which describes whether this link should be visible at all times or not. If the value is set to true , the link is only visible when the page matched with the @id attribute is the current page. Also, there is no link on an optional link. The default value is false (display all the time). |
@permission | This optional attribute defines the permission that the current user must have in order for the link to be displayed |
@role | This optional attribute can be used by the layout to customize the display of this menu. |
@scope | Defines in which contexts this link should be displayed. The value is a comma-separated list of any combination of the values document , group , project , server . |
@title | The title of the link appears in the user interface. This attribute is required. |
Following are menu examples:
<menu title="Home"> <link title="My Home" default="true" idref="home" /> <link title="Group Home" scope="group,project" idref="group-home" /> <link title="Search" scope="group,project" idref="group-search" optional="true" /> </menu>
<menu title="Comments" scope="group"> <link title="New" idref="group-comment-new" /> <link title="List" idref="group-comments" default="true" /> <link title="View" idref="group-comment-thread" optional="true" /> </menu>
Interface components
A PageSeeder interface component can be a block, a dialog or a page. All three components have similar definitions.
Shared attributes
Attributes | Description |
---|---|
@id | An identifier for the component |
@method | Restricts this component to an HTTP method GET or POST. (default is get post ) |
@permission | Only display if the specified permission is true (e.g. edit-group) |
@scope | Defines in which contexts this component can be displayed. The value is a comma-separated list of any combination of the values document , group , project , server . |
@shared | The name of the shared script or css when the same components use the same set of styles (e.g. block-account). |
@style-id | The ID of another page that this component should use for its XSLT and CSS |
@title | The title of component |
Shared elements
All user interface components can specify the following elements:
<url>
– the URL to access the UI component. There could be more than one url element in a component (and there is at least one).<servlet>
– there can be zero, one or multiple servlets for each component. They indicate servlets to invoke to produce content that is not included in the generic properties. The servlets are invoked in order.<generator>
– there can be none, one or multiple generators for each component. They indicate generators to invoke to produce content that is not included in the generic properties. The generators are invoked in order.<script>
– an optional element, it describes a Javascript file which should be imported when loading the page.
<url>
element
This element defines which URL match the parent UI component and contains the following attributes.
Attributes | Description |
---|---|
@pattern |
A required attribute indicating the part of the path information that is used by the engine to map this URL to a component. This path can be an exact path (i.e.: “/document/browse”) or a pattern (i.e.: “/labels{;days-ago}/{label}”). If the path is a pattern, curly brackets {...} are used to reference a variable to load from the URL. This variable can be retrieved using the ‘#’ character in the parameter value (see below). The wildcard character ‘*’ is accepted, but its use is discouraged whenever a pattern variable can be used instead. |
@scope |
An optional attribute to further qualify the scope of the component, the scope of the URL is used when the The only value currently allowed is |
Here are examples of url elements:
<url pattern="/document/publish" /> <url pattern="/fullpath/*" /> <url pattern="/path/{+path}" scope="group" /> <url pattern="/labels{;days-ago}/{label}" />
<servlet> element
This element is used to specify a Java Servlet to invoke. The resulting data is then transformed to display the content. It can have the following attributes.
Attributes | Description |
---|---|
@class | The Java class name for the Servlet. This attribute is required |
@tunnel | A boolean (true or false are allowed) optional (false is the default value) attribute used to specify that all the parameters of the main URL are to be forwarded to the Servlet URL. |
A <servlet>
element can have zero or several children parameter elements.
<generator> element
This element is used to specify a PageSeeder generator to invoke. The resulting data is then transformed to display the content. It can have the following attributes.
Attributes | Description |
---|---|
@class | The Java class name for the generator. This attribute is required |
@tunnel | A boolean (true or false are allowed) optional (false is the default value) attribute used to specify that all the parameters of the main URL are to be forwarded to the generator. |
A <generator>
element can have zero or several children parameter elements.
<parameter> element
This element is used to specify a parameter to transmit to a servlet or generator. It can have the following attributes.
Attributes | Description |
---|---|
@name | The name of the parameter (required) |
@value |
The value of the parameter. This value can be dynamic; it uses the following conventions:
|
@default | A fallback value in case the dynamic value is empty (optional) |
Here are a few examples of parameters:
<parameter name="xformat" value="xml" /> <parameter name="groupName" value="" /> <parameter name="ps-docPath" value="{@uri.docpath}"/> <parameter name="history" value="{$history}" default="all"/> <parameter name="days-ago" value="{#days-ago}" />
<script> element
This element is used to define a Javascript file used by the component on top of the default scripts for the component.
It contains only one attribute called @src
which should contain the name of the script.
The default script file must be located in the script folder:
webapp/weborganic/layout/script/
and the custom script must be in:
webapp/WEB-INF/config/template/[project]/style/layout/script
Example:
<script src="document_view.js"/>
Blocks
Blocks are user interface components that are designed to be included in a page and cannot be displayed on their own.
<block> element
See the following examples:
<block id="document-search-box" scope="group" title="Document search"> <url pattern="/document/search/box"/> <script src="document_search_box.js"/> </block>
<block id="group-members" scope="project,group,document" title="Members"> <url pattern="/member/list"/> <generator class="com.pageseeder.membership.ListMembersForGroup" /> </block>
<block id="block-404" title="Not found!"> <url pattern="/404"/> </block>
<block-set> element
When the same blocks are displayed consistently on pages, it’s possible to group them in a <block-set>
which can be referenced in the page, instead of referencing each block individually.
A <block-set>
is a container for a set of <block-ref>
elements:
<block-set id="default-set" <block idref="group-members"/> <block idref="labels"> </block-set>
Dialog
A dialog is similar to a Page except that it is designed to be displayed as a standalone component in a dialog or modal window.
Dialogs are therefore devoid of blocks or navigation components.
<dialog id="dialog-about" title="About PageSeeder" scope="server"> <url pattern="/about"/> <generator class="com.pageseeder.system.About" /> <generator class="com.pageseeder.publish.About" /> <generator class="com.pageseeder.search.About" /> </dialog>
Pages
A page includes one or more Blocks using <block-ref>
and <blockset-ref>
elements.
As many <block-ref>
elements as required are used to specify the Blocks to include on the Page, however, it is easier to manage this by creating, then referencing a blockset using <blockset-ref>
.
There is only one attribute on a <block-ref>
or <blockset-ref>
element and it is required: @idref
. It refers to the id of an existing block or block set in the Configuration file (@idref
attribute).
Following is an example page listing the comments on a group:
<page id="comments" scope="server" title="Comments" style-id="group-comments"> <url pattern="/comments"/> <generator class="com.pageseeder.comment.GetDiscussions"> <parameter name="pagesize" value="{$pagesize}" default="10" /> <parameter name="page" value="{$page}" /> <parameter name="comments" value="last" /> <parameter name="returngroups" value="user"/> </generator> <script src="lib/jquery.autosize.min.js"/> <script src="jquery.psfield.js"/> <blockset-ref idref="basic-server-set"/> </page>
Following is an example of an error page:
<page id="page-404"> <url pattern="/404"/> </page>