This wiki is locked. Future workgroup activity and specification development must take place at our new wiki. For more information, see this blog post about the new governance model and this post about changes to the website.
OSLC_logo.png

Open Services for Lifecycle Collaboration
Core Specification Version 2.0 UI Preview

This Version

Latest Version Authors
  • Scott Bosworth
Contributors

Table of Contents

License

88x31.png
This work is licensed under a Creative Commons Attribution License.

Notation and Conventions

The key words "MUST", "MUST NOT", "REQUIRED, SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY" and "OPTIONAL" in this document are to be interpreted as described in RFC-2119. This document is a mixture of normative and informative text. See the the glossary below for definitions of these terms.

Introduction

This document outlines a technique that MAY (see OSLC Core: UI Previews) be used to show a user in-context information when displaying a link to a resource, and to show more information when the user's mouse lingers over the link. For example, when a lifecycle resource is being presented to a user, a descriptive title can be used (rather than a URI) to display a link to a related resource . Since a descriptive title alone might not provide the user with sufficient context to decide whether the link is worth navigating at that moment, the user may linger over the link and cause the user interface to provide additional rich previews revealing even more information about the related resource (in advance of actually navigating the link).

This specification describes a mechanism that enables client applications, given only the URI of a resource, to discover helpful information for presenting in-context links and previews of that resource. The approach (1) acknowledges that a lifecycle resource may refer to other resources of arbitrary types, and (2) does not require the client to know much about the particular details of those resources.

Terminology

The following terms are used in discussions of previews:

  • Consumer - a web application displaying a link to a resource.

  • Provider - a Service Provider that offers Consumers information for displaying the link to a resource and rich previews of the resource.

Conceptual Model

To enable previews of a target resource, a Provider needs to supply the Consumer with a representation of the resource as defined in this specification (referred to as a Compact representation). The Consumer fetches the representation with an HTTP GET request to the target resource's URI, using the application/x-oslc-compact+xml media-type in the request header. If the Provider supports the preview mechanism, it responds with a Compact representation that includes information helpful to the Consumer in displaying a link and previews of the target resource.

The Compact representation MUST be in the XML format described in this document (see XML Representation Format below). The media-type ( application/x-oslc-compact+xml) MUST be included in HTTP accept and response headers for successful negotiation of the Compact representation.

Representing a Resource for UI Preview

As mentioned, a referenced resource may be of any arbitrary type, however the information in a Compact representation of that resource is expected to contain specific information. For clarity and convenience, we've described that information below using the same terminology and format used in describing OSLC resources and properties. The locale for Strings is negotiated using HTTP-defined mechanisms.

Representation: Compact

The Compact document is an XML document, even though it may be valid RDF/XML, it should be processed as an XML document. The typical rendering client of the Compact document and UI Preview is a Web browser.

  • Media-type: application/x-oslc-compact+xml
  • Properties:

Property Value-type Occurs Description
dcterms:title String zero-or-one Title which may be used in the display of a link to the resource. The value SHOULD include only content that is valid inside an HTML <span> element. Providers SHOULD include a dcterms:title property with an informative label for the resource. The title is typically shown to a user as a hyperlink. For a resource with no obvious title, Providers SHOULD omit the dcterms:title property. Providers MUST first HTML escape the contents of the dcterms:title before sending the response.
oslc:shortTitle String zero-or-one Abbreviated title which may be used in the display of a link to the resource. The value SHOULD include only content that is valid inside an HTML <span> element. Providers SHOULD include an abbreviated title for the resource when possible. The abbreviated title is typically shown to a user as a hyperlink in presentations where visual space is limited. As a general guideline, the length of the abbreviated title SHOULD be 5 characters or less. A user-visible identifier that ordinarily appears in the dcterms:title, such as a defect number, makes for a good oslc:shortTitle value. When a resource has no obvious identifier or handle, Providers SHOULD omit the oslc:shortTitle property. Providers MUST first HTML escape the contents of the oslc:shortTitle before sending the response.
oslc:icon Resource zero-or-one URI of an image which may be used in the display of a link to the resource. The image SHOULD be 16x16 pixels in size.
oslc:iconAltLabel String zero-or-one Alternative label used in association with the oslc:icon, such as HTML img tag's alt attribute.
oslc:iconTitle String zero-or-one Title used in association with the oslc:icon, such as HTML img tag's title attribute.
oslc:smallPreview Local Inline Resource of type oslc:Preview zero-or-one URI and sizing properties for an HTML document to be used for a small preview.
oslc:largePreview Local Inline Resource of type oslc:Preview zero-or-one URI and sizing properties for an HTML document to be used for a large preview.

