Advanced

Advanced topics

 

Integration with PageSeeder

The Website engine is designed to be loosely coupled with PageSeeder. It can be deployed on its own server and generally does not require a connection to PageSeeder. But it has been designed to work with PageSeeder documents right-out-of the box with minimal configuration.

There are a lot of possible integration points with PageSeeder, this document covers the most common use cases.

Publishing PSML data

The most common solution is to use the Publish Engine to export PageSeeder documents for viewing online. The Universal format acts as a data interface between PageSeeder and the Website.

Configuring PageSeeder

The simplest model, is to store all the website content into a single PageSeeder group.

A common convention is to create a /website folder in your documents (at the same level as /attachments, /images, etc.). This is because it enables the group to be used for storing documents which are not meant to be published but may be necessary as part of the editorial process.

Within the /website folder, another common convention is to create the /config and /content folders. The former is used to stored all the documents used that are not viewed on their own such as the navigation, menus, footers, etc. The latter is for the actual content.

Finally, you will need to setup your Publish/publishConfig.xml to determine what publish actions can be used. Generally, it is useful to define a publish action for the entire group, a folder and a PageSeeder document.

See example below to publish a group and a folder:

<publish>
  <action>
    <name>Publish online</name>
    <type>ant</type>
    <script>group/build.xml</script>
    <description>Publish entire website online</description>
    <source type="group" />
  </action>
  <action>
   <name>Publish online</name>
    <type>ant</type>
    <script>folder/build.xml</script>
    <description>Publish this folder online</description>
    <source type="folder" />
 </action>
  ...
</publish>

Configuring the publisher

Publishing PageSeeder data on the site can be done via a set of publish scripts. The role of each script is two-fold:

  1. Exporting the PageSeeder document as PSML files using universal format. This can easily be achieved by using the <ps:export> Ant task.
  2. Sending the PSML files (e.g. using a file copy or FTP) to the website.

Note

In order to ensure that published documents are always going to end up in the correct place, it is important to always use the same reference point using the @context attribute of the export task.

Website properties

It also a good idea to store the website properties such as the URL and system path in a properties file so that all Ant build files can reuse it.

For example  /Publish/folder/website.properties

# Path to the target Berlioz Web Application
external.location=/usr/berlioz/acmesite

# URL to access the target Berlioz Web Application
external.url=https://acme.example.net

Build files

The publish script is a simple Ant file that will export and copy the PSML to the website.

Below is a sample build file to publish a folder (it should be on the Publisher as /Publish/folder/build.xml)

<project name="publish-online" xmlns:ps="antlib:com.pageseeder.publishapi.ant">

  <!-- Main task visible in the PageSeeder UI -->
  <target name="publish-website-folder" description="Publish this folder online">

    <!-- Load PageSeeder configuration and website properties -->
    <ps:config />
    <loadproperties srcFile="../config/website.properties"/>

    <!-- Creating a working directory -->
    <tempfile property="local.working" prefix="${ps.config.default.group.name}-" destdir="${java.io.tmpdir}"/>
    <mkdir dir="${local.working}"/>

    <!-- Export -->
    <ps:export src="${ps.config.default.uri.path}"
           context="${ps.config.default.group.folder}/website"
              dest="${local.working}" />

    <!-- Moving all PSML files to website root -->
    <move todir="${external.location}/WEB-INF/psml/${ps.config.default.group.name}" includeEmptyDirs="false">
      <fileset dir="${local.working}" includes="**/*.psml,META-INF/**" />
    </move>

    <!-- Move all non-PSML files to website root -->
    <move todir="${external.location}/${ps.config.default.group.name}/" includeEmptyDirs="false">
      <fileset dir="${local.working}/" includes="content/**, public/**" excludes="**/*.psml" />
    </move>

    <!-- Deleting working directory -->
    <delete dir="${local.working}"/>

  </target>

</project>

For more options on how to configure the publish engine, see the guide to the publish engine.

Configuring Berlioz

Bastille provides a collection of generators designed to work with PSML data in the com.weborganic.bastille.psml package. One of the most useful generators is the GetContentFileAuto generator which uses the path in the URL to fetch the corresponding file in the /WEB-INF/psml/content folder in your Web application.

<generator class="com.weborganic.bastille.psml.GetContentFileAuto" ... />

Browse the Berlioz generators in the API documentation for details.

Created on , last edited on