Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
/ nanofeed Public archive

[DEPRECATED] Tiny RSS feed parser client built in JavaScript

License

Notifications You must be signed in to change notification settings

andretf/nanofeed

Repository files navigation

⚠️ WARNING: This package does not work and shouldn't be used anymore, since Yahoo! shut down YQL. Please, consider using rss-parser.

GitHub version Code Climate Build Status Test Coverage

nanofeed

Tiny RSS feed parser client built in JavaScript.

No library dependencies.
Asynchronous requests.
Multiple feeds sources.
Multiple independent successive calls.
Uses Yahoo! YQL Plataform.
Widely supported by browsers.

WARNING

nanofeed is a frontend library who relies on Yahoo Query API to fetch RSS content. It's currently not working since Yahoo shutted down the service. Need some reworking for use other services and allowing user to change it.

Installation

Recommended using CDN:

<script src="https://www.jsdelivr.com/package/npm/nanofeed@1/dist/nanofeed.min.js"></script>

or package manager:

$ yarn add nanofeed
$ pnpm i -D nanofeed

Examples

// minimal
nanofeed.fetch(url, function(items) {
  console.log(items)
})

// Multiple feed sources
nanofeed.fetch([socialFeedUrl, newsFeedUrl], addFeedItems)

// Successive calls
nanofeed
  .fetch([socialFeedUrl, newsFeedUrl], addFeedItems)
  .fetch(weatherFeedUrl, addWeatherFeedItems)

// Callback function receive array of items retrieved from the feed
function callback(items) {
  items.forEach(function(x) {
    var newItemHtml = '<li>' + items.title + ' - ' + item.date + '</li>'
    document.getElementById('feed').innerHTML += newItemHtml
  })
}

// Setting options for a function call
nanofeed.fetch(
  url,
  {
    fields: ['title', 'date'],
    qty: 15
  },
  callback
)

// or globally for all function calls
nanofeed.options = {
  fields: ['title', 'date'],
  qty: 15
}
nanofeed.fetch(url, callback)
nanofeed.fetch(weatherFeedUrl, addWeatherFeedItems)

Documentation

nanofeed.fetch(feed_url, [options,] success_callback)

parameter type required description
feed_url string | string array yes Absolute URL(s) of the RSS feed(s).
options object no Options about format of result returned from feed sources.
success_callback function(data) yes Callback function called on success.

Options parameters

attribute type default accepts description
fields string array ['title', 'link'] title, link, date, description Fields to be returned from feed source(s).
qty integer 5 positive integers
(limited by feed source or Yahoo Feed API)
Quantity of feed entries to return.

Callback function called on success:

Returns as parameter the list of feed entries ordered by most recent publish date. Array of object:

attribute type
title string
link string
pubDate date
description string

For further documentation see specifications.

Specification & Tests

Detailed code coverage is available at https://andretf.github.io/nanofeed/spec/coverage.

Authoring