Resource: Preview

  • Name: Preview
  • Type URI: http://open-services.net/ns/core#Preview
  • Properties:

Property Value-type Occurs Description
oslc:document Resource zero-or-one The URI of an HTML document to be used for the preview.
oslc:hintWidth String zero-or-one Recommended width of the preview. Values MUST be expressed in relative length units as defined in the W3C Cascading Style Sheets Specification (CSS 2.1). Em and ex units are interpreted relative to the default system font (at 100% size).
oslc:hintHeight String zero-or-one Recommended height of the preview. Values MUST be expressed in relative length units as defined in the W3C Cascading Style Sheets Specification (CSS 2.1). Em and ex units are interpreted relative to the default system font (at 100% size).
oslc:initialHeight String zero-or-one Recommended initial height of the preview. The presence of this property indicates that the preview supports dynamically computing its size. Values MUST be expressed in relative length units as defined in the W3C Cascading Style Sheets Specification (CSS 2.1). Em and ex units are interpreted relative to the default system font (at 100% size).

Provider Responsibilities

Providers that support previews will examine the HTTP Accept header for each incoming GET and HEAD request for a resource. If the header indicates that the client has requested a Compact representation, and if the representation is available for the resource, the Provider responds with a Compact representation. The following constraints apply to Providers:

  • Providers that support the preview mechanism need not do so for every resource. Providers SHOULD provide Compact representations of the resources that other applications or resources ordinarily refer to. This is left to individual Providers to decide.
  • If the resource does not exist or is not accessible to the requesting Consumer, the Provider SHOULD return the same 4xx status code that it would have returned had the Consumer instead requested the default representation of the resource.
  • If the resource exists and is accessible to the Consumer, but does not have a Compact representation (in other words, does not support the preview mechanism), the Provider SHOULD respond with a status code of 406 Not Acceptable ( Section 14.1 of HTTP 1.1 specification says that a server "SHOULD" respond with a 406 status code if it cannot serve up the media-type specified in the accept header).
    • Otherwise, the Provider SHOULD respond with a Compact representation of the resource and a response header including a 200 OK status code and the compact media-type. The representation MUST follow conventions outlined in this document (see XML Representation Format).
  • Providers SHOULD include a Vary field in the response header when returning a Compact representation of the resource. Experience has shown that for subsequent requests on the URL, some browser caching algorithms ignore the media-type and return a cached representation of the URL request (which may be the default target resource representation or the Compact representation). Use of the Vary field allows a cache to properly interpret future requests on the resource and informs the browser that the cacheable response is subject to server-driven negotiation (see Section 14.44 of the HTTP 1.1 specification).
  • Providers MAY consult the Accept-Language field on requests for a Compact representation of the resource (and on requests for rich preview documents) and return a representation for the requested natural language.

Responsibilities for Consumers

Though Consumer implementations will vary, tool users will benefit if the preview mechanism is used consistently. Previews are a valuable added benefit to tool users and not a necessary element for users to perform tasks. As such, Consumers should gracefully handle unsuccessful attempts to use the preview mechanism; unsuccessful attempts should never result in failure in the way a Consumer application operates or performs. Consumers SHOULD anticipate that the preview mechanism may not be supported for a resource, or that the the preview mechanism may not work due to security or service availability issues, or even that preview capability once supported by a Provider has been phased out.

Important: In order to properly recognize when a Provider supports the preview mechanism, Consumers MUST perform two checks on the response from a Compact representation request. Only a response header including a 200 OK status code and compact-media-type assures the Consumer that the preview protocol is understood by the Provider. Though Providers should respond with a 406 Not Acceptable status code when they do not recognize the media-type, Consumers MUST NOT rely on this behavior. Some servers simply ignore an unrecognized media-type and respond with 200 OK and a default representation of the resource. If either the status code or media-type conditions are not met, then Consumers MUST conclude that the Provider does not support the preview mechanism.

