Optional Plugins

Optional PubTal Plugins.

Plugins

Plugins can be used to add support for additional content types or upload methods.  Several plugins are installed by default, and the content types that they provide are described elsewhere in this manual.

Several plugins are provided that are not installed by default, but included with PubTal in the "optional-plugins" directory.  These are documented here.

  • pytextile.py - This plugin provides support for Textile and requires pyTextile  and Python 2.2 to be installed.
  • abiwordContent - This plugin provides support for using the AbiWord application to author web pages.  AbiWord has in the past saved corrupted files, so use with caution.
  • CSVPlugin - Provides support for generating multiple web pages based on the contents of a .CSV file.

Textile

The pytextile.py plugin provides support for the Textile content type.  In addition to the properties listed in the Template Basics section, Textile content also generates an additional property: rawContent.

This is available on the page object (i.e. the TAL path is page/rawContent), and holds a copy of the Textile content in its unparsed form.

Abiword

The abiwordContent plugin provides support for the Abiword content type.  In addition to the properties listed in the Template Basics section, Abiword content also generates an additional property: footnotes.

This is available on the page object (i.e. the TAL path is page/footnotes), and holds a list of footnotes.  These can be used in a template as follows:

<div>
  <div tal:repeat="footnote page/footnotes" tal:replace="structure footnote">Foonotes go here</div>
</div>

CSVSortedTables

This is a complex content type provided by CSVPlugin.  The plugin registers the file extension *.csvst as containing CSVSortedTables content.  The file format of the *.csvst file is similar to that of the PubTal site configuration file, i.e. directives with options.  The file defines a source CSV file that contains comma separated values, with the first row in the file being the name of each column.  The file then goes on to define the pages that should be produced based on the CSV file, including any sorting that should be applied to the data.

Here is an example of a *.csvst file that demonstrates all of the options available:

source-file employees-file.csv
<Page employeesByName.html>
header title Employees sorted by Name
  <sort name>
  </sort>
</Page>
<Page employeesByLevel.html>
header title Employees sorted by Level, then Name
  <sort level>
  value VP 0
  value Manager 1
  value Team Lead 2
  empty-value 3
  </sort>
  <sort name>
  </sort>
</Page>

The source-file option must come first, and specifies the source CSV data file (relative to the *.csvst file).  The <Page pageName.html> directives can contain header options that define name-value pairs.  The pageName.html is the exact name of the page to be generated.

The <sort column-name> directives must be nested within the <Page> directives, and define how the data should be sorted.  The order of the <sort> directives defines which column is sorted first.  Within the directive two options can be used: value and empty-value.  The value option is used to map a column value to a sort priority; the lower the priority the higher up in the list it appears.  The empty-value option defines the sort priority to use for an empty value.  If no options are specified the column will be sorted by alphabetical order.

Template Properties

The CSVSortedTables content type provides the CSV data through page/content as a list.  To access column values for a particular row use the name of the column.  As an example the template for the employee csvst file above could be:

<table>
  <tr>
    <th><a href="employeesByName.html">Employee Name</a></th>
    <th><a href="employeesByLevel.html">Employee Level</a></th>
  </tr>
  <tr tal:repeat="employee page/content">
    <td tal:content="employee/name"></td>
    <td tal:content="employee/level"></td>
  </tr>
</table>
Last Modified: Sat, 07 Feb 2015 12:35:15 GMT

Made with PubTal 3.5

Copyright 2017 Colin Stewart

Email: colin at owlfish.com