Skip to content

Commit

Permalink
Merge pull request #4019 from omnivore-app/fix/thumbnail
Browse files Browse the repository at this point in the history
fix: fail to display the thumbnail of some webpages
  • Loading branch information
sywhb authored Jun 3, 2024
2 parents 1df84f7 + f7c6a02 commit e64fee1
Show file tree
Hide file tree
Showing 8 changed files with 3,796 additions and 618 deletions.
5 changes: 3 additions & 2 deletions packages/readabilityjs/Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,8 @@ Readability.prototype = {
var metaElements = this._doc.getElementsByTagName("meta");

// property is a space-separated list of values
var propertyPattern = /\s*(dc|dcterm|og|twitter|article)\s*:\s*(locale|author|creator|description|title|site_name|published_time|published|date|image)\s*/gi;
var propertyPattern =
/\s*(dc|dcterm|og|twitter|article)\s*:\s*(locale|author|creator|description|title|site_name|published_time|published|date|image(?:$|\s|:url|:secure_url))\s*/gi;

// name is a single value
var namePattern = /^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name|date|image)\s*$/i;
Expand Down Expand Up @@ -2056,7 +2057,7 @@ Readability.prototype = {
values["og:image"] ||
values["weibo:article:image"] ||
values["weibo:webpage:image"] ||
jsonld.previewImage
jsonld.previewImage;

metadata.locale = values["og:locale"];

Expand Down
2 changes: 1 addition & 1 deletion packages/readabilityjs/test/generate-testcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async function fetchSource(url, callbackFn) {
}
})()
}),
page.waitForTimeout(5000), //5 second timeout
new Promise((resolve) => setTimeout(resolve, 5000)),
])

// get document body with all hidden elements removed
Expand Down
680 changes: 340 additions & 340 deletions packages/readabilityjs/test/index.html

Large diffs are not rendered by default.

154 changes: 153 additions & 1 deletion packages/readabilityjs/test/test-pages/techcrunch/distiller.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"title": "SBF regrets declaring FTX bankrupt",
"byline": "Alex Wilhelm, Natasha Mascarenhas",
"dir": null,
"excerpt": "The saga of FTX, formerly one of the world’s largest crypto exchanges that fell rapidly into bankruptcy, took a new turn today after Vox published a series of messages with its former CEO Sam Bankman-Fried. The erstwhile executive, known in the crypto world as SBF, discussed regulators, ethics and bankruptcy regrets, amongst other issues that […]",
"excerpt": "FTX founder and former CEO Sam Bankman-Fried talks about regulators, bankruptcy and \"the sketchy stuff\" over the past week.",
"siteName": "TechCrunch",
"siteIcon": "https://techcrunch.com/wp-content/uploads/2015/02/cropped-cropped-favicon-gradient.png?w=32",
"previewImage": "https://techcrunch.com/wp-content/uploads/2022/11/GettyImages-1238326461.jpg?w=680",
"previewImage": "https://techcrunch.com/wp-content/uploads/2022/11/GettyImages-1238326461.jpg?resize=1200,775",
"publishedDate": "2022-11-16T21:58:29.000Z",
"language": "English",
"readerable": true
Expand Down
376 changes: 354 additions & 22 deletions packages/readabilityjs/test/test-pages/techcrunch/expected.html

Large diffs are not rendered by default.

3,177 changes: 2,927 additions & 250 deletions packages/readabilityjs/test/test-pages/techcrunch/source.html

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5178,6 +5178,22 @@
"@radix-ui/react-primitive" "1.0.3"
"@radix-ui/react-use-callback-ref" "1.0.1"

"@radix-ui/react-hover-card@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@radix-ui/react-hover-card/-/react-hover-card-1.0.7.tgz#684bca2504432566357e7157e087051aa3577948"
integrity sha512-OcUN2FU0YpmajD/qkph3XzMcK/NmSk9hGWnjV68p6QiZMgILugusgQwnLSDs3oFSJYGKf3Y49zgFedhGh04k9A==
dependencies:
"@babel/runtime" "^7.13.10"
"@radix-ui/primitive" "1.0.1"
"@radix-ui/react-compose-refs" "1.0.1"
"@radix-ui/react-context" "1.0.1"
"@radix-ui/react-dismissable-layer" "1.0.5"
"@radix-ui/react-popper" "1.1.3"
"@radix-ui/react-portal" "1.0.4"
"@radix-ui/react-presence" "1.0.1"
"@radix-ui/react-primitive" "1.0.3"
"@radix-ui/react-use-controllable-state" "1.0.1"

"@radix-ui/[email protected]", "@radix-ui/react-id@^0.1.1":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@radix-ui/react-id/-/react-id-0.1.5.tgz#010d311bedd5a2884c1e9bb6aaaa4e6cc1d1d3b8"
Expand Down

0 comments on commit e64fee1

Please sign in to comment.