The following guidance is suggested for Consumer display of a resource link and rich previews. For purposes of this discussion, assume source resource A has a URI property that refers to target resource B:

Navigation to the target resource
At any time, the user SHOULD be able to gesture that they would like to navigate the link to the target resource, regardless of how the link to the target resource happens to be rendered.
Default way to display the link to the target resource
The typical way for forming and displaying the hyperlink SHOULD be based on information that is stored locally in source resource A (or that is generally known to the Consumer). Generally, link text can be derived from property values of resource A, and potentially from a string or literal property value in the reference to the target resource B, if such a property exists. Because these property values are part of the representation of the source resource A, they are available without consulting the target resource, and will be available even if the target resource B cannot be fetched. When available, Consumers SHOULD display this string (as opposed to the URI) when presenting resource A to indicate a potential navigation to resource B. This is the basic presentation of a link to target resource B.

The default display of the link from A to B is visible to any user authorized to access resource A. The use of Compact representation information described below is only viable for users who are also authorized to access resource B.

Using the Compact representation title, short title, and icon
A Compact representation of the resource may contain a more accurate and slightly richer label for a target resource ( dcterms:title element), a short-form title for the resource ( oslc:shortTitle), and a corresponding image ( oslc:icon), all of which may be based on the current state of the target resource. If this becomes known to the Consumer, the Consumer SHOULD assume that this information is better and use it in forming the hyperlink that is displayed to the user. When available, oslc:shortTitle MAY be used instead of dcterms:title in presentations where visual space is severely limited.

Consumers SHOULD NOT fetch Compact representations when there is perfectly usable default display information available. When designing a Consumer application, consideration should be given to the potential benefits of obtaining an improved title and icon for the target resource against the costs of preemptively fetching the Compact representation in terms of added load on servers and networks (which might only be apparent to users on slow networks or heavily loaded servers).

Consumers SHOULD be wary of material obtained from non-trusted sources; in particular, the Consumer SHOULD check that the dcterms:title and oslc:shortTitle property values do not contain HTML markup beyond the specified set of simple elements.

Displaying a small preview
If a user mouses or hovers over a displayed link, the Consumer SHOULD determine whether the target resource has a small preview (oslc:smallPreview). If it does, the Consumer SHOULD present the small preview document in a hovering widget. Since preview documents may contain arbitrary content, including HTML and scripts, Consumers MUST use iframes if embedding the preview document inside another HTML-based presentation.

The Consumer SHOULD NOT attempt to prefetch a Compact representation just to have the preview URIs in hand so that the hover can come up faster. There is a low chance that the user will make a gesture that would call for the display of a small preview. It would generally be a poor tradeoff to increase overall system load just to decrease UI latency for low probability eventualities.

Displaying a large preview
If the user then gestures that they want to see a bit more of the resource, the Consumer should determine whether the target resource has a large preview ( oslc:largePreview). If it does, the Consumer SHOULD present the large preview document in a stationary widget that permits further user interaction. Again, since preview documents may contain arbitrary content, including HTML and scripts, Consumers MUST use iframes if embedding the preview document inside another HTML-based presentation.

Preview sizing

Small and large previews are designed to be sized statically by the client. The Compact representation MAY include oslc:hintHeight and/or oslc:hintWidth properties for each of the previews. When the resource does not supply preferred sizing for a preview, the Consumer SHOULD use a reasonably generous default value large enough to display previews without scroll bars or truncation. When the resource supplies preferred sizing, the Consumer SHOULD use the preferred value instead.

Small and large previews MAY also support dynamic resizing. For a preview that supports dynamic resizing, the Compact representation MUST include the oslc:initialHeight property to indicate the initial height. A Provider MAY use dynamic resizing previews on some of their resources but not others. Moreover, dynamic resizing applies to the small and large previews independently.

