# jquery.rss [![Build Status](https://travis-ci.org/sdepold/jquery-rss.svg?branch=master)](https://travis-ci.org/sdepold/jquery-rss) This plugin can be used to read a RSS feed and transform it into a custom piece of HTML. ## Alternatives A vanilla JavaScript version of this library can be found here: [Vanilla RSS](https://github.com/sdepold/vanilla-rss). This plugin uses [Feedr](https://github.com/sdepold/feedr), a backend server that parses and converts RSS feeds into its JSON representation. The server was built as a drop-in replacement for Google's former Feed API. ## Support Since version 3.4.0 of jquery.rss, users have the chance to support funding future developments and covering the costs for the hosting of jquery.rss' respective server side companion app [feedr](https://github.com/sdepold/feedr). Every once in a while supporters will get affiliate links instead of one of the feed's entries. If you are not interested in supporting the authors of the plugin, then you can easily opt-out of it by setting the respective `support` option. See below for further details. Thanks in advance! ## Installation Through npm: ``` $ npm install jquery $ npm install jquery-rss const $ = require('jquery'); require('jquery-rss); // This will add the plugin to the jQuery namespace ``` Through cdnjs: ``` ``` ## Setup ```html
{title}
", // additional token definition for in-template-usage // default: {} // valid values: any object/hash tokens: { foo: "bar", bar: function(entry, tokens) { return entry.title; } }, // formats the date with moment.js (optional) // default: 'dddd MMM Do' // valid values: see http://momentjs.com/docs/#/displaying/ dateFormat: "MMMM Do, YYYY", // localizes the date with moment.js (optional) // default: 'en' dateLocale: "de", // Defines the format which is used for the feed. // Default: null (utf8) // valid values: https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings encoding: "ISO-8859-1", // Defined the order of the feed's entries. // Default: undefined (keeps the order of the original feed) // valid values: All entry properties; title, link, content, contentSnippet, publishedDate, categories, author, thumbnail // Order can be reversed by prefixing a dash (-) order: "-publishedDate", // formats the date in whatever manner you choose. (optional) // this function should return your formatted date. // this is useful if you want to format dates without moment.js. // if you don't use moment.js and don't define a dateFormatFunction, the dates will // not be formatted; they will appear exactly as the RSS feed gives them to you. dateFormatFunction: function(date) {}, // a callback, which gets triggered when an error occurs // default: function() { throw new Error("jQuery RSS: url don't link to RSS-Feed") } error: function() {}, // a callback, which gets triggered when everything was loaded successfully // this is an alternative to the next parameter (callback function) // default: function(){} success: function() {}, // a callback, which gets triggered once data was received but before the rendering. // this can be useful when you need to remove a spinner or something similar onData: function() {} }, // callback function // called after feeds are successfully loaded and after animations are done function callback() {} ); ``` ### Note about the host option Since version 3.0.0 the plugin is no longer using the Google Feed API but a drop-in replacement called [feedr](https://feedrapp.info). That server is currently running on Heroku and might have some downtimes, interruptions or unexpected issues. While I will try to keep those problems as rare as possible, it can totally happen from time to time. I might move the service to some other provide or even improve the infrastructure. If you don't want to rely on the [provided server](http://feedrapp.info) and instead run your own version, you can just download feedr, install the dependencies and run it. As written above, you can specify the host which is used to parse the feeds with the `host` option. ## Templating As seen in the options, you can specify a template in order to transform the json objects into HTML. In order to that, you can either define the outer template (which describes the html around the entries) or the entry template (which describes the html of an entry). The basic format of those templates are: ```html "Title |
---|