Putting It All Together
The full code for this sample is available at https://github.com/jcleblanc/programming-social-applications/blob/master/chapter_7/chapter_final.xml.
Now that we’ve examined data pipelining and templating, one thing should be blatantly obvious: these two features of the OpenSocial specification can significantly reduce the amount of code that you need to write, create a highly modularized environment to promote multiuser development, and generally simplify debugging and data retrieval to allow you to focus on more important aspects of your gadget, such as monetization and social features.
Up until now, we’ve explored the individual specifications for accessing and working with data. Now we will put together a few of the lessons that we have learned into a fully functional example that showcases some of the major uses for templating and data pipelining.
In this example, we’ll look at:
Capturing data sources through data pipelining HTTP Requests
Integrating data pipes into templates
Using loop structures
Using special variables
Our sample code will use the data pipelining specification to pull in two RSS feeds, one from www.reddit.com and the other from the San Francisco local news section of www.craigslist.org. Following that, we’ll create two separate pages that can be switched back and forth by tabs. These pages will use the templating specification to display the title, link, and date from these two feeds as styled, unordered lists. The general ...