Marrying Data Pipelining and Templating
Note
The full code for this sample is available at https://github.com/jcleblanc/programming-social-applications/blob/master/chapter_7/pipeline_with_templating.xml.
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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access