reallysimple 0.4.5 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reallysimple",
3
- "description": "Reads an RSS-like feed and calls back with a JavaScript structure, hiding all the history. It really is simple. ;-)",
4
- "version": "0.4.5",
3
+ "description": "A Node package that reads RSS-like feeds and calls back with a simple, consistent JavaScript object. Easy to use, hides the history.",
4
+ "version": "0.4.8",
5
5
  "author": "Dave Winer <dave@scripting.com>",
6
6
  "license": "MIT",
7
7
  "files": [
package/readme.md CHANGED
@@ -1,74 +1,28 @@
1
1
  # reallysimple
2
2
 
3
- JavaScript code to read a feed. Calls back with a simple JavaScript object, easily represented in JSON. Hides all the history.
3
+ A Node package that reads RSS-like feeds and calls back with a simple, consistent JavaScript object. Easy to use, hides the history.
4
4
 
5
- #### What formats are supported?
6
-
7
- RSS, Atom, and RDF.
8
-
9
- #### Why?
10
-
11
- I wanted to make reading a feed from a JavaScript app as easy as possible.
12
-
13
- To hide all the history to get it out of your way.
14
-
15
- If developers can quickly put together an app that uses feeds, people will try out more ideas, add feed support to more apps.
5
+ #### Code example
16
6
 
17
- I needed to simplify feed reading for the scripting system in Drummer. For scripting, simplicity is everything. Why not share the simplicity with lower level code.
7
+ I always like to see the code first...
18
8
 
19
- There probably is a small tradeoff in performance, you can probably write faster code by going straight to the feedparser level. And that's fine for applications that require the maximum performance, perhaps where you're reading a thousand feeds per sectond.
9
+ ```javascript
20
10
 
21
- #### A coding example
11
+ Here's <a href="https://github.com/scripting/reallysimple/blob/main/example/test.json">the file</a> that's created when you run the code.
22
12
 
23
- Here's how you call the package.
24
-
25
- const reallysimple = require ("reallysimple");
26
-
27
- const url = "http://scripting.com/rss.xml";
28
-
29
- reallysimple.readFeed (url, function (err, theFeed) {
30
-
31
- if (!err) {
32
-
33
- console.log ("theFeed == " + JSON.stringify (theFeed));
13
+ #### Why?
34
14
 
35
- }
15
+ I needed a simple routine to call when I wanted to read a feed.
36
16
 
37
- }):
17
+ #### What formats are supported?
38
18
 
39
- Here's what shows up in the console when you run that code.
19
+ RSS, Atom, and RDF.
40
20
 
41
21
  #### What we build on
42
22
 
43
23
  Thanks to Dan MacTough for the <a href="https://www.npmjs.com/package/feedparser">feedparser</a> package.
44
24
 
45
- It also builds on the davefeedread package, which simplifies the programming interface to feedparser.
46
-
47
- This package further simplifies the struct returned by <a href="https://www.npmjs.com/package/davefeedread">davefeedread</a>.
48
-
49
- #### Work notes
50
-
51
- 3/21/22; 10:19:22 AM by DW
52
-
53
- Reviewing the way we represent links in items in the API.
54
-
55
- The question is this -- how can we get a link to the item from the item.
56
-
57
- The answer, on reflection -- rely on the link element as the permalink.
58
-
59
- 3/7/22; 10:27:47 AM by DW
60
-
61
- Start the reallysimple repo. Publish the NPM package.
62
-
63
- 3/6/22; 11:27:52 AM by DW
64
-
65
- It now understands various elements from the source namespace, including source:account, source:localtime and source:outline.
66
-
67
- Started a new private GitHub repo for the project and saved the files.
68
-
69
- Added it to my NPM sub-menu, this is going to be a supported project.
70
-
71
25
  #### Comments, questions?
72
26
 
73
- Please post your comments and questions in the <a href="https://github.com/scripting/reallysimple/issues/new">issues section</a> of this repo.
27
+ Post comments and questions in the <a href="https://github.com/scripting/reallysimple/issues/new">issues section</a> of this repo.
74
28
 
package/readme.opml CHANGED
@@ -2,7 +2,7 @@
2
2
  <opml version="2.0">
3
3
  <head>
4
4
  <title>readme.md</title>
5
- <dateModified>Sun, 27 Mar 2022 16:05:47 GMT</dateModified>
5
+ <dateModified>Sat, 11 Jun 2022 20:01:27 GMT</dateModified>
6
6
  <expansionState></expansionState>
7
7
  <vertScrollState>1</vertScrollState>
8
8
  <windowTop>300</windowTop>
@@ -12,53 +12,24 @@
12
12
  </head>
13
13
  <body created="Sat, 05 Mar 2022 16:54:13 GMT" text="readme.md">
14
14
  <outline created="Sat, 05 Mar 2022 16:54:15 GMT" text="# reallysimple">
15
- <outline created="Mon, 07 Mar 2022 15:05:45 GMT" text="JavaScript code to read a feed. Calls back with a simple JavaScript object, easily represented in JSON. Hides all the history."></outline>
15
+ <outline created="Sat, 11 Jun 2022 15:59:23 GMT" text="A Node package that reads RSS-like feeds and calls back with a simple, consistent JavaScript object. Easy to use, hides the history."></outline>
16
16
  </outline>
17
- <outline created="Thu, 17 Mar 2022 15:42:49 GMT" text="#### What formats are supported?">
18
- <outline created="Thu, 17 Mar 2022 15:42:57 GMT" text="RSS, Atom, and RDF."></outline>
17
+ <outline created="Sat, 11 Jun 2022 16:24:18 GMT" text="#### Code example">
18
+ <outline created="Sat, 11 Jun 2022 16:20:10 GMT" text="I always like to see the code first..."></outline>
19
+ <outline text="&lt;%includeExample (&quot;example1&quot;)%&gt;"></outline>
20
+ <outline created="Mon, 07 Mar 2022 15:10:30 GMT" text="Here's &lt;a href=&quot;https://github.com/scripting/reallysimple/blob/main/example/test.json&quot;&gt;the file&lt;/a&gt; that's created when you run the code. "></outline>
19
21
  </outline>
20
- <outline text="#### Why?">
21
- <outline created="Thu, 17 Mar 2022 15:40:05 GMT" text="I wanted to make reading a feed from a JavaScript app as easy as possible. "></outline>
22
- <outline created="Thu, 17 Mar 2022 15:40:29 GMT" text="To hide all the history to get it out of your way. "></outline>
23
- <outline created="Mon, 07 Mar 2022 15:16:54 GMT" text="If developers can quickly put together an app that uses feeds, people will try out more ideas, add feed support to more apps."></outline>
24
- <outline created="Mon, 07 Mar 2022 15:17:44 GMT" text="I needed to simplify feed reading for the scripting system in Drummer. For scripting, simplicity is everything. Why not share the simplicity with lower level code."></outline>
25
- <outline created="Mon, 07 Mar 2022 15:18:12 GMT" text="There probably is a small tradeoff in performance, you can probably write faster code by going straight to the feedparser level. And that's fine for applications that require the maximum performance, perhaps where you're reading a thousand feeds per sectond. "></outline>
22
+ <outline created="Sat, 11 Jun 2022 16:00:30 GMT" text="#### Why?">
23
+ <outline created="Sat, 11 Jun 2022 16:00:36 GMT" text="I needed a simple routine to call when I wanted to read a feed. "></outline>
26
24
  </outline>
27
- <outline created="Mon, 07 Mar 2022 15:11:02 GMT" text="#### A coding example">
28
- <outline created="Mon, 07 Mar 2022 15:11:09 GMT" text="Here's how you call the package."></outline>
29
- <outline created="Mon, 07 Mar 2022 15:12:02 GMT" text="const reallysimple = require (&quot;reallysimple&quot;);"></outline>
30
- <outline created="Mon, 07 Mar 2022 15:12:17 GMT" text="const url = &quot;http://scripting.com/rss.xml&quot;;"></outline>
31
- <outline created="Mon, 07 Mar 2022 15:11:18 GMT" text="reallysimple.readFeed (url, function (err, theFeed) {">
32
- <outline created="Mon, 07 Mar 2022 15:12:40 GMT" text="if (!err) {">
33
- <outline created="Mon, 07 Mar 2022 15:12:44 GMT" text="console.log (&quot;theFeed == &quot; + JSON.stringify (theFeed));"></outline>
34
- <outline created="Mon, 07 Mar 2022 15:13:04 GMT" text="}"></outline>
35
- </outline>
36
- <outline created="Mon, 07 Mar 2022 15:11:54 GMT" text="}):"></outline>
37
- </outline>
38
- <outline created="Mon, 07 Mar 2022 15:10:30 GMT" text="Here's what shows up in the console when you run that code. "></outline>
25
+ <outline created="Thu, 17 Mar 2022 15:42:49 GMT" text="#### What formats are supported?">
26
+ <outline created="Thu, 17 Mar 2022 15:42:57 GMT" text="RSS, Atom, and RDF."></outline>
39
27
  </outline>
40
28
  <outline created="Mon, 07 Mar 2022 15:25:06 GMT" text="#### What we build on">
41
29
  <outline created="Mon, 07 Mar 2022 15:25:07 GMT" text="Thanks to Dan MacTough for the &lt;a href=&quot;https://www.npmjs.com/package/feedparser&quot;&gt;feedparser&lt;/a&gt; package."></outline>
42
- <outline created="Mon, 07 Mar 2022 15:25:33 GMT" text="It also builds on the davefeedread package, which simplifies the programming interface to feedparser."></outline>
43
- <outline created="Thu, 17 Mar 2022 15:46:06 GMT" text="This package further simplifies the struct returned by &lt;a href=&quot;https://www.npmjs.com/package/davefeedread&quot;&gt;davefeedread&lt;/a&gt;."></outline>
44
- </outline>
45
- <outline created="Sat, 05 Mar 2022 17:30:26 GMT" text="#### Work notes">
46
- <outline created="Mon, 21 Mar 2022 14:19:22 GMT" text="3/21/22; 10:19:22 AM by DW">
47
- <outline created="Mon, 21 Mar 2022 14:19:22 GMT" text="Reviewing the way we represent links in items in the API. "></outline>
48
- <outline created="Mon, 21 Mar 2022 14:27:17 GMT" text="The question is this -- how can we get a link to the item from the item. "></outline>
49
- <outline created="Mon, 21 Mar 2022 14:27:44 GMT" text="The answer, on reflection -- rely on the link element as the permalink. "></outline>
50
- </outline>
51
- <outline created="Mon, 07 Mar 2022 15:27:46 GMT" text="3/7/22; 10:27:47 AM by DW">
52
- <outline created="Mon, 07 Mar 2022 15:27:47 GMT" text="Start the reallysimple repo. Publish the NPM package. "></outline>
53
- </outline>
54
- <outline created="Sun, 06 Mar 2022 16:27:50 GMT" text="3/6/22; 11:27:52 AM by DW">
55
- <outline created="Sun, 06 Mar 2022 16:27:53 GMT" text="It now understands various elements from the source namespace, including source:account, source:localtime and source:outline."></outline>
56
- <outline created="Sun, 06 Mar 2022 16:28:33 GMT" text="Started a new private GitHub repo for the project and saved the files. "></outline>
57
- <outline created="Sun, 06 Mar 2022 16:29:01 GMT" text="Added it to my NPM sub-menu, this is going to be a supported project."></outline>
58
- </outline>
59
30
  </outline>
60
31
  <outline created="Mon, 07 Mar 2022 15:26:41 GMT" text="#### Comments, questions?">
61
- <outline created="Mon, 07 Mar 2022 15:26:47 GMT" text="Please post your comments and questions in the &lt;a href=&quot;https://github.com/scripting/reallysimple/issues/new&quot;&gt;issues section&lt;/a&gt; of this repo."></outline>
32
+ <outline created="Mon, 07 Mar 2022 15:26:47 GMT" text="Post comments and questions in the &lt;a href=&quot;https://github.com/scripting/reallysimple/issues/new&quot;&gt;issues section&lt;/a&gt; of this repo."></outline>
62
33
  </outline>
63
34
  </body>
64
35
  </opml>
package/reallysimple.js CHANGED
@@ -1,4 +1,4 @@
1
- var myProductName = "reallysimple"; myVersion = "0.4.5";
1
+ var myProductName = "reallysimple"; myVersion = "0.4.8";
2
2
 
3
3
  exports.readFeed = readFeed;
4
4
  exports.convertFeedToOpml = convertFeedToOpml;
@@ -15,13 +15,21 @@ const allowedHeadNames = [
15
15
  const allowedItemNames = [
16
16
  "title", "link", "description", "author", "category", "comments", "enclosures", "guid", "pubDate", "source", "source:outline", "source:likes"
17
17
  ];
18
+ const allowedEnclosureNames = [
19
+ "url", "type", "length"
20
+ ];
18
21
 
19
22
  var config = {
20
23
  timeOutSecs: 3
21
24
  }
22
25
 
23
26
  function isEmptyObject (obj) {
24
- return (Object.keys (obj).length === 0);
27
+ try {
28
+ return (Object.keys (obj).length === 0);
29
+ }
30
+ catch (err) {
31
+ return (true); //6/8/22 by DW
32
+ }
25
33
  }
26
34
  function getItemPermalink (item) {
27
35
  var rssguid = item ["rss:guid"], returnedval = undefined;
@@ -150,8 +158,15 @@ function convertFeed (oldFeed) {
150
158
 
151
159
  getHeadValuesFromFirstItem (); //3/6/22 by DW
152
160
 
153
- if (isEmptyObject (newFeed.image)) {
154
- delete newFeed.image;
161
+ if (newFeed.image !== undefined) { //5/17/22 by DW
162
+ if (isEmptyObject (newFeed.image)) {
163
+ delete newFeed.image;
164
+ }
165
+ }
166
+ if (newFeed.cloud !== undefined) { //6/11/22 by DW
167
+ if (isEmptyObject (newFeed.cloud)) {
168
+ delete newFeed.cloud;
169
+ }
155
170
  }
156
171
 
157
172
  newFeed.items = new Array ();
@@ -182,9 +197,26 @@ function convertFeed (oldFeed) {
182
197
  }
183
198
  }
184
199
  newItem.guid = getItemPermalink (item);
185
- if (isEmptyObject (newItem.source)) {
186
- delete newItem.source;
200
+ if (newItem.source !== undefined) { //5/17/22 by DW
201
+ if (isEmptyObject (newItem.source)) {
202
+ delete newItem.source;
203
+ }
204
+ }
205
+
206
+ if (newItem.enclosure !== undefined) { //6/11/22 by DW
207
+ var enc = new Object ();
208
+ for (var x in newItem.enclosure) {
209
+ allowedEnclosureNames.forEach (function (name) {
210
+ if (x == name) {
211
+ if (newItem.enclosure [x] != null) {
212
+ enc [x] = newItem.enclosure [x];
213
+ }
214
+ }
215
+ });
216
+ }
217
+ newItem.enclosure = enc;
187
218
  }
219
+
188
220
  newFeed.items.push (newItem);
189
221
  });
190
222