Values for the oslc:hintWidth, oslc:hintHeight, and oslc:initialHeight properties may be valid relative length units as specified in the W3C Cascading Style Sheets Specification (CSS 2.1). Consumers are expected to use these relative length values in combination with other client system settings to scale a rich preview to a size that fits a user's display characteristics. Specifically, em and ex units are meant to be relative to 100% of the default system font size, giving Consumers and Providers a common basis for interpreting em- and ex-value hints. For example, an oslc:hintHeight value of "20em" means "I recommend you allow for 20 character's worth of normal-sized text for my preview."

The communication of dynamic preview size information happens within a web browser. JavaScript code running in the preview iframe sends a message that is received and acted upon by JavaScript code running in the iframe's parenting window. This cross-frame communication is done using HTML 5 postMessage. While many major web browsers support HTML 5 postMessage, support is not yet universal. In browsers that do not support postMessage, there is no way to implement dynamic resizing. In this case, everything falls back on static sizing.

A dynamic preview resize message consists of the characters "oslc-preview-height:" followed by the representation of the desired height of the preview in pixels. Whitespace characters are not allowed.

Example showing desired preview height of 277 pixels:

           oslc-preview-height:277 

The source of the event MUST be the preview's window.

Providers SHOULD make a preview dynamically resizeable where that suits their needs, but are under no obligation to do so. A Provider that chooses to offer dynamic resizing for a particular resource preview MUST (a) supply a static oslc:initialHeight value, and (b) send one or more preview resize messages when the preview is shown in an iframe. When the preview is shown in a web browser that does not support HTML 5 postMessage (e.g., Internet Explorer 7), everything falls back on static sizing.

JavaScript snippet for a typical resource preview to report a preview resize event to its parent window:

var newPreviewHeight = ...; // desired height of preview (hard!)

if (window.postMessage && window.parent)  {
    var PREVIEW_RESIZE_MESSAGE_PREFIX = "oslc-preview-height:";
    var resizeMessage = PREVIEW_RESIZE_MESSAGE_PREFIX + newPreviewHeight;
    window.parent.postMessage(resizeMessage, "*");
 }

Note that postMessage for a preview resize message MUST be executed in the context of the preview's window so that the source of the event is set correctly.

Warning: Reliably computing the height of a document (newPreviewHeight above) is non-trivial owing to severe incompatibilities between browsers. Caveat emptor.

Consumers SHOULD honor a preview's ability to dynamic resize, but are under no obligation to do so. A Consumer that chooses to honor dynamic resizing for a particular preview MUST (a) use the oslc:initialHeight value instead of any static height, and (b) register a handler to receive preview resize messages sent by the preview and adjust the size of the preview accordingly. Since a preview is allowed to resize itself any number of times, the Consumer MUST keep a handler registered and react appropriately each time it received a preview resize message from that preview. When the preview is not shown in an iframe, or shown in a browser that does not support HTML 5 postMessage, everything falls back on static sizing.

Consumers that honor dynamic preview resizing SHOULD make an effort to minimize the amount of resizing behavior that the user actually sees. Consumers SHOULD locally cache the last known dynamic height for recently shown preview URLs, and use a cached height for a preview in preference to its oslc:initialHeight value.

JavaScript snippet for a typical Consumer to show a preview in an iframe:

var previewURL = ...; // from oscl:document attribute for preview 
var previewPreferredPixelHeight = ...; // from oslc:hintHeight property for preview normalized to pixels, or empty string if none 
var previewPreferredPixelWidth = ...; // from oslc:hintWidth property for preview normalized to pixels, or empty string if none 
var previewInitialPixelHeight = ...; // from oslc:initialHeight property for preview normalized to pixels, or empty string if none  

var previewFrame = document.createElement("iframe");  // create iframe for preview 
previewFrame.src = previewURL;
previewFrame.height = (previewPreferredPixelHeight || DEFAULT_PREVIEW_HEIGHT); 
previewFrame.width = (previewPreferredPixelWidth || DEFAULT_PREVIEW_WIDTH);  

if (window.postMessage && previewInitialPixelHeight) {
   previewFrame.height = previewInitialPixelHeight;

   var handlePreviewResize = function(event) { 
        if (event.source !== previewFrame.contentWindow) return; 
        var data = event.data;  
        var PREVIEW_RESIZE_MESSAGE_PREFIX = "oslc-preview-height:"; 
        if (data && data.indexOf(PREVIEW_RESIZE_MESSAGE_PREFIX) === 0) {    
            var newHeight = data.substring(PREVIEW_RESIZE_MESSAGE_PREFIX.length);   
            previewFrame.height = newHeight;    
         } 
    } 
   dojo.connect(window, "onmessage", window, handlePreviewResize);
} 
document.body.appendChild(previewFrame); // make preview iframe visible

