Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config.local.js.SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ export default {
// dnt: true,
cache_ttl: 100 * 365 * 24 * 3600 // 100 Years.
},
readability: {
enabled: false
app: {
// allow_readability: true
// allowPTagDescription: true // to enable description fallback to first paragraph
},
images: {
Expand Down
11 changes: 1 addition & 10 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@
return hasDomainData;
}

const BIG_CONTEXT = ['htmlparser', 'readability', 'decode'];
const BIG_CONTEXT = ['htmlparser', 'readability', 'decode', 'cheerio'];

function prepareResultData(uri, result, options) {

Expand Down Expand Up @@ -1969,15 +1969,6 @@
}
}

if (/* options.getProviderOptions('readability.enabled') === true */
CONFIG.providerOptions && CONFIG.providerOptions.readability
&& CONFIG.providerOptions.readability.enabled === true
|| options.readability) {
context.__readabilityEnabled = true;
// Prevent force load readability plugin.
usedParams.__readabilityEnabled = true;
}

asyncMethodCb('initial');
};

Expand Down
1 change: 0 additions & 1 deletion lib/loader/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"request",
"whitelistRecord",
"iframelyRun",
"__readabilityEnabled",

// Copy from `core.js` `utilsModules`.
"utils",
Expand Down
19 changes: 17 additions & 2 deletions plugins/links/article/article.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import * as cheerio from 'cheerio';

export default {

getData: function(readability, meta, __is_general_article, utils) {
provides: 'articlebody', // if not yet provided from LD articlebody

getData: function(__readabilityEnabled, readability, meta, utils) {

const articleHtml = utils.encodeText(meta.charset, readability.getHTML());
const $p = cheerio.load(articleHtml)('p');

if ($p.text()) {
return {
articlebody: articleHtml
}
}
},

getVars: function(articlebody) {
return {
safe_html: utils.encodeText(meta.charset, readability.getHTML())
articlebody: articlebody
};
}
};
28 changes: 22 additions & 6 deletions plugins/links/article/check-article.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
export default {

provides: '__is_general_article',
provides: [
"__readabilityEnabled",
"articlebody"
],

getData: function(meta, __readabilityEnabled) {
getData: function(meta, options) {

if (meta.og && (meta.og.type === "article" || meta.og.type === "blog")) {
const ld = meta.ld?.newsarticle || meta.ld?.article || meta.ld?.blogposting || meta.ld?.reportagenewsarticle || meta.ld?.socialmediaposting;

return {
__is_general_article: true
};
if ((ld
|| (meta.og && (meta.og.type === "article" || meta.og.type === "blog" || meta.og.type === 'website')
|| meta.twitter?.card === 'summary_large_image'
|| meta.article))

&& (options.getRequestOptions('readability.articlebody', false) || CONFIG.providerOptions?.app?.allow_readability === true)) {

if (ld?.articlebody && /\/>/.test(ld.articlebody)) {
return {
articlebody: ld.articlebody
}
} else if (options.getProviderOptions('app.allow_readability')) {
return {
__readabilityEnabled: true
}
}
}
}
};
10 changes: 10 additions & 0 deletions plugins/links/article/reader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {

getData: function(articlebody) {
if (CONFIG.providerOptions?.app?.allow_readability === true && !CONFIG.SKIP_IFRAMELY_RENDERS) {
return {
safe_html: articlebody
}
}
}
};
2 changes: 1 addition & 1 deletion plugins/links/embedURL/embedURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {

provides: 'schemaVideoObject',

getData: function(url, cheerio, decode, __allowEmbedURL, utils) {
getData: function(url, __allowEmbedURL, cheerio, decode, utils) {

/* Let's try to find ld+json in the body first. */
const ldSelector = 'script[type="application/ld+json"]:contains("VideoObject"), script[type="application/ld+json"]:contains("VideoObject")'
Expand Down
2 changes: 1 addition & 1 deletion plugins/meta/description-from-p-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
lowestPriority: true,
provides: '__allowPTagDescription',

getMeta: function(cheerio, decode, __allowPTagDescription) {
getMeta: function(__allowPTagDescription, cheerio, decode) {
// Get the text from the first <p> tag that's not in a header
var description;
cheerio("body p").each(function() {
Expand Down
2 changes: 1 addition & 1 deletion static/js/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function processUrl() {
// Render context.
var contexts = data.allData && data.allData
.filter(function(d) {
return d.method.name === 'getData';
return d.method.name === 'getData' || d.method.name === 'getVars';
})
.map(function(d) {
return d.data;
Expand Down