Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

1. Determine the Media Type

All media element supported by Sousa must have a file extention and MIME type associated with them. Generally, standard MIME types should be used. See http://www.feedforall.com/mime-types.htm for an all in one list, or the official list at http://www.iana.org/assignments/media-types/.

1a. Resource Tool Types

In some cases, the Sakai Resource tool has already defined a media type. The following line in AddItemProducer (in the Page tool) can be enabled to see all media types going by:

...

Thus we learn that the item "Nolaria.com" has a media type of "text/url".

1b. Registering the Media Type

Media types are registered in the ContentElementHandler class of the Sousa content handler package (sousa-content/util). Create a new registered type using code like this:

Code Block
java
java

//	Add the URL media type.
handler = new CEUrl();
this.media.put ("text/url", handler);
this.types.add (new MediaType("text/url", "url", "URL", handler));

If several extensions or MIME types are managed by the same handler, add them.

2. Create a ContentElement Class

...

2d. Content Editing Methods

Editing media content falls broadly into two categories at this time: editable text and uploaded files. Future work may include custom editors for specific media types (an equations editor, for example).

Editable Text

To add an editable text field, create a prompt in the Page tool message bundle and add code similar to the following:

Code Block
java
java

UIMessage.make(tofill, "edit-label", "st_plain_text_label");
String content = contentItem.getEditContent();
if ((content == null) && (contentItem.getId() != null)) {
	byte[] bytes = contentItem.getContent();
	content = new String (bytes);
}
		UIInput.make(tofill, "edit-input-textarea", "#{uploaditem.content}", content);

This field can be used to either create and edit existing text, or allow information to be cut and pasted (typically XML, though not required).

Upload File

All support for uploading of files is already present in Sousa. To indicate that this element is based on an uploaded file, create a prompt in the Page tool message bundle and force the UIInput into existence as follows:

Code Block
java
java

//	Set up the file upload field.
UIMessage.make(tofill, "edit-label", "st_csv_file_label");
UIInput.make(tofill, "edit-input-file", null, "");

2e. Parameter Editing Methods

...