O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Marrying Data Pipelining and Templating

We’ve explored the vast potential and power in both data pipelining and templates, which integrate rich data sets and visualization templates, respectively, into a gadget. Alone, each feature is a wonderful addition to any gadget, but their power really lies in being married into one cohesive unit.

Let’s take a look at an example of how we can merge these two technologies together to build out a data set based on the result set of an external data source. In this example, we want to scrape the main page of http://www.reddit.com to capture its top headlines. Using this data source, we want to display all links within our gadget.

Our first task is to build out the ModulePrefs section of our OpenSocial gadget, integrating all data pipelining and templating requirements:

<?xml version="1.0" encoding="utf-8"?>
<Module>
   <ModulePrefs title="Reddit Headline Fetch"
                title_url="http://www.jcleblanc.com"
                description="Obtains reddit.com headlines via YQL using data
                             pipelining and visualizes using OS templates"
                author="Jonathan LeBlanc">
      <Require feature="opensocial-0.9"/>
      <Require feature="opensocial-data" />
      <Require feature="opensocial-templates" />
   </ModulePrefs>

Within the ModulePrefs node, we need to set up the Require elements for the features that we will need in our gadget. For this use case, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required