Skip to main content

 Tutorials

Task-driven tutorials and recipes for PageSeeder

How to create a document publish task

Skills requiredXML
Time required (minutes)15
Intended audienceDeveloper
DifficultyEasy
CategoryDocument

Objective

This tutorial shows you how to create a simple publish task for a document.

PageSeeder provides a publishing framework to let you process, export or publish PageSeeder documents. By creating a publish task, we provide this options in the user interface.

Prerequisites

  • You are a project manager or contributor for your group.
  • You know how to navigate folders and create documents.
  • You are comfortable editing some basic XML

Tutorial

Follow the step below to create a publish task for a document, that simply exports the document out.

Create ant task

In this step, we only create the Ant task 

  1. Go to the Project administration or Group administration page ( icon)
  2. Go to the Template files page 
  3. Create a build.xml file under the "[project]/psml/default/publish" folder
  4. Edit the build.xml to include
<?xml version="1.0"?>
<project name="publish" xmlns:ps="antlib:com.pageseeder.publishapi.ant">


</preject>
  1. Create the Ant target
     <?xml version="1.0"?>
     <project name="publish" xmlns:ps="antlib:com.pageseeder.publishapi.ant">

+      <target name="tutorial-task" description="Sample task">
+
+      </target>

     </preject>

The ant target is the 

  1. Inside the target, add the <ps-config/> element
       <target name="tutorial-task" description="Sample task">

+        <ps:config />
+
       </target>

The <ps:config> element initialises Ant environment to make sure that all the properties about the current context (document, group, user) are available as ant properties

  1. After add the <echo> element to display text on the console
       <target name="tutorial-task" description="Sample task">

         <ps:config />
 
+        <echo>Sample publish task</echo>
+
       </target>

We now have a simple task that loads the configuration and displays some text on the console.

Update document config

In this step, we register our task on the document config, to make the task available in the user interface.

From the Template files page of your project,

  1. Create the document-config.xml file under the "[project]/psml/default" folder
  2. Create the <publishing> element if it does not already exist
+     <publishing>
+
+     </publishing>

This part of the document config file defines the publishing options for the document.

  1. Create <action type="publish"> element if it does not exist
      <publishing>
+       <action type="publish">
+
+       </action>
      </publishing>

This element lets you define the possible task under the publish, export or process tab. We create an action of type ‘publish’ to match the folder where we’ve created our Ant task.

  1. Add a reference to your Ant task with the <target> element
      <publishing>
        <action type="publish">
+         <target name="tutorial-task" role="manager">
+           <description>A simple task for learning</description>
+         </target>
        </action>
      </publishing>

The target name must match the name of the target in your Ant file. The description element is used to show what the task does in the user interface.

Run task

In this step, we check that the Ant task is visible and can be triggered from the user interface

  1. Go to a document of type Default in your group
  2. Open the Document export, publish & process panel ( icon)
  3. Open to Publish tab
  4. Select the task that you’ve created in the drop-down
  5. Click Run

Notes

In this tutorial, we create a Publish task, to create an Export or Process task, simply define the task in the appropriate folder. There is no technical difference between these, it only affects how they are presented to the user.

Created on , last edited on

Available tutorials