Class: UWA.Services.Feed

UWA/Services/Feed. UWA.Services.Feed

new UWA.Services.Feed(options)

This Service provide a class to manipulate and load feeds.

Example

Load one feed using using <UWA.Data.request> and <UWA.Services.Feed>:

UWA.Data.request('http://feeds.feedburner.com/NetvibesDevBlog', {
proxy: 'feed',
type: 'json',
onComplete: function (data) {

   var feed = new UWA.Services.Feed({
       data: data
   });

   feed.getTitle();
   feed.getItem(0);
}
});

Load multiple feed using using <UWA.Services.Feed.Utils.load>:

UWA.Services.Feed.Utils.load({
    urls: [
        'http://feeds.feedburner.com/NetvibesDevBlog',
        'http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
    ],
    onComplete: function (feeds) {
        // feeds will be an object with UWA.Services.Feed instance
        // indexed by feed url.
    }
});
Parameters
Name Type Description
options Object

Options hash

Mixes In

  • UWA.Class.Options

Index

Members

id :String

Unique feed id.

Type
  • String

lastFetchedDate :Number

The timestamp of the last feed update.

Type
  • Number

error :String

Current error message.

Type
  • String

preProcessItemEnclosures

Pre process item to extract enclosures.

Methods

setOptions(options) → {this}

Set options of this instance. Passing an 'events' field will automatically add those events.

Parameters
Name Type Description
options Object

Options hash

Returns
Type
this

setError(error) → {this}

Set error message of this instance.

Parameters
Name Type Description
error Object

Error message

Returns
Type
this

getError() → {String}

Get error message of this instance.

Returns

Error message.

Type
String

isReadOnly() → {Boolean}

Return the current state of read/unread percistency on this feed instance.

Returns

true if in read only else false.

Type
Boolean

setLastFetchedDate(timeStampInSeconds) → {this}

Set the last time that the feed has been fetched using timespamp.

Parameters
Name Type Description
timeStampInSeconds Integer

The timespamp of the last fetch in seconds

Returns
Type
this

getLastFetchedDate() → {Integer}

Get the timespamp that define when that feed has been fetched.

Returns

The timespamp of the last fetch in seconds.

Type
Integer

setData() → {Object}

Add data to Feed instance.

Returns
Type
Object

addItems(items, where)

Add items to the feed instance.

Parameters
Name Type Description
items Array

A collection of items to add

where String

The position of the added items, could be "before", "after" and default is using <sortItemsByDate>

sortItemsByDate(order)

Sort current items by date and update their indexes.

Parameters
Name Type Description
order String

Define the order, possible value are "asc" or "desc", default is "desc".

setItemsIndexes()

Define the index property of each items, related to their position defined by <sortItemsByDate> for example.

preProcessItem(item) → {Object}

Pre process item, extract enclosures, filter link and enclosures.

Parameters
Name Type Description
item Object

The item to pre process

Returns

The processed item.

Type
Object

addItemLinkFilter(filter)

Add a new link filters function.

Parameters
Name Type Description
filter Function

The enclosure filter function

applyItemLinkFilters(item)

Apply link filters on an item.

Parameters
Name Type Description
item Object

The item to process

addItemEnclosureFilter(filter)

Add a new enclosure filters function.

Parameters
Name Type Description
filter Function

The enclosure filter function

applyItemEnclosureFilters(item)

Apply enclosure filters on an item.

Parameters
Name Type Description
item Object

The item to process

getTitle() → {String}

Get feed title defined by the feed.

Returns
Type
String

getDir() → {String}

Get the preferred language direction defined by the feed.

Returns
Type
String

getUrl() → {String}

Get the url source of the feed.

Returns
Type
String

Get website url that relly on the feed.

Returns
Type
String

getType() → {String}

Get the feed type (e.g rss2, atom, rdf).

Returns
Type
String

getItems() → {Array}

Get all items.

Returns
Type
Array

getItem() → {Object}

Get item by index.

Returns
Type
Object

getItemByGuid() → {Object}

Get item by index.

Returns
Type
Object

getItemByProperty() → {Object}

Get item by property value.

Returns
Type
Object

getLastItemId() → {String}

Get last item id.

Returns
Type
String

getItemsLength() → {Number}

Get the number of loaded items.

Returns
Type
Number

getUnread() → {Array}

Get the unread items.

Returns
Type
Array

isItemRead() → {Boolean}

Check if item state is read.

Returns
Type
Boolean

setItemRead()

Set item state to read.

setItemUnread()

Set item state to unread.

setAllItemsRead()

Set all item state to read.

setAllItemsUnread()

Set all item state to unread.

setItemsFlag()

Set flags on items.