-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
285 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ node_js: | |
- "node" | ||
- "8" | ||
- "6" | ||
- "4" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,19 +11,19 @@ | |
### Create a new feed | ||
|
||
```js | ||
var Podcast = require('podcast'); | ||
import Podcast from 'podcast'; | ||
|
||
var feed = new Podcast(feedOptions); | ||
const feed = new Podcast(feedOptions); | ||
``` | ||
|
||
#### `feedOptions` | ||
|
||
* `title` **string** Title of your site or feed | ||
* `description` _optional_ **string** A short description of the feed. | ||
* `generator` _optional_ **string** Feed generator. | ||
* `feed_url` **url string** Url to the rss feed. | ||
* `site_url` **url string** Url to the site that the feed is for. | ||
* `image_url` _optional_ **url string* Small image for feed readers to use. | ||
* `feedUrl` **url string** Url to the rss feed. | ||
* `siteUrl` **url string** Url to the site that the feed is for. | ||
* `imageUrl` _optional_ **url string* Small image for feed readers to use. | ||
* `docs` _optional_ **url string** Url to documentation on this feed. | ||
* `author` **string** Who owns this feed. | ||
* `managingEditor` _optional_ **string** Who manages content in this feed. | ||
|
@@ -40,14 +40,16 @@ var feed = new Podcast(feedOptions); | |
* `itunesExplicit` _optional_ **boolean** (iTunes specific) specifies if the podcast contains explicit content | ||
* `itunesCategory` _optional_ **array of objects** (iTunes specific) Categories for iTunes ( [{text:String, subcats:[{text:String, subcats:Array}]}] ) | ||
* `itunesImage` _optional_ **string** (iTunes specific) link to an image for the podcast | ||
* `customNamespaces` _optional_ **object** Put additional namespaces in <rss> element (without 'xmlns:' prefix) | ||
* `customElements` _optional_ **array** Put additional elements in the feed (node-xml syntax) | ||
|
||
### Add items to a feed | ||
|
||
An item can be used for a blog entry, project update, log entry, etc. Your RSS feed | ||
an have any number of items. Most feeds use 20 or fewer items. | ||
|
||
```js | ||
feed.item(itemOptions); | ||
feed.addItem(itemOptions); | ||
``` | ||
|
||
#### itemOptions | ||
|
@@ -73,20 +75,21 @@ feed.item(itemOptions); | |
information. | ||
* `size` _optional_ **number** Number of bytes in the file. The length field will defualt to 0 if the | ||
`size` or `file` fields have not been set. | ||
* `mime` _optional_ **string** Mime type of the file. Will be guessed from the url if this parameter is | ||
* `type` _optional_ **string** Mime type of the file. Will be guessed from the url if this parameter is | ||
not set. | ||
* `itunesAuthor` _optional_ **string** (iTunes specific) author of the podcast | ||
* `itunesExplicit` _optional_ **boolean** (iTunes specific) specifies if the podcast contains explicit content | ||
* `itunesSubtitle` _optional_ **string** (iTunes specific) subtitle for iTunes listing | ||
* `itunesSummary` _optional_ **string** (iTunes specific) summary for iTunes listing | ||
* `itunesDuration` _optional_ **number** (iTunes specific) duration of the podcast item in seconds | ||
* `itunesKeywords` _optional_ **array of string** (iTunes specific) keywords of the podcast | ||
* `itunesKeywords` _optional_ **array of strings** (iTunes specific) keywords of the podcast | ||
* `itunesImage` _optional_ **string** (iTunes specific) link to an image for the item | ||
* `customElements` _optional_ **array** Put additional elements in the item (node-xml syntax) | ||
|
||
#### Feed XML | ||
|
||
```js | ||
var xml = feed.xml(indent); | ||
const xml = feed.xml(indent); | ||
``` | ||
|
||
This returns the XML as a string. | ||
|
@@ -97,10 +100,10 @@ This returns the XML as a string. | |
## Example Usage | ||
|
||
```js | ||
var Podcast = require('podcast'); | ||
import Podcast from 'podcast'; | ||
|
||
/* lets create an rss feed */ | ||
var feed = new Podcast({ | ||
const feed = new Podcast({ | ||
title: 'title', | ||
description: 'description', | ||
feed_url: 'http://example.com/rss.xml', | ||
|
@@ -130,7 +133,7 @@ var feed = new Podcast({ | |
}); | ||
|
||
/* loop over data and add to feed */ | ||
feed.item({ | ||
feed.addItem({ | ||
title: 'item title', | ||
description: 'use this for the content. It can include html.', | ||
url: 'http://example.com/article4?this&that', // link to the item | ||
|
@@ -150,26 +153,14 @@ feed.item({ | |
}); | ||
|
||
// cache the xml to send to clients | ||
var xml = feed.xml(); | ||
const xml = feed.xml(); | ||
``` | ||
|
||
## Tests | ||
|
||
Tests included use Mocha. Use `npm test` to run the tests. | ||
|
||
$ npm test | ||
|
||
## Notes | ||
* You do not need to escape anything. This module will escape characters when necessary. | ||
* This module is very fast but you might as well cache the output of xml() and serve | ||
it until something changes. | ||
|
||
# History | ||
|
||
I started this module over two years ago (April 2011) because there weren't any Node modules | ||
for creating RSS. Besides these [25 modules](https://npmjs.org/browse/depended/rss) | ||
I would love to know what other projects are using it. | ||
|
||
# Contributing | ||
|
||
Contributions to the project are welcome. Feel free to fork and improve. | ||
|
@@ -180,7 +171,7 @@ are included. | |
|
||
(The MIT License) | ||
|
||
Copyright (c) 2011-2013 Dylan Greene <[email protected]> | ||
Copyright (c) 2013-2017 Max Nowack <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function buildiTunesCategories(categories) { | ||
const arr = []; | ||
if (Array.isArray(categories)) { | ||
categories.forEach((category) => { | ||
if (category.subcats) { | ||
const elements = [ | ||
{ _attr: { text: category.text } }, | ||
]; | ||
const cats = buildiTunesCategories(category.subcats); | ||
cats.forEach((cat) => { | ||
elements.push(cat); | ||
}); | ||
arr.push({ 'itunes:category': elements }); | ||
} else { | ||
arr.push({ 'itunes:category': { _attr: { text: category.text } } }); | ||
} | ||
}); | ||
} | ||
return arr; | ||
} | ||
|
||
export default buildiTunesCategories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const warnedPositions = {}; | ||
|
||
function deprecate({ | ||
type, | ||
name, | ||
version, | ||
alternative, | ||
}) { | ||
const stack = new Error().stack || ''; | ||
let at = (stack.match(/(?:\s+at\s.+){2}\s+at\s(.+)/) || [undefined, ''])[1]; | ||
|
||
if (/\)$/.test(at)) { | ||
[at] = at.match(/[^(]+(?=\)$)/); | ||
} else { | ||
at = at.trim(); | ||
} | ||
if (at in warnedPositions) { | ||
return; | ||
} | ||
warnedPositions[at] = true; | ||
let message; | ||
switch (type) { | ||
case 'class': | ||
message = 'Class'; | ||
break; | ||
case 'property': | ||
message = 'Property'; | ||
break; | ||
case 'method': | ||
message = 'Method'; | ||
break; | ||
case 'function': | ||
message = 'Function'; | ||
break; | ||
default: message = ''; | ||
} | ||
message += ` \`${name}\` has been deprecated`; | ||
if (version) { | ||
message += ` since version ${version}`; | ||
} | ||
if (alternative) { | ||
message += `, use \`${alternative}\` instead`; | ||
} | ||
message += '.'; | ||
if (at) { | ||
message += `\n at ${at}`; | ||
} | ||
|
||
console.warn(message); // eslint-disable-line no-console | ||
} | ||
|
||
export default deprecate; |
Oops, something went wrong.