Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 2.8 KB

File metadata and controls

67 lines (52 loc) · 2.8 KB

jFeed: jQuery feed parser plugin

Copyright (C) 2007-2011 Jean-François Hovinne - http://hovinne.com/
Dual licensed under the MIT (MIT-license.txt) and GPL (GPL-license.txt) licenses.

Usage

jQuery.getFeed(options);

Options:

  • url: the feed URL (required)
  • data: data to be sent to the server. See jQuery.ajax data property
  • success: a function to be called if the request succeeds. The function gets passed one argument: the JFeed object
Example:
 jQuery.getFeed({
   url: 'rss.xml',
   success: function(feed) {
     alert(feed.title);
   }
 });

JFeed properties

  • feed.type
  • feed.version
  • feed.title
  • feed.link
  • feed.description
  • feed.language
  • feed.updated
  • feed.items: an array of JFeedItem

JFeedItem properties

  • item.title
  • item.link
  • item.description
  • item.updated
  • item.id
These have been added to the base JFeedItem properties:
  • item.latlon
  • item.contentEncoded
  • item.imageURL
-- Note -- latlon: latlon is stored as a string (lat and lon separated with a space) in our rss feed using the geopoint XML namespace (the tag is <geopoint:point></geopoint:point>). The operation we use to access this field is: jQuery(this).find(&quot;georss\\&#58;point,point&quot;)&#59; -- this is, from the best I can tell, the best way of parsing the XML namespace, that works in both webkit browsers and Firefox. For more information, see this jquery post: http://bugs.jquery.com/ticket/10377 or this is discussed in this stackoverflow post: http://stackoverflow.com/questions/853740/jquery-xml-parsing-with-namespaces

-- Note -- imageURL: is parsed out of contentEncoded manually, since our feed has contentEncodeded enclosed within CDATA flags, which cause the HTML information to not be parsed by the JRss parser. This manual workaround occurs in the new JRss._getImageURLFromSrcTag(jQueryObject) function.

The _getImageURLFromSrcTag(jQueryObject) function takes a jQueryObject that has a cdata-section childnode, which has a data attribute, where the HTML that we want to use to pull our imageURL lives. We manually parse that HTML into a jQuery object and then loop over the tags within it, and pull the first valid src tag of the img we find. A src tag is valid if it ends in .jpg, .JPG, .jpeg, .JPEG, .png, .PNG, .gif, .GIF.

Please see the provided examples for more information.

A basic PHP proxy is also available (proxy.php), if you need to load external feeds (for testing purposes only, do not use it on public websites).