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)
Line 3: Line 3:
 
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.
 
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 =
+
= orion.core.linkScanner =
  
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.
+
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 [[Orion/Documentation/Developer_Guide/Core_client_services#orion.core.textlink| text link]] service to convert text into a DOM node with appropriate anchor and text nodes as children.
  
 
== Service methods ==
 
== Service methods ==
Line 11: Line 11:
  
 
== Service attributes ==
 
== Service attributes ==
Implementations of <tt>orion.page.link</tt> must define the following attributes:
+
Implementations of <tt>orion.core.linkScanner</tt> must define the following attributes:
  
;name
+
;pattern
:A human readable link name, typically used as an HTML anchor element body, or in a tooltip.
+
:A regular expression string to locate links in the source text
;id
+
;words
:A symbolic id for referencing this link.
+
:A <tt>Number</tt> identifying the number of white-space delimited words in each match
;href
+
;anchor
: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.
+
: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 ==
 
== Examples ==
  
The following snippet defines the main links that are shown in a default Orion installation.
+
The following scanner will replace text of the form "bug 123456" with links of the form "https://bugs.eclipse.org/123456
  
  var serviceImpl = {};//no service methods required
+
var provider = new eclipse.PluginProvider();
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
+
var serviceImpl = {};
      name: "Navigator",
+
var serviceProperties = {  
      id: "orion.navigator",
+
  pattern: "bug\\s\\d{4,7}",
      href: "/navigate/table.html#"
+
  words: 2,
  });
+
  anchor: "https://bugs.eclipse.org/%2"
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
+
};
      name: "Sites",
+
provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
      id: "orion.sites",
+
provider.connect();
      href: "/sites/sites.html"
+
  });
+
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
+
      name: "Repositories",
+
      id: "orion.repositories",
+
      href: "/git/git-repository.html#"
+
  });
+
  
= orion.page.link.related =
+
This scanner will replace email addresses with mailto: URLs:
  
The related link service provides a mechanism for plugins to contribute links to the "Related pages" menu in the Orion page headerCurrently, 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."
+
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();
  
 
= orion.page.content =
 
= orion.page.content =
Line 92: Line 93:
 
       contentType: ["image.gif", "image.jpeg", "image.ico", "image.png","image.tiff"]});
 
       contentType: ["image.gif", "image.jpeg", "image.ico", "image.png","image.tiff"]});
  
= orion.core.linkScanner =
+
= orion.page.link =
  
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 [[Orion/Documentation/Developer_Guide/Core_client_services#orion.core.textlink| text link]] service to convert text into a DOM node with appropriate anchor and text nodes as children.
+
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 ==
 
== Service methods ==
Line 100: Line 101:
  
 
== Service attributes ==
 
== Service attributes ==
Implementations of <tt>orion.core.linkScanner</tt> must define the following attributes:
+
Implementations of <tt>orion.page.link</tt> must define the following attributes:
  
;pattern
+
;name
:A regular expression string to locate links in the source text
+
:A human readable link name, typically used as an HTML anchor element body, or in a tooltip.
;words
+
;id
:A <tt>Number</tt> identifying the number of white-space delimited words in each match
+
:A symbolic id for referencing this link.
;anchor
+
;href
: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.
+
: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 ==
 
== Examples ==
  
The following scanner will replace text of the form "bug 123456" with links of the form "https://bugs.eclipse.org/123456
+
The following snippet defines the main links that are shown in a default Orion installation.
  
var provider = new eclipse.PluginProvider();
+
  var serviceImpl = {};//no service methods required
var serviceImpl = {};
+
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
var serviceProperties = {  
+
      name: "Navigator",
  pattern: "bug\\s\\d{4,7}",
+
      id: "orion.navigator",
  words: 2,
+
      href: "/navigate/table.html#"
  anchor: "https://bugs.eclipse.org/%2"
+
  });
};
+
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
provider.registerServiceProvider("orion.core.linkScanner", serviceImpl, serviceProperties);
+
      name: "Sites",
provider.connect();
+
      id: "orion.sites",
 +
      href: "/sites/sites.html"
 +
  });
 +
  provider.registerServiceProvider("orion.page.link", serviceImpl, {
 +
      name: "Repositories",
 +
      id: "orion.repositories",
 +
      href: "/git/git-repository.html#"
 +
  });
  
This scanner will replace email addresses with mailto: URLs:
+
= orion.page.link.related =
  
var provider = new eclipse.PluginProvider();
+
The related link service provides a mechanism for plugins to contribute links to the "Related pages" menu in the Orion page headerCurrently, 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."
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();
+

Revision as of 11:35, 13 April 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.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();

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. Pages contributed in this way are opened in a URL that specifies the id of the extension.

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. Variables supplied to the template include {OrionHome}, the fully qualified path name of the Orion extension, {Location}, the path to the Orion resource (if applicable), {Name}, the name of the Orion resource (if applicable), {SaveURL} a URL that can be used to save content back to Orion.
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"});

The URL to open this page is /content/content.html#{Location},contentProvider=orion.pixlr.content

If the page content requires a resource location (for example, it is an editor), then typically the page would be linked using the orion editor extension point. This ensures that the page were opened with a specified location parameter in the URL. The pixlr plugin contributes an editor in this way.

  provider.registerServiceProvider("orion.edit.editor", {}, {
     id: "orion.pixlr",
     name: "Pixlr Image Editor",
     uriTemplate: "{OrionHome}/content/content.html#{Location},contentProvider=orion.pixlr.content"});

The corresponding "open with" extension point is

  provider.registerServiceProvider("orion.navigate.openWith", {}, {
     editor: "orion.pixlr",
     contentType: ["image.gif", "image.jpeg", "image.ico", "image.png","image.tiff"]});

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."

Back to the top