Feeds integration

From MPDLMediaWiki
Jump to navigation Jump to search

Possible solutions[edit]

Google AJAX API[edit]

Pros[edit]

  • Very simple to implement and to reuse.

Cons[edit]

  • Google Terms of use : [1]

How to[edit]

To use the Google AJAX API, just reuse the following code and adapt the red parts with your configuration:

<script src="http://www.google.com/jsapi">&#160;</script> 
<script>
  google.load("feeds", "1");
  function initialize() 
  {  	
      var feedControl = new google.feeds.FeedControl();
      feedControl.addFeed("http://url/of/the/feed/ ", "Feed name");
      feedControl.setNumEntries(6);
      feedControl.draw(document.getElementById("feedControl"));
  }
  google.setOnLoadCallback(initialize);
</script>

Remarks:[edit]

  • The first script element should not be minimized. To avoid the auto-minimization from JSF please write like it is on the previous code.
  • The url of the feed should be access from a backing bean with either

<h:outputText value="#{MyBackingBean.feedUrl}"/>

or replace the url with

document.getElementById("rssFeedUrl").value

and add in your jsp

 <h:inputHidden id="rssFeedUrl" value="#{MyBackingBean.rssFeedUrl}"></h:inputHidden>

  • The Google AJAX Feed API might be used with a Google AJAX key [2]. This key is defined for one server (that means one key is needed for dev, qa, demo, live, ..., servers). The usefulness of that key is described here [3]. If you want to use it, add it as parameter in the url source of the first script

 <script src="http://www.google.com/jsapi?key=your-key">&#160;</script> 

  • You can easily add additional feeds to your feedControl:

 feedControl.addFeed("http://url/of/second/feed/", "Second Feed name");
 feedControl.addFeed("http://url/of/third/feed/", "ThirdFeed name");
 ...

  • To set the target of the links, add:

 feedControl.setLinkTarget(google.feeds.LINK_TARGET_BLANK | google.feeds.LINK_TARGET_SELF | google.feeds.LINK_TARGET_TOP | google.feeds.LINK_TARGET_PARENT); 

More[edit]