reallysimple 0.4.10 → 0.4.13
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 +1 -1
- package/reallysimple.js +16 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reallysimple",
|
|
3
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.
|
|
4
|
+
"version": "0.4.13",
|
|
5
5
|
"author": "Dave Winer <dave@scripting.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
package/reallysimple.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
var myProductName = "reallysimple", myVersion = "0.4.
|
|
1
|
+
var myProductName = "reallysimple", myVersion = "0.4.13";
|
|
2
2
|
|
|
3
3
|
exports.readFeed = readFeed;
|
|
4
4
|
exports.convertFeedToOpml = convertFeedToOpml;
|
|
5
|
+
exports.setConfig = setConfig; //6/23/22 by DW
|
|
5
6
|
|
|
6
7
|
const utils = require ("daveutils");
|
|
7
8
|
const request = require ("request");
|
|
@@ -20,9 +21,14 @@ const allowedEnclosureNames = [
|
|
|
20
21
|
];
|
|
21
22
|
|
|
22
23
|
var config = {
|
|
23
|
-
timeOutSecs:
|
|
24
|
+
timeOutSecs: 10
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
function setConfig (options) { //6/23/22 by DW
|
|
28
|
+
for (var x in options) {
|
|
29
|
+
config [x] = options [x];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
26
32
|
function isEmptyObject (obj) {
|
|
27
33
|
try {
|
|
28
34
|
return (Object.keys (obj).length === 0);
|
|
@@ -79,8 +85,7 @@ function convertFeedToOpml (theFeed) { //use this if you want to show an RSS fee
|
|
|
79
85
|
});
|
|
80
86
|
return (opml.stringify (theOutline));
|
|
81
87
|
}
|
|
82
|
-
function convertFeed (oldFeed) {
|
|
83
|
-
|
|
88
|
+
function convertFeed (oldFeed, whenstart) {
|
|
84
89
|
var newFeed = new Object ();
|
|
85
90
|
|
|
86
91
|
function convertOutline (jstruct) {
|
|
@@ -169,6 +174,11 @@ function convertFeed (oldFeed) {
|
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
|
|
177
|
+
newFeed.metadata = { //7/2/22 by DW
|
|
178
|
+
readerApp: myProductName + " v" + myVersion,
|
|
179
|
+
ctSecs: utils.secondsSince (whenstart)
|
|
180
|
+
};
|
|
181
|
+
|
|
172
182
|
newFeed.items = new Array ();
|
|
173
183
|
oldFeed.items.forEach (function (item) {
|
|
174
184
|
var newItem = new Object ();
|
|
@@ -224,12 +234,13 @@ function convertFeed (oldFeed) {
|
|
|
224
234
|
}
|
|
225
235
|
|
|
226
236
|
function readFeed (url, callback) {
|
|
237
|
+
const whenstart = new Date ();
|
|
227
238
|
davefeedread.parseUrl (url, config.timeOutSecs, function (err, theFeed) {
|
|
228
239
|
if (err) {
|
|
229
240
|
callback (err);
|
|
230
241
|
}
|
|
231
242
|
else {
|
|
232
|
-
callback (undefined, convertFeed (theFeed));
|
|
243
|
+
callback (undefined, convertFeed (theFeed, whenstart));
|
|
233
244
|
}
|
|
234
245
|
});
|
|
235
246
|
}
|