RSS feed reader example

An example of how to set up an RSS feed reader using a CNN RSS feed.

Step 1. Create UI Page

Set up a UI page named 'render_gadget_widgetRSS' with the following HTML
<?xml version= "1.0" encoding= "utf-8" ?><j:jelly trim = "false" xmlns:j = "jelly:core" xmlns:g = "glide"xmlns:j2 = "null" xmlns:g2 = "null" ><style type = "text/css" >
     #feedControl .gf-title {
       color:#0000ff;
     }
   </style><g2:scrollable_area height = "100px" ><div id = "feedControl" >Loading...</div><script type = "text/javascript" >
        google.load("feeds", "1");       
 
        function initialize() {               
           var feedControl = new google.feeds.FeedControl();
           feedControl.addFeed("http://rss.cnn.com/rss/cnn_topstories.rss", "CNN");
           feedControl.setLinkTarget(google.feeds.LINK_TARGET_BLANK);
           feedControl.setNumEntries(5);
           feedControl.draw(document.getElementById("feedControl"));
        }
        if(typeof google == "undefined" || navigator.appName == "Microsoft Internet Explorer"){                
           //Give us some time to load the script
           setTimeout('initialize()',1500);
        }
        else{
           initialize();
        }
     </script></g2:scrollable_area></j:jelly>

Step 2. Create UI Widget

Create a new javascript widget under 'System UI > Widgets' with the following script. You can replace the 'RSS Feed Sample' line with the title of your widget. 'widgetRSS' should be replaced with whatever comes after 'render_gadget_' in the name of your UI page.
function sections ( ) { return { 'RSS Feed Sample' : { 'type' : 'widgetRSS' } } ; }
 
 function render ( ) { var type  = renderer. getPreferences ( ). get ( "type" ) ; var gf  = new GlideForm (renderer. getGC ( ) , "render_gadget_" + type , 0 ) ;
  gf. setDirect ( true ) ;
  gf. setRenderProperties (renderer. getRenderProperties ( ) ) ; return gf. getRenderedPage ( ) ; }
 
 function getEditLink ( ) { return "sys_ui_page.do?sysparm_query=name=render_gadget_" + renderer. getPreferences ( ). get ( "type" ) ; }

Step 3. Create Global UI Script

Create a UI script under System UI > UI Scripts with the following script. Select the Global checkbox on the UI Script form. The script must include your Google API key.
document.write('<script type="text/javascript" src="https://www.google.com/jsapi?key=your_instance_api_key_here"></script>');
document.write('<script type = "text/javascript" >google. load ( "feeds" , "1" ) ;</script >');
You can now navigate to your homepage and add the widget. Below is a sample showing what the widget looks like.
Figure 1. RSS Feed Reader