Skip to content

Commit

Permalink
adding torrent enclosure support
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk committed Apr 12, 2018
1 parent 5bc314d commit 687fae9
Show file tree
Hide file tree
Showing 9 changed files with 3,898 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
coverage
node_modules
node_modules
yarn-error.log
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ before_install:
- export TZ=Europe/London
script:
- "npm run-script test-travis"
after_script:
- "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
- "codeclimate-test-reporter < ./coverage/lcov.info"
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Feed for Node.js

> [Feed](http://projets.jpmonette.net/en/feed) is a *RSS 2.0*, *JSON Feed 1.0*, and *Atom 1.0* generator for **Node.js**, making content syndication simple and intuitive!
> Feed is a *RSS 2.0*, *JSON Feed 1.0*, *Atom 1.0* and *JSON Feed 1.0* generator for **Node.js**
[![Build Status](https://travis-ci.org/jpmonette/feed.svg?branch=master)](https://travis-ci.org/jpmonette/feed)
[![Coverage Status](https://coveralls.io/repos/github/jpmonette/feed/badge.svg?branch=master)](https://coveralls.io/github/jpmonette/feed?branch=master)
[![Build Status](https://travis-ci.org/rigelk/feed.svg?branch=master)](https://travis-ci.org/rigelk/feed)

## Installation

Expand All @@ -14,14 +13,15 @@ $ npm install feed
## Features

* Pure JavaScript
* Support for Atom 1.0 and RSS 2.0
* Support for Atom 1.0, Json 1.0 and RSS 2.0
* Lightweight - Only 1 dependency!

## Quick Start

First, add the module:

```js
// @ts-ignore
const Feed = require('feed')
```

Expand Down Expand Up @@ -118,14 +118,7 @@ Output a JSON Feed 1.0 feed:
feed.json1()
```

Yes, it's that simple :)!

## More Information

* [Feed for Node.js](http://projets.jpmonette.net/en/feed) (English)
* [Feed pour Node.js](http://projets.jpmonette.net/feed) (French)
* Follow [@jpmonette](https://twitter.com/jpmonette) on Twitter for updates
* Read my personal blog [Blogue de Jean-Philippe Monette](http://blogue.jpmonette.net/) to learn more about what I do!
Hopefully simple enough, and soon-to-be more featureful :)

## License

Expand Down
4 changes: 3 additions & 1 deletion lib/feed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feed.js.map

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "feed",
"version": "1.1.1",
"description": "Feed is a RSS and Atom feed generator for Node.js, making content syndication simple and intuitive!",
"homepage": "http://projets.jpmonette.net/en/feed",
"author": "Jean-Philippe Monette <contact@jpmonette.net>",
"name": "pfeed",
"version": "1.1.2",
"description": "Feed is a RSS 2.0, Atom 1.0 and Json Feed 1.0 generator for Node.js, based on work from Jean-Philippe Monette and initiated by a need of the PeerTube project",
"homepage": "http://github.com/rigelk/feed",
"author": "Rigel Kent <sendmemail@rigelk.eu>",
"contributors": [
{
"name": "Jean-Philipe Monette",
"email": "contact@jpmonette.net"
},
{
"name": "Ben McCormick",
"email": "ben.mccormick@windsorcircle.com"
Expand Down Expand Up @@ -48,17 +52,17 @@
"babel-cli": "^6.24.1",
"babel-preset-env": "^1.5.1",
"codeclimate-test-reporter": "^0.5.0",
"coveralls": "^2.13.1",
"jest": "^20.0.4"
"coveralls": "^3.0.0",
"jest": "^22.4.3"
},
"engines": {
"node": ">=0.4.0"
},
"bugs": {
"url": "https://github.com/jpmonette/feed/issues"
"url": "https://github.com/rigelk/feed/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jpmonette/feed.git"
"url": "https://github.com/rigelk/feed.git"
}
}
4 changes: 3 additions & 1 deletion src/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ class Feed {
})
}

if(entry.image) {
if (entry.torrent) {
item.push({ enclosure: [{ _attr: { url: entry.torrent, type: 'application/x-bittorrent' } }] });
} else if(entry.image) {
item.push({ enclosure: [{ _attr: { url: entry.image } }] });
}

Expand Down
7 changes: 3 additions & 4 deletions src/feed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ feed.addItem({
}
}],
date: sampleDate,
image: 'https://example.com/hello-world.jpg'
torrent: 'https://example.com/hello-world.torrent'
})

feed.addExtension({
Expand Down Expand Up @@ -104,7 +104,7 @@ test('it should generate an RSS 2.0 feed', () => {
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<author>janedoe@example.com (Jane Doe)</author>
<enclosure url="https://example.com/hello-world.jpg">
<enclosure url="https://example.com/hello-world.torrent" type="application/x-bittorrent">
</enclosure>
</item>
</channel>
Expand Down Expand Up @@ -174,7 +174,7 @@ test('it should generate an Atom 1.0 feed', () => {
expect(actual).toBe(expected)
});

test('it should generate a JSON v1 Feed', () => {
test('it should generate a JSON v1 feed', () => {
let expected = {
"author": {
"name": "John Doe",
Expand All @@ -190,7 +190,6 @@ test('it should generate a JSON v1 Feed', () => {
},
"date_modified": "2013-07-13T23:00:00Z",
"id": "https://example.com/hello-world",
"image": "https://example.com/hello-world.jpg",
"summary": "This is an article about Hello World.",
"title": "Hello World",
"url": "https://example.com/hello-world",
Expand Down

0 comments on commit 687fae9

Please sign in to comment.