XML Representation Format

A representation of a Compact Resource is an XML document that looks like the following (for the target resource URL http://example.com/bugs/12345):


<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dcterms="http://purl.org/dc/terms/"
   xmlns:oslc="http://open-services.net/ns/core#">

 <oslc:Compact
   rdf:about="http://example.com/bugs/12345">

   <dcterms:title> 12345: Need a &quot;fix&quot; &lt;em&gt;NOW&lt;/em&gt; </dcterms:title>
   <oslc:shortTitle> 12345 </oslc:shortTitle>
   <oslc:icon rdf:resource="http://example.com/icons/defect.jpg" />
   <oslc:iconAltLabel>Defect</oslc:iconAltLabel>
   <oslc:iconTitle>Defect</oslc:iconTitle>

   <oslc:smallPreview>
      <oslc:Preview>
         <oslc:document rdf:resource="http://example.com/bugs/12345?hover=small" />
      </oslc:Preview>
   </oslc:smallPreview>


   <oslc:largePreview>
      <oslc:Preview>
         <oslc:document rdf:resource="http://example.com/bugs/12345?hover=large" />
         <oslc:hintWidth> 60em </oslc:hintWidth>
         <oslc:hintHeight> 20em </oslc:hintHeight>
      </oslc:Preview>
   </oslc:largePreview>

 </oslc:Compact>

</rdf:RDF>

The XML representation has the following syntactic and semantic constraints:

  • The root element MUST be rdf:RDF and SHOULD identify the namespaces for RDF ( http://www.w3.org/1999/02/22-rdf-syntax-ns#), Dublin Core ( http://purl.org/dc/terms/), and OSLC ( http://open-services.net/ns/core#), as well as namespaces for any additional Provider supplied properties.
  • The oslc:Compact element MUST be a child of the root element and MUST specify an rdf:about attribute whose value is the URI of the target resource.
    • The oslc:Compact element MAY have any number of child elements, including none. Each child element specifies one property of the target resource. The order of child elements is not significant.
    • Each of the dcterms:title, oslc:shortTitle, oslc:icon, oslc:smallPreview, and oslc:largePreview child elements MAY occur at most once.
    • The content of a dcterms:title or oslc:shortTitle element MUST be limited to any XHTML <span> element. To afford clients the greatest flexibility to style the text to match the context in which it is being displayed, the titles SHOULD be plain text with XHTML markup used only to emphasize words or phrases or to convey additional information about the target resource.
    • An oslc:icon element MUST have an rdf:resource attribute whose value is a URI of an image. The image SHOULD be 16x16 pixels in size.
    • The oslc:iconAltLabel and oslc:iconTitle elements MUST only have string content.
    • The oslc:smallPreview and oslc:largePreview elements MAY have any number of child elements, including none.
      • The oslc:Preview element MUST be a child of an oslc:smallPreview or oslc:largePreview element and MAY occur at most once.
        • An oslc:Preview element MAY have any number of child elements, including none. Each child element specifies one property of the Preview. The order of child elements is not significant.
        • Each of the oslc:document, oslc:hintWidth, oslc:hintHeight, and oslc:initialHeight child elements MAY occur at most once.
        • The oslc:document element MUST have an rdf:resource attribute whose value is a URI of a document containing a preview of the resource.
        • The content of an oslc:hintWidth, oslc:hintHeight, or oslc:initialHeight element MUST be a valid relative length value.
  • All elements MAY have additional atttributes not specified here. All elements, other than dcterms:title and oslc:shortTitle, MAY include additional child elements not specified here. Consumers MUST quietly ignore unknown elements and attributes encountered in a Compact representation.

References

Topic revision: r28 - 03 Aug 2012 - 19:03:07 - SteveSpeicher
 
This site is powered by the TWiki collaboration platform Copyright by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Contributions are governed by our Terms of Use
Ideas, requests, problems regarding this site? Send feedback