Comparing version 0.8.0 to 0.9.0
@@ -5,3 +5,3 @@ ![header](./assets/Favicon.png) | ||
# Creamcrop <small>v0.8.0</small> | ||
# Creamcrop <small>v0.9.0</small> | ||
@@ -8,0 +8,0 @@ > A cream-of-the-crop, top-of-the-top, slice-and-chop, absolutely minimalist news getter |
@@ -5,4 +5,5 @@ * **Documentation** | ||
* [Config](./config.md) | ||
* [Sorting](./sort.md) | ||
* **Other Info** | ||
* [FAQ](./faq.md) | ||
@@ -36,2 +36,3 @@ > Configuration for the package | ||
| `custom` | A custom HTML template. Inside the HTML, use `%feed%`, which will be replaced by the _unread_ content of the feed, and `%read%` for the _read_ content of the feed. Use `%update%` in the HTML, which will be replaced by a script that auto-updates the RSS feed. Use `%search%` in the HTML to get the search bar to filter through results. | A basic HTML page. | The relative path to the HTML template file | | ||
| `read` | Array of URLs which have already been read. Whenever you click a URL on the webpage, it is automatically added here. | `[]` | An array of URLs as strings. | | ||
| `read` | Array of URLs which have already been read. Whenever you click a URL on the webpage, it is automatically added here. | `[]` | An array of URLs as strings. | | ||
| `sort` | File which contains custom sorting script. See [sort](sort.md) for more information | `""` | A string containing the relative file path to the javascript file | |
@@ -116,3 +116,3 @@ > Learn the fundamentals of creamcrop | ||
Qlabs (@Quantalabs) | ||
0.8.0 | ||
0.9.0 | ||
``` | ||
@@ -158,3 +158,3 @@ | ||
$ cream --version | ||
0.8.0 | ||
0.9.0 | ||
``` |
{ | ||
"name": "@creamcropdev/creamcrop", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "A cream-of-the-crop, top-of-the-top, slice-and-chop, absolutely minimalist news getter.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
{ | ||
"name": "creamcrop", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "A cream-of-the-crop, top-of-the-top, slice-and-chop, absolutely minimalist news getter.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -102,10 +102,22 @@ const http = require('http'); | ||
// Sort all the items in feed.items by date | ||
// Sort all the items in feed.items by date, or by function in config.sort, if it exists | ||
feed.items = feed.items.sort(function(a, b) { | ||
return new Date(b.pubdate) - new Date(a.pubdate); | ||
if (config.sort) { | ||
const sortFunc = require(config.sort); | ||
return sortFunc(a, b); | ||
} | ||
else { | ||
return new Date(b.pubdate) - new Date(a.pubdate); | ||
} | ||
}); | ||
// Sort all the items in read.items by date | ||
// Sort all the items in read.items by date, or by function in config.sort, if it exists | ||
read.items = read.items.sort(function(a, b) { | ||
return new Date(b.pubdate) - new Date(a.pubdate); | ||
if (config.sort) { | ||
const sortFunc = require(config.sort); | ||
return sortFunc(a, b); | ||
} | ||
else { | ||
return new Date(b.pubdate) - new Date(a.pubdate); | ||
} | ||
}); | ||
@@ -153,2 +165,29 @@ | ||
`).join('\n')); | ||
// if %sort% is found, replace it with all the items in feed.items and read.items, sorted by the function in config.sort, or by date, if it doesn't exist | ||
customconf = customconf.replace(/%sort%/g, function() { | ||
if (config.sort) { | ||
const sortFunc = require(config.sort); | ||
// Combine feed.items and read.items | ||
let items = feed.items.concat(read.items); | ||
// Sort the items | ||
items = items.sort(sortFunc); | ||
// Return the items in HTML format | ||
return items.map(item => ` | ||
${format(item.title, item.link, item.feedlink, item.feed, item.pubdate, `<div onClick="markRead(${item.link})">`, '</div>')} | ||
`).join('\n'); | ||
} | ||
else { | ||
// Combine feed.items and read.items | ||
let items = feed.items.concat(read.items); | ||
// Sort the items | ||
items = items.sort(function(a, b) { | ||
return new Date(b.pubdate) - new Date(a.pubdate); | ||
}); | ||
// Return the items in HTML format | ||
return items.map(item => ` | ||
${format(item.title, item.link, item.feedlink, item.feed, item.pubdate, `<div onClick="markRead(${item.link})">`, '</div>')} | ||
`).join('\n'); | ||
} | ||
}); | ||
@@ -155,0 +194,0 @@ // Replace %update% with automatic reloading script with interval in customconf |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160171
40
486
5