Website Downloads Documentation Knowledgebase Wiki Issue tracker Commercial support

Part Editors

Introduction

Starting with Daisy 1.4, the document editor has been changed to make it easy to insert custom editors for parts.

Configuration

The rules for detecting which part editor to use are as follows:

  • if there is part specific editor configured, use that
  • if the "Daisy HTML" flag of the part type is true, use the HTML editor
  • in all other cases, show the upload-editor

To use a custom editor for a certain part, a file called <partTypeName>.xml should be created in the following directory:

<wikidata directory>/resources/parteditors/

The file should contain some XML like the following:

<?xml version="1.0"?>
<partEditor xmlns="http://outerx.org/daisy/1.0#parteditor"
        class="...">
  <properties>
    <entry key="...">...</entry>
  </properties>
</partEditor>

The class property of the partEditor element should contain the class name of a class implementing the following interface:

org.outerj.daisy.frontend.editor.PartEditorFactory

The properties element is optional and can be used to configure the part editor.

Besides the default editors, there is one example editor included in Daisy: a plain text editor. Suppose you have a part called MyPlainText and you want to use this editor for it, you need to create a file called MyPlainText.xml in the above mentioned directory, and put the following XML in it:

<?xml version="1.0"?>
<partEditor xmlns="http://outerx.org/daisy/1.0#parteditor"
        class="org.outerj.daisy.frontend.editor.PlainTextPartEditor$Factory">
</partEditor>

Once you save this file, the editor will become immediately active (no need to restart the Wiki). If you do not see the editor, check the cocoon error log.

Implementation info

A part editor is implemented by means of a CForm (Cocoon Form). This consists of a form definition and a form template. To fit into Daisy's document editor framework, there are two things you need to pay attention to:

  • The form definition should declare an action with id "dummy", as follows:
    <fd:action id="dummy">
      <fd:label>dummy action</fd:label>
    </fd:action>
    

    This action is needed for the working of the document editor, you simply need to add it and not care about it otherwise (i.e. you do not need to insert it into your form template).

  • The form template should not contain a ft:form-template element, as it will be embedded inside the document editors' template.

Besides the form definition and template, you need to implement the interface org.outerj.daisy.frontend.PartEditor (and corresponding PartEditorFactory). This interface defines methods that will be called for constructing, loading and saving of the form.

To learn more, it is best to explore the sources of the default Daisy part editors.

Comments (0)
Advertisement

Daisy hosting, installation, support. Workshops and turnkey Daisy CMS projects. Get Daisy from its creators.

outerthought.org

Downloads provided by

SourceForge.net Logo

Open source stats