mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboViteDocs.git
synced 2026-06-15 21:56:30 +00:00
Initalize
This commit is contained in:
63
node_modules/feed/src/__tests__/__snapshots__/atom1.spec.ts.snap
generated
vendored
Normal file
63
node_modules/feed/src/__tests__/__snapshots__/atom1.spec.ts.snap
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`atom 1.0 should generate a valid feed 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<feed xmlns=\\"http://www.w3.org/2005/Atom\\">
|
||||
<id>http://example.com/</id>
|
||||
<title>Feed Title</title>
|
||||
<updated>2013-07-13T23:00:00.000Z</updated>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<author>
|
||||
<name>John Doe</name>
|
||||
<email>johndoe@example.com</email>
|
||||
<uri>https://example.com/johndoe?link=sanitized&value=2</uri>
|
||||
</author>
|
||||
<link rel=\\"alternate\\" href=\\"http://example.com/\\"/>
|
||||
<link rel=\\"self\\" href=\\"http://example.com/sampleFeed.rss\\"/>
|
||||
<link rel=\\"hub\\" href=\\"wss://example.com/\\"/>
|
||||
<subtitle>This is my personnal feed!</subtitle>
|
||||
<logo>http://example.com/image.png</logo>
|
||||
<icon>http://example.com/image.ico</icon>
|
||||
<rights>All rights reserved 2013, John Doe</rights>
|
||||
<category term=\\"Technology\\"/>
|
||||
<contributor>
|
||||
<name>Johan Cruyff</name>
|
||||
<email>johancruyff@example.com</email>
|
||||
<uri>https://example.com/johancruyff</uri>
|
||||
</contributor>
|
||||
<entry>
|
||||
<title type=\\"html\\"><![CDATA[Hello World]]></title>
|
||||
<id>https://example.com/hello-world?id=this&that=true</id>
|
||||
<link href=\\"https://example.com/hello-world?link=sanitized&value=2\\"/>
|
||||
<updated>2013-07-13T23:00:00.000Z</updated>
|
||||
<summary type=\\"html\\"><![CDATA[This is an article about Hello World.]]></summary>
|
||||
<content type=\\"html\\"><![CDATA[Content of my item]]></content>
|
||||
<author>
|
||||
<name>Jane Doe</name>
|
||||
<email>janedoe@example.com</email>
|
||||
<uri>https://example.com/janedoe?link=sanitized&value=2</uri>
|
||||
</author>
|
||||
<author>
|
||||
<name>Joe Smith</name>
|
||||
<email>joesmith@example.com</email>
|
||||
<uri>https://example.com/joesmith</uri>
|
||||
</author>
|
||||
<author>
|
||||
<name>Joe Smith, Name Only</name>
|
||||
</author>
|
||||
<category label=\\"Grateful Dead\\"/>
|
||||
<category label=\\"MSFT\\"/>
|
||||
<contributor>
|
||||
<name>Shawn Kemp</name>
|
||||
<email>shawnkemp@example.com</email>
|
||||
<uri>https://example.com/shawnkemp</uri>
|
||||
</contributor>
|
||||
<contributor>
|
||||
<name>Reggie Miller</name>
|
||||
<email>reggiemiller@example.com</email>
|
||||
<uri>https://example.com/reggiemiller</uri>
|
||||
</contributor>
|
||||
<published>2013-07-10T23:00:00.000Z</published>
|
||||
</entry>
|
||||
</feed>"
|
||||
`;
|
||||
48
node_modules/feed/src/__tests__/__snapshots__/json.spec.ts.snap
generated
vendored
Normal file
48
node_modules/feed/src/__tests__/__snapshots__/json.spec.ts.snap
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`json 1 should generate a valid feed 1`] = `
|
||||
"{
|
||||
\\"version\\": \\"https://jsonfeed.org/version/1\\",
|
||||
\\"title\\": \\"Feed Title\\",
|
||||
\\"home_page_url\\": \\"http://example.com/\\",
|
||||
\\"feed_url\\": \\"http://example.com/sampleFeed.json\\",
|
||||
\\"description\\": \\"This is my personnal feed!\\",
|
||||
\\"icon\\": \\"http://example.com/image.png\\",
|
||||
\\"author\\": {
|
||||
\\"name\\": \\"John Doe\\",
|
||||
\\"url\\": \\"https://example.com/johndoe?link=sanitized&value=2\\"
|
||||
},
|
||||
\\"_example_extension\\": {
|
||||
\\"about\\": \\"just an extension example\\",
|
||||
\\"dummy\\": \\"example\\"
|
||||
},
|
||||
\\"items\\": [
|
||||
{
|
||||
\\"id\\": \\"https://example.com/hello-world?id=this&that=true\\",
|
||||
\\"content_html\\": \\"Content of my item\\",
|
||||
\\"url\\": \\"https://example.com/hello-world?link=sanitized&value=2\\",
|
||||
\\"title\\": \\"Hello World\\",
|
||||
\\"summary\\": \\"This is an article about Hello World.\\",
|
||||
\\"image\\": \\"https://example.com/hello-world.jpg\\",
|
||||
\\"date_modified\\": \\"2013-07-13T23:00:00.000Z\\",
|
||||
\\"date_published\\": \\"2013-07-10T23:00:00.000Z\\",
|
||||
\\"author\\": {
|
||||
\\"name\\": \\"Jane Doe\\",
|
||||
\\"url\\": \\"https://example.com/janedoe?link=sanitized&value=2\\"
|
||||
},
|
||||
\\"tags\\": [
|
||||
\\"Grateful Dead\\",
|
||||
\\"MSFT\\"
|
||||
],
|
||||
\\"_item_extension_1\\": {
|
||||
\\"about\\": \\"just an item extension example\\",
|
||||
\\"dummy1\\": \\"example\\"
|
||||
},
|
||||
\\"_item_extension_2\\": {
|
||||
\\"about\\": \\"just a second item extension example\\",
|
||||
\\"dummy1\\": \\"example\\"
|
||||
}
|
||||
}
|
||||
]
|
||||
}"
|
||||
`;
|
||||
263
node_modules/feed/src/__tests__/__snapshots__/rss2.spec.ts.snap
generated
vendored
Normal file
263
node_modules/feed/src/__tests__/__snapshots__/rss2.spec.ts.snap
generated
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`rss 2.0 should generate a valid feed 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
|
||||
<channel>
|
||||
<title>Feed Title</title>
|
||||
<link>http://example.com/</link>
|
||||
<description>This is my personnal feed!</description>
|
||||
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
|
||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<language>en</language>
|
||||
<ttl>60</ttl>
|
||||
<image>
|
||||
<title>Feed Title</title>
|
||||
<url>http://example.com/image.png</url>
|
||||
<link>http://example.com/</link>
|
||||
</image>
|
||||
<copyright>All rights reserved 2013, John Doe</copyright>
|
||||
<category>Technology</category>
|
||||
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world?link=sanitized&value=2</link>
|
||||
<guid>https://example.com/hello-world?id=this&that=true</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>"
|
||||
`;
|
||||
|
||||
exports[`rss 2.0 should generate a valid feed with audio 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
|
||||
<channel>
|
||||
<title>Feed Title</title>
|
||||
<link>http://example.com/</link>
|
||||
<description>This is my personnal feed!</description>
|
||||
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
|
||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<language>en</language>
|
||||
<ttl>60</ttl>
|
||||
<image>
|
||||
<title>Feed Title</title>
|
||||
<url>http://example.com/image.png</url>
|
||||
<link>http://example.com/</link>
|
||||
</image>
|
||||
<copyright>All rights reserved 2013, John Doe</copyright>
|
||||
<category>Technology</category>
|
||||
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world?link=sanitized&value=2</link>
|
||||
<guid>https://example.com/hello-world?id=this&that=true</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world2</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world2</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world3</link>
|
||||
<guid>https://example.com/hello-world3</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"audio/mpeg\\" url=\\"https://example.com/hello-world.mp3\\"/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>"
|
||||
`;
|
||||
|
||||
exports[`rss 2.0 should generate a valid feed with enclosure 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
|
||||
<channel>
|
||||
<title>Feed Title</title>
|
||||
<link>http://example.com/</link>
|
||||
<description>This is my personnal feed!</description>
|
||||
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
|
||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<language>en</language>
|
||||
<ttl>60</ttl>
|
||||
<image>
|
||||
<title>Feed Title</title>
|
||||
<url>http://example.com/image.png</url>
|
||||
<link>http://example.com/</link>
|
||||
</image>
|
||||
<copyright>All rights reserved 2013, John Doe</copyright>
|
||||
<category>Technology</category>
|
||||
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world?link=sanitized&value=2</link>
|
||||
<guid>https://example.com/hello-world?id=this&that=true</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world2</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world2</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>"
|
||||
`;
|
||||
|
||||
exports[`rss 2.0 should generate a valid feed with image properties 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
|
||||
<channel>
|
||||
<title>Feed Title</title>
|
||||
<link>http://example.com/</link>
|
||||
<description>This is my personnal feed!</description>
|
||||
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
|
||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<language>en</language>
|
||||
<ttl>60</ttl>
|
||||
<image>
|
||||
<title>Feed Title</title>
|
||||
<url>http://example.com/image.png</url>
|
||||
<link>http://example.com/</link>
|
||||
</image>
|
||||
<copyright>All rights reserved 2013, John Doe</copyright>
|
||||
<category>Technology</category>
|
||||
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world?link=sanitized&value=2</link>
|
||||
<guid>https://example.com/hello-world?id=this&that=true</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
|
||||
</item>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world2</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>"
|
||||
`;
|
||||
|
||||
exports[`rss 2.0 should generate a valid feed with video 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
|
||||
<channel>
|
||||
<title>Feed Title</title>
|
||||
<link>http://example.com/</link>
|
||||
<description>This is my personnal feed!</description>
|
||||
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
|
||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>https://github.com/jpmonette/feed</generator>
|
||||
<language>en</language>
|
||||
<ttl>60</ttl>
|
||||
<image>
|
||||
<title>Feed Title</title>
|
||||
<url>http://example.com/image.png</url>
|
||||
<link>http://example.com/</link>
|
||||
</image>
|
||||
<copyright>All rights reserved 2013, John Doe</copyright>
|
||||
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
|
||||
<item>
|
||||
<title><![CDATA[Hello World]]></title>
|
||||
<link>https://example.com/hello-world4</link>
|
||||
<guid>419c523a-28f4-489c-877e-9604be64c005</guid>
|
||||
<pubDate>Wed, 10 Jul 2013 23:00:00 GMT</pubDate>
|
||||
<description><![CDATA[This is an article about Hello World.]]></description>
|
||||
<content:encoded><![CDATA[Content of my item]]></content:encoded>
|
||||
<author>janedoe@example.com (Jane Doe)</author>
|
||||
<author>joesmith@example.com (Joe Smith)</author>
|
||||
<category>Grateful Dead</category>
|
||||
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
|
||||
<enclosure url=\\"https://example.com/hello-world.mp4\\" length=\\"0\\" type=\\"video/mp4\\"/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>"
|
||||
`;
|
||||
8
node_modules/feed/src/__tests__/atom1.spec.ts
generated
vendored
Normal file
8
node_modules/feed/src/__tests__/atom1.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { sampleFeed } from "./setup";
|
||||
|
||||
describe("atom 1.0", () => {
|
||||
it("should generate a valid feed", () => {
|
||||
const actual = sampleFeed.atom1();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
8
node_modules/feed/src/__tests__/json.spec.ts
generated
vendored
Normal file
8
node_modules/feed/src/__tests__/json.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { sampleFeed } from "./setup";
|
||||
|
||||
describe("json 1", () => {
|
||||
it("should generate a valid feed", () => {
|
||||
const actual = sampleFeed.json1();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
230
node_modules/feed/src/__tests__/rss2.spec.ts
generated
vendored
Normal file
230
node_modules/feed/src/__tests__/rss2.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
import { Feed } from "../feed";
|
||||
import { published, sampleFeed, updated } from "./setup";
|
||||
|
||||
describe("rss 2.0", () => {
|
||||
it("should generate a valid feed", () => {
|
||||
const actual = sampleFeed.rss2();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
it("should generate a valid feed with image properties", () => {
|
||||
sampleFeed.addItem({
|
||||
title: "Hello World",
|
||||
guid: "419c523a-28f4-489c-877e-9604be64c001",
|
||||
link: "https://example.com/hello-world2",
|
||||
description: "This is an article about Hello World.",
|
||||
content: "Content of my item",
|
||||
author: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "janedoe@example.com",
|
||||
link: "https://example.com/janedoe",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith",
|
||||
email: "joesmith@example.com",
|
||||
link: "https://example.com/joesmith",
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
{
|
||||
name: "_item_extension_1",
|
||||
objects: {
|
||||
about: "just an item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "_item_extension_2",
|
||||
objects: {
|
||||
about: "just a second item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
],
|
||||
category: [
|
||||
{
|
||||
name: "Grateful Dead",
|
||||
},
|
||||
{
|
||||
name: "MSFT",
|
||||
domain: "http://www.fool.com/cusips",
|
||||
},
|
||||
],
|
||||
date: updated,
|
||||
image: { url: "https://example.com/hello-world.jpg", length: 12665 },
|
||||
published,
|
||||
});
|
||||
const actual = sampleFeed.rss2();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
it("should generate a valid feed with enclosure", () => {
|
||||
sampleFeed.addItem({
|
||||
title: "Hello World",
|
||||
guid: "419c523a-28f4-489c-877e-9604be64c001",
|
||||
link: "https://example.com/hello-world2",
|
||||
description: "This is an article about Hello World.",
|
||||
content: "Content of my item",
|
||||
author: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "janedoe@example.com",
|
||||
link: "https://example.com/janedoe",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith",
|
||||
email: "joesmith@example.com",
|
||||
link: "https://example.com/joesmith",
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
{
|
||||
name: "_item_extension_1",
|
||||
objects: {
|
||||
about: "just an item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "_item_extension_2",
|
||||
objects: {
|
||||
about: "just a second item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
],
|
||||
category: [
|
||||
{
|
||||
name: "Grateful Dead",
|
||||
},
|
||||
{
|
||||
name: "MSFT",
|
||||
domain: "http://www.fool.com/cusips",
|
||||
},
|
||||
],
|
||||
date: updated,
|
||||
enclosure: { url: "https://example.com/hello-world.jpg", length: 12665 },
|
||||
published,
|
||||
});
|
||||
const actual = sampleFeed.rss2();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
it("should generate a valid feed with audio", () => {
|
||||
sampleFeed.addItem({
|
||||
title: "Hello World",
|
||||
link: "https://example.com/hello-world3",
|
||||
description: "This is an article about Hello World.",
|
||||
content: "Content of my item",
|
||||
author: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "janedoe@example.com",
|
||||
link: "https://example.com/janedoe",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith",
|
||||
email: "joesmith@example.com",
|
||||
link: "https://example.com/joesmith",
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
{
|
||||
name: "_item_extension_1",
|
||||
objects: {
|
||||
about: "just an item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "_item_extension_2",
|
||||
objects: {
|
||||
about: "just a second item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
],
|
||||
category: [
|
||||
{
|
||||
name: "Grateful Dead",
|
||||
},
|
||||
{
|
||||
name: "MSFT",
|
||||
domain: "http://www.fool.com/cusips",
|
||||
},
|
||||
],
|
||||
date: updated,
|
||||
audio: { url: "https://example.com/hello-world.mp3", length: 12665, type: "audio/mpeg" },
|
||||
published,
|
||||
});
|
||||
const actual = sampleFeed.rss2();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
it("should generate a valid feed with video", () => {
|
||||
const sampleFeed = new Feed({
|
||||
title: "Feed Title",
|
||||
description: "This is my personnal feed!",
|
||||
link: "http://example.com/",
|
||||
id: "http://example.com/",
|
||||
language: "en",
|
||||
ttl: 60,
|
||||
image: "http://example.com/image.png",
|
||||
copyright: "All rights reserved 2013, John Doe",
|
||||
hub: "wss://example.com/",
|
||||
updated, // optional, default = today
|
||||
|
||||
author: {
|
||||
name: "John Doe",
|
||||
email: "johndoe@example.com",
|
||||
link: "https://example.com/johndoe",
|
||||
},
|
||||
});
|
||||
sampleFeed.addItem({
|
||||
title: "Hello World",
|
||||
id: "419c523a-28f4-489c-877e-9604be64c005",
|
||||
link: "https://example.com/hello-world4",
|
||||
description: "This is an article about Hello World.",
|
||||
content: "Content of my item",
|
||||
author: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "janedoe@example.com",
|
||||
link: "https://example.com/janedoe",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith",
|
||||
email: "joesmith@example.com",
|
||||
link: "https://example.com/joesmith",
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
{
|
||||
name: "_item_extension_1",
|
||||
objects: {
|
||||
about: "just an item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "_item_extension_2",
|
||||
objects: {
|
||||
about: "just a second item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
],
|
||||
category: [
|
||||
{
|
||||
name: "Grateful Dead",
|
||||
},
|
||||
{
|
||||
name: "MSFT",
|
||||
domain: "http://www.fool.com/cusips",
|
||||
},
|
||||
],
|
||||
date: updated,
|
||||
video: "https://example.com/hello-world.mp4",
|
||||
published,
|
||||
});
|
||||
const actual = sampleFeed.rss2();
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
108
node_modules/feed/src/__tests__/setup.ts
generated
vendored
Normal file
108
node_modules/feed/src/__tests__/setup.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
import { Feed } from "../feed";
|
||||
|
||||
export const updated = new Date("Sat, 13 Jul 2013 23:00:00 GMT");
|
||||
export const published = new Date("Sat, 10 Jul 2013 23:00:00 GMT");
|
||||
|
||||
export const sampleFeed = new Feed({
|
||||
title: "Feed Title",
|
||||
description: "This is my personnal feed!",
|
||||
link: "http://example.com/",
|
||||
id: "http://example.com/",
|
||||
feed: "http://example.com/sampleFeed.rss",
|
||||
feedLinks: {
|
||||
json: "http://example.com/sampleFeed.json",
|
||||
},
|
||||
language: "en",
|
||||
ttl: 60,
|
||||
image: "http://example.com/image.png",
|
||||
favicon: "http://example.com/image.ico",
|
||||
copyright: "All rights reserved 2013, John Doe",
|
||||
hub: "wss://example.com/",
|
||||
updated, // optional, default = today
|
||||
|
||||
author: {
|
||||
name: "John Doe",
|
||||
email: "johndoe@example.com",
|
||||
link: "https://example.com/johndoe?link=sanitized&value=2"
|
||||
}
|
||||
});
|
||||
|
||||
sampleFeed.addCategory("Technology");
|
||||
|
||||
sampleFeed.addContributor({
|
||||
name: "Johan Cruyff",
|
||||
email: "johancruyff@example.com",
|
||||
link: "https://example.com/johancruyff",
|
||||
});
|
||||
|
||||
sampleFeed.addItem({
|
||||
title: "Hello World",
|
||||
id: "https://example.com/hello-world?id=this&that=true",
|
||||
link: "https://example.com/hello-world?link=sanitized&value=2",
|
||||
description: "This is an article about Hello World.",
|
||||
content: "Content of my item",
|
||||
author: [
|
||||
{
|
||||
name: "Jane Doe",
|
||||
email: "janedoe@example.com",
|
||||
link: "https://example.com/janedoe?link=sanitized&value=2",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith",
|
||||
email: "joesmith@example.com",
|
||||
link: "https://example.com/joesmith",
|
||||
},
|
||||
{
|
||||
name: "Joe Smith, Name Only",
|
||||
}
|
||||
],
|
||||
contributor: [
|
||||
{
|
||||
name: "Shawn Kemp",
|
||||
email: "shawnkemp@example.com",
|
||||
link: "https://example.com/shawnkemp",
|
||||
},
|
||||
{
|
||||
name: "Reggie Miller",
|
||||
email: "reggiemiller@example.com",
|
||||
link: "https://example.com/reggiemiller",
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
{
|
||||
name: "_item_extension_1",
|
||||
objects: {
|
||||
about: "just an item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "_item_extension_2",
|
||||
objects: {
|
||||
about: "just a second item extension example",
|
||||
dummy1: "example",
|
||||
},
|
||||
},
|
||||
],
|
||||
category: [
|
||||
{
|
||||
name: "Grateful Dead",
|
||||
},
|
||||
{
|
||||
name: "MSFT",
|
||||
domain: "http://www.fool.com/cusips",
|
||||
},
|
||||
],
|
||||
date: updated,
|
||||
image: "https://example.com/hello-world.jpg",
|
||||
enclosure: { url: "https://example.com/hello-world.jpg", length: 12665, type: "image/jpeg" },
|
||||
published,
|
||||
});
|
||||
|
||||
sampleFeed.addExtension({
|
||||
name: "_example_extension",
|
||||
objects: {
|
||||
about: "just an extension example",
|
||||
dummy: "example",
|
||||
},
|
||||
});
|
||||
15
node_modules/feed/src/__tests__/utils.spec.ts
generated
vendored
Normal file
15
node_modules/feed/src/__tests__/utils.spec.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { sanitize } from "../utils";
|
||||
|
||||
describe("Sanitizing", () => {
|
||||
it("should sanitize & to &", () => {
|
||||
expect('&').toEqual(sanitize('&'));
|
||||
});
|
||||
it("should handle multiple &", () => {
|
||||
expect('https://test.com/?page=1&size=3&length=10').toEqual(sanitize('https://test.com/?page=1&size=3&length=10'));
|
||||
});
|
||||
|
||||
it("should handle undefined", () => {
|
||||
var undefined;
|
||||
expect(sanitize(undefined)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
202
node_modules/feed/src/atom1.ts
generated
vendored
Normal file
202
node_modules/feed/src/atom1.ts
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
import * as convert from "xml-js";
|
||||
import { generator } from "./config";
|
||||
import { Feed } from "./feed";
|
||||
import { Author, Category, Item } from "./typings";
|
||||
import { sanitize } from "./utils";
|
||||
|
||||
/**
|
||||
* Returns an Atom feed
|
||||
* @param ins
|
||||
*/
|
||||
export default (ins: Feed) => {
|
||||
const { options } = ins;
|
||||
|
||||
const base: any = {
|
||||
_declaration: { _attributes: { version: "1.0", encoding: "utf-8" } },
|
||||
feed: {
|
||||
_attributes: { xmlns: "http://www.w3.org/2005/Atom" },
|
||||
id: options.id,
|
||||
title: options.title,
|
||||
updated: options.updated ? options.updated.toISOString() : new Date().toISOString(),
|
||||
generator: sanitize(options.generator || generator)
|
||||
}
|
||||
};
|
||||
|
||||
if (options.author) {
|
||||
base.feed.author = formatAuthor(options.author);
|
||||
}
|
||||
|
||||
base.feed.link = [];
|
||||
|
||||
// link (rel="alternate")
|
||||
if (options.link) {
|
||||
base.feed.link.push({ _attributes: { rel: "alternate", href: sanitize(options.link) } });
|
||||
}
|
||||
|
||||
// link (rel="self")
|
||||
const atomLink = sanitize(options.feed || (options.feedLinks && options.feedLinks.atom));
|
||||
|
||||
if (atomLink) {
|
||||
base.feed.link.push({ _attributes: { rel: "self", href: sanitize(atomLink) } });
|
||||
}
|
||||
|
||||
// link (rel="hub")
|
||||
if (options.hub) {
|
||||
base.feed.link.push({ _attributes: { rel: "hub", href: sanitize(options.hub) } });
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* "feed" node: optional elements
|
||||
*************************************************************************/
|
||||
|
||||
if (options.description) {
|
||||
base.feed.subtitle = options.description;
|
||||
}
|
||||
|
||||
if (options.image) {
|
||||
base.feed.logo = options.image;
|
||||
}
|
||||
|
||||
if (options.favicon) {
|
||||
base.feed.icon = options.favicon;
|
||||
}
|
||||
|
||||
if (options.copyright) {
|
||||
base.feed.rights = options.copyright;
|
||||
}
|
||||
|
||||
base.feed.category = [];
|
||||
|
||||
ins.categories.map((category: string) => {
|
||||
base.feed.category.push({ _attributes: { term: category } });
|
||||
});
|
||||
|
||||
base.feed.contributor = [];
|
||||
|
||||
ins.contributors.map((contributor: Author) => {
|
||||
base.feed.contributor.push(formatAuthor(contributor));
|
||||
});
|
||||
|
||||
// icon
|
||||
|
||||
base.feed.entry = [];
|
||||
|
||||
/**************************************************************************
|
||||
* "entry" nodes
|
||||
*************************************************************************/
|
||||
ins.items.map((item: Item) => {
|
||||
//
|
||||
// entry: required elements
|
||||
//
|
||||
|
||||
let entry: convert.ElementCompact = {
|
||||
title: { _attributes: { type: "html" }, _cdata: item.title },
|
||||
id: sanitize(item.id || item.link),
|
||||
link: [{ _attributes: { href: sanitize(item.link) } }],
|
||||
updated: item.date.toISOString()
|
||||
};
|
||||
|
||||
//
|
||||
// entry: recommended elements
|
||||
//
|
||||
if (item.description) {
|
||||
entry.summary = {
|
||||
_attributes: { type: "html" },
|
||||
_cdata: item.description,
|
||||
};
|
||||
}
|
||||
|
||||
if (item.content) {
|
||||
entry.content = {
|
||||
_attributes: { type: "html" },
|
||||
_cdata: item.content,
|
||||
};
|
||||
}
|
||||
|
||||
// entry author(s)
|
||||
if (Array.isArray(item.author)) {
|
||||
entry.author = [];
|
||||
|
||||
item.author.map((author: Author) => {
|
||||
entry.author.push(formatAuthor(author));
|
||||
});
|
||||
}
|
||||
|
||||
// content
|
||||
|
||||
// link - relative link to article
|
||||
|
||||
//
|
||||
// entry: optional elements
|
||||
//
|
||||
|
||||
// category
|
||||
if (Array.isArray(item.category)) {
|
||||
entry.category = [];
|
||||
|
||||
item.category.map((category: Category) => {
|
||||
entry.category.push(formatCategory(category));
|
||||
});
|
||||
}
|
||||
|
||||
// contributor
|
||||
if (item.contributor && Array.isArray(item.contributor)) {
|
||||
entry.contributor = [];
|
||||
|
||||
item.contributor.map((contributor: Author) => {
|
||||
entry.contributor.push(formatAuthor(contributor));
|
||||
});
|
||||
}
|
||||
|
||||
// published
|
||||
if (item.published) {
|
||||
entry.published = item.published.toISOString();
|
||||
}
|
||||
|
||||
// source
|
||||
|
||||
// rights
|
||||
if (item.copyright) {
|
||||
entry.rights = item.copyright;
|
||||
}
|
||||
|
||||
base.feed.entry.push(entry);
|
||||
});
|
||||
|
||||
return convert.js2xml(base, { compact: true, ignoreComment: true, spaces: 4 });
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a formatted author
|
||||
* @param author
|
||||
*/
|
||||
const formatAuthor = (author: Author) => {
|
||||
const { name, email, link } = author;
|
||||
|
||||
const out: { name?: string, email?: string, uri?: string } = { name };
|
||||
if (email) {
|
||||
out.email = email;
|
||||
}
|
||||
|
||||
if (link) {
|
||||
out.uri = sanitize(link);
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a formatted category
|
||||
* @param category
|
||||
*/
|
||||
const formatCategory = (category: Category) => {
|
||||
const { name, scheme, term } = category;
|
||||
|
||||
return {
|
||||
_attributes: {
|
||||
label: name,
|
||||
scheme,
|
||||
term,
|
||||
},
|
||||
};
|
||||
};
|
||||
1
node_modules/feed/src/config/index.ts
generated
vendored
Normal file
1
node_modules/feed/src/config/index.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const generator = "https://github.com/jpmonette/feed";
|
||||
60
node_modules/feed/src/feed.ts
generated
vendored
Normal file
60
node_modules/feed/src/feed.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import renderAtom from "./atom1";
|
||||
import renderJSON from "./json";
|
||||
import renderRSS from "./rss2";
|
||||
import { Author, Extension, FeedOptions, Item } from "./typings";
|
||||
|
||||
export { Author, Extension, FeedOptions, Item };
|
||||
|
||||
/**
|
||||
* Class used to generate Feeds
|
||||
*/
|
||||
export class Feed {
|
||||
options: FeedOptions;
|
||||
items: Item[] = [];
|
||||
categories: string[] = [];
|
||||
contributors: Author[] = [];
|
||||
extensions: Extension[] = [];
|
||||
|
||||
constructor(options: FeedOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a feed item
|
||||
* @param item
|
||||
*/
|
||||
public addItem = (item: Item) => this.items.push(item);
|
||||
|
||||
/**
|
||||
* Add a category
|
||||
* @param category
|
||||
*/
|
||||
public addCategory = (category: string) => this.categories.push(category);
|
||||
|
||||
/**
|
||||
* Add a contributor
|
||||
* @param contributor
|
||||
*/
|
||||
public addContributor = (contributor: Author) => this.contributors.push(contributor);
|
||||
|
||||
/**
|
||||
* Adds an extension
|
||||
* @param extension
|
||||
*/
|
||||
public addExtension = (extension: Extension) => this.extensions.push(extension);
|
||||
|
||||
/**
|
||||
* Returns a Atom 1.0 feed
|
||||
*/
|
||||
public atom1 = (): string => renderAtom(this);
|
||||
|
||||
/**
|
||||
* Returns a RSS 2.0 feed
|
||||
*/
|
||||
public rss2 = (): string => renderRSS(this);
|
||||
|
||||
/**
|
||||
* Returns a JSON1 feed
|
||||
*/
|
||||
public json1 = (): string => renderJSON(this);
|
||||
}
|
||||
108
node_modules/feed/src/json.ts
generated
vendored
Normal file
108
node_modules/feed/src/json.ts
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
import { Feed } from "./feed";
|
||||
import { Author, Category, Extension, Item } from "./typings";
|
||||
|
||||
/**
|
||||
* Returns a JSON feed
|
||||
* @param ins
|
||||
*/
|
||||
export default (ins: Feed) => {
|
||||
const { options, items, extensions } = ins;
|
||||
|
||||
let feed: any = {
|
||||
version: "https://jsonfeed.org/version/1",
|
||||
title: options.title,
|
||||
};
|
||||
|
||||
if (options.link) {
|
||||
feed.home_page_url = options.link;
|
||||
}
|
||||
|
||||
if (options.feedLinks && options.feedLinks.json) {
|
||||
feed.feed_url = options.feedLinks.json;
|
||||
}
|
||||
|
||||
if (options.description) {
|
||||
feed.description = options.description;
|
||||
}
|
||||
|
||||
if (options.image) {
|
||||
feed.icon = options.image;
|
||||
}
|
||||
|
||||
if (options.author) {
|
||||
feed.author = {};
|
||||
if (options.author.name) {
|
||||
feed.author.name = options.author.name;
|
||||
}
|
||||
if (options.author.link) {
|
||||
feed.author.url = options.author.link;
|
||||
}
|
||||
}
|
||||
|
||||
extensions.map((e: Extension) => {
|
||||
feed[e.name] = e.objects;
|
||||
});
|
||||
|
||||
feed.items = items.map((item: Item) => {
|
||||
let feedItem: any = {
|
||||
id: item.id,
|
||||
// json_feed distinguishes between html and text content
|
||||
// but since we only take a single type, we'll assume HTML
|
||||
content_html: item.content,
|
||||
};
|
||||
if (item.link) {
|
||||
feedItem.url = item.link;
|
||||
}
|
||||
if (item.title) {
|
||||
feedItem.title = item.title;
|
||||
}
|
||||
if (item.description) {
|
||||
feedItem.summary = item.description;
|
||||
}
|
||||
|
||||
if (item.image) {
|
||||
feedItem.image = item.image;
|
||||
}
|
||||
|
||||
if (item.date) {
|
||||
feedItem.date_modified = item.date.toISOString();
|
||||
}
|
||||
if (item.published) {
|
||||
feedItem.date_published = item.published.toISOString();
|
||||
}
|
||||
|
||||
if (item.author) {
|
||||
let author: Author | Author[] = item.author;
|
||||
if (author instanceof Array) {
|
||||
// json feed only supports 1 author per post
|
||||
author = author[0];
|
||||
}
|
||||
feedItem.author = {};
|
||||
if (author.name) {
|
||||
feedItem.author.name = author.name;
|
||||
}
|
||||
if (author.link) {
|
||||
feedItem.author.url = author.link;
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(item.category)) {
|
||||
feedItem.tags = [];
|
||||
item.category.map((category: Category) => {
|
||||
if (category.name) {
|
||||
feedItem.tags.push(category.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (item.extensions) {
|
||||
item.extensions.map((e: Extension) => {
|
||||
feedItem[e.name] = e.objects;
|
||||
});
|
||||
}
|
||||
|
||||
return feedItem;
|
||||
});
|
||||
|
||||
return JSON.stringify(feed, null, 4);
|
||||
};
|
||||
237
node_modules/feed/src/rss2.ts
generated
vendored
Normal file
237
node_modules/feed/src/rss2.ts
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
import * as convert from "xml-js";
|
||||
import { generator } from "./config";
|
||||
import { Feed } from "./feed";
|
||||
import { Author, Category, Enclosure, Item } from "./typings";
|
||||
import { sanitize } from "./utils";
|
||||
|
||||
/**
|
||||
* Returns a RSS 2.0 feed
|
||||
*/
|
||||
export default (ins: Feed) => {
|
||||
const { options } = ins;
|
||||
let isAtom = false;
|
||||
let isContent = false;
|
||||
|
||||
const base: any = {
|
||||
_declaration: { _attributes: { version: "1.0", encoding: "utf-8" } },
|
||||
rss: {
|
||||
_attributes: { version: "2.0" },
|
||||
channel: {
|
||||
title: { _text: options.title },
|
||||
link: { _text: sanitize(options.link) },
|
||||
description: { _text: options.description },
|
||||
lastBuildDate: { _text: options.updated ? options.updated.toUTCString() : new Date().toUTCString() },
|
||||
docs: { _text: options.docs ? options.docs : "https://validator.w3.org/feed/docs/rss2.html" },
|
||||
generator: { _text: options.generator || generator },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Channel language
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltlanguagegtSubelementOfLtchannelgt
|
||||
*/
|
||||
if (options.language) {
|
||||
base.rss.channel.language = { _text: options.language };
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel ttl
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltttlgtSubelementOfLtchannelgt
|
||||
*/
|
||||
if (options.ttl) {
|
||||
base.rss.channel.ttl = { _text: options.ttl };
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel Image
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltimagegtSubelementOfLtchannelgt
|
||||
*/
|
||||
if (options.image) {
|
||||
base.rss.channel.image = {
|
||||
title: { _text: options.title },
|
||||
url: { _text: options.image },
|
||||
link: { _text: sanitize(options.link) }
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel Copyright
|
||||
* https://validator.w3.org/feed/docs/rss2.html#optionalChannelElements
|
||||
*/
|
||||
if (options.copyright) {
|
||||
base.rss.channel.copyright = { _text: options.copyright };
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel Categories
|
||||
* https://validator.w3.org/feed/docs/rss2.html#comments
|
||||
*/
|
||||
ins.categories.map((category) => {
|
||||
if (!base.rss.channel.category) {
|
||||
base.rss.channel.category = [];
|
||||
}
|
||||
base.rss.channel.category.push({ _text: category });
|
||||
});
|
||||
|
||||
/**
|
||||
* Feed URL
|
||||
* http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html
|
||||
*/
|
||||
const atomLink = options.feed || (options.feedLinks && options.feedLinks.rss);
|
||||
if (atomLink) {
|
||||
isAtom = true;
|
||||
base.rss.channel["atom:link"] = [
|
||||
{
|
||||
_attributes: {
|
||||
href: sanitize(atomLink),
|
||||
rel: "self",
|
||||
type: "application/rss+xml",
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Hub for PubSubHubbub
|
||||
* https://code.google.com/p/pubsubhubbub/
|
||||
*/
|
||||
if (options.hub) {
|
||||
isAtom = true;
|
||||
if (!base.rss.channel["atom:link"]) {
|
||||
base.rss.channel["atom:link"] = [];
|
||||
}
|
||||
base.rss.channel["atom:link"] = {
|
||||
_attributes: {
|
||||
href: sanitize(options.hub),
|
||||
rel: "hub"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel Categories
|
||||
* https://validator.w3.org/feed/docs/rss2.html#hrelementsOfLtitemgt
|
||||
*/
|
||||
base.rss.channel.item = [];
|
||||
|
||||
ins.items.map((entry: Item) => {
|
||||
let item: any = {};
|
||||
|
||||
if (entry.title) {
|
||||
item.title = { _cdata: entry.title };
|
||||
}
|
||||
|
||||
if (entry.link) {
|
||||
item.link = { _text: sanitize(entry.link) };
|
||||
}
|
||||
|
||||
if (entry.guid) {
|
||||
item.guid = { _text: entry.guid };
|
||||
} else if (entry.id) {
|
||||
item.guid = { _text: entry.id };
|
||||
} else if (entry.link) {
|
||||
item.guid = { _text: sanitize(entry.link) };
|
||||
}
|
||||
|
||||
if (entry.date) {
|
||||
item.pubDate = { _text: entry.date.toUTCString() };
|
||||
}
|
||||
|
||||
if (entry.published) {
|
||||
item.pubDate = { _text: entry.published.toUTCString() };
|
||||
}
|
||||
|
||||
if (entry.description) {
|
||||
item.description = { _cdata: entry.description };
|
||||
}
|
||||
|
||||
if (entry.content) {
|
||||
isContent = true;
|
||||
item["content:encoded"] = { _cdata: entry.content };
|
||||
}
|
||||
/**
|
||||
* Item Author
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltauthorgtSubelementOfLtitemgt
|
||||
*/
|
||||
if (Array.isArray(entry.author)) {
|
||||
item.author = [];
|
||||
entry.author.map((author: Author) => {
|
||||
if (author.email && author.name) {
|
||||
item.author.push({ _text: author.email + " (" + author.name + ")" });
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Item Category
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltcategorygtSubelementOfLtitemgt
|
||||
*/
|
||||
if (Array.isArray(entry.category)) {
|
||||
item.category = [];
|
||||
entry.category.map((category: Category) => {
|
||||
item.category.push(formatCategory(category));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Item Enclosure
|
||||
* https://validator.w3.org/feed/docs/rss2.html#ltenclosuregtSubelementOfLtitemgt
|
||||
*/
|
||||
if (entry.enclosure) {
|
||||
item.enclosure = formatEnclosure(entry.enclosure);
|
||||
}
|
||||
|
||||
if (entry.image) {
|
||||
item.enclosure = formatEnclosure(entry.image, "image");
|
||||
}
|
||||
|
||||
if (entry.audio) {
|
||||
item.enclosure = formatEnclosure(entry.audio, "audio");
|
||||
}
|
||||
|
||||
if (entry.video) {
|
||||
item.enclosure = formatEnclosure(entry.video, "video");
|
||||
}
|
||||
|
||||
base.rss.channel.item.push(item);
|
||||
});
|
||||
|
||||
if (isContent) {
|
||||
base.rss._attributes["xmlns:dc"] = "http://purl.org/dc/elements/1.1/";
|
||||
base.rss._attributes["xmlns:content"] = "http://purl.org/rss/1.0/modules/content/";
|
||||
}
|
||||
|
||||
if (isAtom) {
|
||||
base.rss._attributes["xmlns:atom"] = "http://www.w3.org/2005/Atom";
|
||||
}
|
||||
return convert.js2xml(base, { compact: true, ignoreComment: true, spaces: 4 });
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a formated enclosure
|
||||
* @param enclosure
|
||||
* @param mimeCategory
|
||||
*/
|
||||
const formatEnclosure = (enclosure: string | Enclosure, mimeCategory = "image") => {
|
||||
if (typeof enclosure === "string") {
|
||||
const type = new URL(enclosure).pathname.split(".").slice(-1)[0];
|
||||
return { _attributes: { url: enclosure, length: 0, type: `${mimeCategory}/${type}` } };
|
||||
}
|
||||
|
||||
const type = new URL(enclosure.url).pathname.split(".").slice(-1)[0];
|
||||
return { _attributes: { length: 0, type: `${mimeCategory}/${type}`, ...enclosure } };
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a formated category
|
||||
* @param category
|
||||
*/
|
||||
const formatCategory = (category: Category) => {
|
||||
const { name, domain } = category;
|
||||
return {
|
||||
_text: name,
|
||||
_attributes: {
|
||||
domain,
|
||||
},
|
||||
};
|
||||
};
|
||||
72
node_modules/feed/src/typings/index.ts
generated
vendored
Normal file
72
node_modules/feed/src/typings/index.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
export interface Item {
|
||||
title: string;
|
||||
id?: string;
|
||||
link: string;
|
||||
date: Date;
|
||||
|
||||
description?: string;
|
||||
content?: string;
|
||||
category?: Category[];
|
||||
|
||||
guid?: string;
|
||||
|
||||
image?: string | Enclosure;
|
||||
audio?: string | Enclosure;
|
||||
video?: string | Enclosure;
|
||||
enclosure?: Enclosure;
|
||||
|
||||
author?: Author[];
|
||||
contributor?: Author[];
|
||||
|
||||
published?: Date;
|
||||
copyright?: string;
|
||||
|
||||
extensions?: Extension[];
|
||||
}
|
||||
|
||||
export interface Enclosure {
|
||||
url: string;
|
||||
type?: string;
|
||||
length?: number;
|
||||
title?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export interface Author {
|
||||
name?: string;
|
||||
email?: string;
|
||||
link?: string;
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
name?: string;
|
||||
domain?: string;
|
||||
scheme?: string;
|
||||
term?: string;
|
||||
}
|
||||
|
||||
export interface FeedOptions {
|
||||
id: string;
|
||||
title: string;
|
||||
updated?: Date;
|
||||
generator?: string;
|
||||
language?: string;
|
||||
ttl?: number;
|
||||
|
||||
feed?: string;
|
||||
feedLinks?: any;
|
||||
hub?: string;
|
||||
docs?: string;
|
||||
|
||||
author?: Author;
|
||||
link?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
favicon?: string;
|
||||
copyright: string;
|
||||
}
|
||||
|
||||
export interface Extension {
|
||||
name: string;
|
||||
objects: any;
|
||||
}
|
||||
6
node_modules/feed/src/utils.ts
generated
vendored
Normal file
6
node_modules/feed/src/utils.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export function sanitize(url: string | undefined): string | undefined {
|
||||
if (typeof (url) === 'undefined') {
|
||||
return;
|
||||
}
|
||||
return url.replace(/&/g, '&');
|
||||
}
|
||||
Reference in New Issue
Block a user