orion.core.contenttype

The content type service tells Orion about a new kind of file. The content types contributed to this service don't have any direct effect on the Orion UI, but they can be referred to by other services that need to associate themselves with a particular kind of file. For an example, see orion.navigate.openWith.

The Orion client UI defines a bunch of content types by default: see webEditingPlugin.html in the client UI code.

Service attributes

contentTypes
An Array containing one or more content types to register. Each element of the array defines a new content type, and must have this shape:
id
String The unique identifier of the content type. This is a simple hierarchical name and should start with a category like "text" or "image".
name
String The user-readable name of the content type.
extension
String[] Optional. Array of file extensions characterizing this content type. (Extensions are given without the leading "." character).
filename
String[] Optional. Array of filenames characterizing this content type. Use this when a type does not have a characteristic file extension, but rather a filename. (For example, "Makefile", "README", "passwd").
extends
String Optional. If this content type is a subtype of another, this gives the parent content type's ID.
image
String Optional. URL of an image to display beside files of this type (for example, in the Orion navigator).

Service methods

None. This service is purely declarative.

Example

This example code contributes contributes a new content type for Perl files. A Perl file extends from "text/plain" and has the extension .pl.

 provider.registerServiceProvider("orion.core.contenttype", {}, {
   contentTypes: [{  id: "application/perl",
                     name: "Perl",
                     extension: "pl",
                     "extends": "text/plain"
                  }] });
 provider.connect();

The example code below contributes a new content type for Ant build files. An Ant build file is a special kind of XML file that always has the name "build.xml".

 provider.registerServiceProvider("orion.core.contenttype", {}, {
   contentTypes: [{  id: "text/ant",
                     name: "Ant build file",
                     filename: "build.xml",
                     "extends": "application/xml"
                  }] });
 provider.connect();