Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Orion/Documentation/Developer Guide/Plugging into Orion pages"

(orion.page.content)
(Examples)
Line 71: Line 71:
  
 
   provider.registerServiceProvider("orion.page.content", {}, {
 
   provider.registerServiceProvider("orion.page.content", {}, {
id: "orion.pixlr.content",
+
      id: "orion.pixlr.content",
name: "Pixlr",
+
      name: "Pixlr",
saveToken: ["imgapi?image=","imgapi&image="],
+
      saveToken: ["imgapi?image=","imgapi&image="],
saveTokenTerminator: "&",
+
      saveTokenTerminator: "&",
uriTemplate: "http://pixlr.com/editor/?image={OrionHome}{Location}&referrer=Orion&title={Name}&locktype=true&exit={ExitURL}&target={SaveURL}imgapi&locktitle=true,contentProvider=orion.pixlr.content"});
+
      uriTemplate: "http://pixlr.com/editor/?image={OrionHome}{Location}&referrer=Orion&title={Name}&locktype=true&exit={ExitURL}&target={SaveURL}imgapi&locktitle=true,contentProvider=orion.pixlr.content"});
  
 
= orion.core.linkScanner =
 
= orion.core.linkScanner =

Revision as of 09:44, 26 March 2012

Overview of plugging into Orion pages

The following services allow plugins to contribute links and other forms of connectivity between an Orion page and other web pages. Services in this section can be used on any Orion page, rather than operating on any specific page. Page authors can make use of these services to allow extensible connectivity between their page and others.

orion.page.link

The link service provides a mechanism for plugins to add links that should appear in the main header of Orion pages. Clients supply the link name and URL. The header code will look for implementors of this service when generating page headers for Orion.

Service methods

None.

Service attributes

Implementations of orion.page.link must define the following attributes:

name
A human readable link name, typically used as an HTML anchor element body, or in a tooltip.
id
A symbolic id for referencing this link.
href
The anchor's hypertext reference. This should be an absolute URL because the service implementation won't know anything about the position of the pages that may choose to insert this link.

Examples

The following snippet defines the main links that are shown in a default Orion installation.

  var serviceImpl = {};//no service methods required
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
     name: "Navigator",
     id: "orion.navigator",
     href: "/navigate/table.html#"
  });
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
     name: "Sites",
     id: "orion.sites",
     href: "/sites/sites.html"
  });
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
     name: "Repositories",
     id: "orion.repositories",
     href: "/git/git-repository.html#"
  });

orion.page.link.related

The related link service provides a mechanism for plugins to contribute links to the "Related pages" menu in the Orion page header. Currently, a related link must first be defined as a command in "orion.navigate.command." Then, the command id should be referenced in the service definition for the "orion.page.link.related" extension. When any page is loaded in Orion, it will evaluate its resource against the validationProperties for the command. If the page's resource is valid for the command, then the command will appear in "Related pages."

orion.page.content

Plugins can contribute page content for a page that is framed by the common Orion banner and equipped with standard Orion page services, such as the related pages menu. The page content itself is rendered in an iframe inside the page.

Service methods

None.

Service attributes

Implementations of orion.page.content must define the following attributes:

name
The name of the content, which is shown as the page title in the Orion banner.
id
A symbolic id for referencing this extension point.
uriTemplate
a URI template that defines the href for the iframe content. The template may refer to the following variables:
saveToken
an optional String or array of Strings describing token(s) that appear in the URL of the page that saves the content. The saveToken is used to find the location of the saved content.
saveTokenTerminator
an optional String or array of Strings describing the strings that terminate the save token.

Examples

The following snippet defines an orion.page.content extension for showing the Pixlr image editor inside Orion.

  provider.registerServiceProvider("orion.page.content", {}, {
     id: "orion.pixlr.content",
     name: "Pixlr",
     saveToken: ["imgapi?image=","imgapi&image="],
     saveTokenTerminator: "&",
     uriTemplate: "http://pixlr.com/editor/?image={OrionHome}{Location}&referrer=Orion&title={Name}&locktype=true&exit={ExitURL}&target={SaveURL}imgapi&locktitle=true,contentProvider=orion.pixlr.content"});

orion.core.linkScanner

Link scanners are declarative services that specify patterns of text to replace with link anchors. Scanners contribute a regular expression pattern to match in the source text. They then provide a link to be inserted for each match. These scanners are used by the text link service to convert text into a DOM node with appropriate anchor and text nodes as children.

Service methods

None.

Service attributes

Implementations of orion.core.linkScanner must define the following attributes:

pattern
A regular expression string to locate links in the source text
words
A Number identifying the number of white-space delimited words in each match
anchor
A template of the URL for each match. The template may contain variables of the form %1, %2, etc, which are substituted by each of the words in the match.

Examples

The following scanner will replace text of the form "bug 123456" with links of the form "https://bugs.eclipse.org/123456

var provider = new eclipse.PluginProvider();
var serviceImpl = {};
var serviceProperties = { 
  pattern: "bug\\s\\d{4,7}",
  words: 2,
  anchor: "https://bugs.eclipse.org/%2"
};
provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
provider.connect();

This scanner will replace email addresses with mailto: URLs:

var provider = new eclipse.PluginProvider();
var serviceImpl = {};
var serviceProperties = { 
  pattern: "\\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b",
  words: 1,
  anchor: "mailto:%1"
};
provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
provider.connect();

Back to the top