Home My Page Projects FusionForge
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files Mediawiki Hudson/Jenkins

FusionForge

Compact Preview Plugin

From FusionForge Wiki
(Redirected from CompactPreview plugin)
Jump to: navigation, search
Name
Compact Preview Plugin
Description
A very interesting feature of OSLC is the compact previews which enables the display of resources in a compact way inside UIs.
Directory
/plugins/compactpreview
Plugin Changelog
Plugin Changelog for compactpreview
Maintainer(s)
Status
maintained
Compatibility
undefined


OSLC Compact Previews

Contents

  • 1 Specs of OSLC compact previews
  • 2 Implementation in FusionForge
  • 3 How it works
    • 3.1 A concrete example
      • 3.1.1 A Special resource link
      • 3.1.2 Ajax call by the client script
      • 3.1.3 Loading the RDF document of the compact preview
      • 3.1.4 Loading the HTML document of the compact preview
      • 3.1.5 Integration with gravatar plugin
    • 3.2 Other resource types covered

Specs of OSLC compact previews

A very interesting feature of OSLC is the compact previews which enables the display of resources in a compact way inside UIs.

This part of OSLC is specified here: open-services.net/bin/view/Main/OslcCoreUiPreview

Implementation in FusionForge

The compactpreview plugin implements the compact preview OSLC feature. It consists in displaying inside a Javascript tooltip a summary of a resource when you hover with the mouse on that resource's link. Currently, compact previews for users and projects are implemented. Other resource types will be added like tracker tickets.

So, for the user browsing the site, displaying a resource compact preview in a tooltip is as simple as "hovering" with the mouse on that resource link.

Here is an explanation of the way it works and how it is integrated with FusionForge.

Three main components needs to be available to create these compact previews:

  • The compact document describing the resource. This document should be identified with a URI.
  • An RDF document containing the compact document URI and describing some of the tooltip properties like width and heigth.
  • A client script that knows how to trigger the tooltip display and loads inside it the compact document describing the ressource.

How it works

Displaying a compact resource preview in a tooltip need the execution of the following steps:

  1. The client script requests the resource page with a specific "Accept" header using a "GET" HTTP request to that resource's page URL in the forge.
  2. Based on a content negociation mechanism, the server responds by delivering the RDF document of the compact ressource.
  3. The client script parses the returned RDF document and gets from it the URI of the compact document describing the resource.
  4. The client scripts loads the compact document inside the tooltip.

A concrete example

Here is a concrete example that helps understanding all that. We will display a user compact preview in a tooltip.

A Special resource link

There should be a user link that points to that user's page. Example, user is 'labbenes':

<a class="resourcePopupTrigger" class="https://fftrunk/users/labbenes/" rel="user,labbenes">labbenes</a>
  • 'class' property of this user link will be used by the client script to build toolTip.
  • 'href' property makes the link points to labbenes's page in FusionForge.
  • 'rel' property contains the params we pass to the client script. In this example, the first part of the param string indicates it is a ressource of type 'user'. The second part gives the resource id which is labbenes in our example.

Usually a user link in FusionForge doesn't contain all these properties. It just links to the user page. We build this kind of links meaning a hook of the OSLC plugin. the hook is named 'user_link_with_tooltip'. Whenever a plugin responds to that hook call and returns such a link, we display it instead of the classic link to user page. This hook call was added to util_display_user() function in 'common/include/utils.php'.

Ajax call by the client script

The client script will now requests the user page through an XMLHTTPRequest with a application/x-oslc-compact+xml as an Accept header.

In the /users script of FusionForge (www/users) we have added a content negociation mechanism (based on the content_negociated_user_home hook) that makes the difference between requests based on the accept header.

When 'Accept' header is application/x-oslc-compact+xml (as per the OSLC specs), the FusionForge /users script launches a plugin hook call (hook name is 'content_negociated_user_home') which is intented to return the URL of the RDF document of the compact preview of the user 'labbenes'. In this example the URL of the RDF document will be '/plugins/oslc/compact/user/labbenes'. This is the content of the RDF document of 'labbenes' compact preview:

When a plugin has responded to that hook call by returning an URL, FusionForge will redirects to that URL.

Note that another content-type is supported in addition to OSLC's which is displays directly the compact preview instead of the RDF description, based on the application/x-fusionforge-compact+html Accept content-type.

Loading the RDF document of the compact preview

The XMLHTTPRequest triggered by the client script will finally recieve the following RDF Document as XML data object.

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="purl.org/dc/terms/" xmlns:oslc="open-services.net/ns/core#">
  <oslc:Compact rdf:about="https://fftrunk/plugins/oslc/compact/user/labbenes">
    <dcterms:title>M. Sabri LABBENE</dcterms:title>
    <oslc:shortTitle>labbenes</oslc:shortTitle>
    <oslc:smallPreview>
      <oslc:Preview>
        <oslc:document rdf:ressource="https://fftrunk/plugins/oslc/compact/user/labbenes/type/small"/>
        <oslc:hintWidth>500px</oslc:hintWidth>
        <oslc:hintHeight>150px</oslc:hintHeight>
      </oslc:Preview>
    </oslc:smallPreview>
  </oslc:Compact>
</rdf:RDF>

Loading the HTML document of the compact preview

The client script then parses this XML document and gets the 'rdf:resource' attribute's value of the <oslc:document> tag. This value is the url of the compact preview HTML document.

Finally, the script loads this URL inside the toolTip container and we get this final result:

spacer

With Firebug we can see the sequence of urls requested when we mouseover the user link as in the following figure:

spacer
  • The first URL is the one of the user page in the forge which was requested with the 'application/x-oslc-compact+xml' Accept header.
  • The second one is the URL of the RDF document which represents the OSLC compact preview. FusionForge have redirected to that URL since a user page was requested with the special Accept header.
  • The third URL was requested when the client script loaded it inside the tooltip container.

Integration with gravatar plugin

The Gravatar plugin is now supported in the compact preview of users : spacer

Other resource types covered

This same feature was also made available for project links as the following figure shows:

spacer

The same feature will be extended to cover tracker artifacts and will also show a compact preview of the artifact inside a popup.

Retrieved from "fusionforge.org/plugins/mediawiki/wiki/fusionforge/index.php?title=Compact_Preview_Plugin&oldid=1325"
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
FusionForge
  • Project Summary
  • Log In
Navigation
  • Main page
  • Recent changes
  • Random page
Tools
  • What links here
  • Related changes
  • Special pages
  • Printable version
spacer
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.