Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use article's first meaningful (more than 50 characters) paragraph as excerpt if description not found #4028

Merged
merged 2 commits into from
Jun 5, 2024
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
2 changes: 1 addition & 1 deletion packages/content-handler/src/websites/youtube-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class YoutubeHandler extends ContentHandler {
<meta property="og:image" content="${thumbnail}" />
<meta property="og:image:secure_url" content="${thumbnail}" />
<meta property="og:title" content="${escapedTitle}" />
<meta property="og:description" content="" />
<meta property="og:description" content="${escapedTitle}" />
<meta property="og:article:author" content="${authorName}" />
<meta property="og:site_name" content="YouTube" />
<meta property="og:type" content="video" />
Expand Down
13 changes: 9 additions & 4 deletions packages/readabilityjs/Readability.js
Original file line number Diff line number Diff line change
Expand Up @@ -3101,13 +3101,18 @@ Readability.prototype = {
this._postProcessContent(articleContent);

// If we haven't found an excerpt in the article's metadata, use the article's
// first paragraph as the excerpt. This is used for displaying a preview of
// first meaningful paragraph (more than 50 characters) as the excerpt. This is used for displaying a preview of
// the article's content.
if (!metadata.excerpt) {
var paragraphs = articleContent.getElementsByTagName("p");
if (paragraphs.length > 0) {
metadata.excerpt = paragraphs[0].textContent.trim();
}
for (const p of paragraphs) {
const text = p.textContent.trim();

if (text.length > 50) {
metadata.excerpt = text;
break;
}
};
}
if (!metadata.siteName) {
// Fallback to hostname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"title": "New corona regs, Kotti cops, electric cars",
"byline": "Andrew Bulkeley",
"dir": null,
"excerpt": "Hello 20\n Percent,",
"excerpt": "We\n agreed to confine my wife to my son’s room. She was included in the\n democratic process because she’s the one with corona. And now every time she heads out\n for food, to use the restroom or to just change clothes, we go through a complex tetris of\n opening windows, dawning masks and maintaining social distancing. A weird thing in your own\n house. But we’ve survived lice, moths in the larder and even black mold - Berlin\n things. So we’ll get through this too - so far it’s been little more\n than a serious cold for her (YMMV). Since we’re all\n boostered, it will be interesting to see who is also felled by the virus. I’m fine for\n now (knocks on wooden floor).",
"siteName": "fakehost",
"publishedDate": "2001-01-13T16:00:00.000Z",
"language": "English",
"readerable": true
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="readability-page-1" class="page">
<DIV class="page" id="readability-page-1">
<div>
<div>
<h3> and startups bringing in more money than our brains can comprehend.</h3>
Expand Down Expand Up @@ -34,7 +34,7 @@ <h3> New corona rules today (Friday)</h3>
<p>Why make it easy when you can make it more complex? Corona regulations are generally passed by the federal government and then have to be passed again at the state level, often with inexplicable local flourishes, before becoming law. This creates a Germany-wide quilt of differing regulations that few understand. This week is no different though Berlin has decided to stretch the introduction over two days. Starting today in Berlin, <strong>people in contact with an infected person no longer have to go into quarantine if they’ve received a booster vaccination or belong to the new “fresh” category</strong> - “freshly” vaccinated or recovered. “Fresh” means within the past three months. Quarantine for other contact persons now ends after 10 days, rather than 14, and people can test out (rapid antibody or PCR) after 7 days. Is anyone enforcing this?</p>
<h3> New corona rules Saturday (tomorrow)</h3>
<p><strong>FFP2 masks are now mandatory on public transport,</strong> so keep the surgical masks until the next time politicians change their minds (the only constant in this pandemic). Bars and restaurants are also 2G plus, which means recently recovered or vaccinated PLUS a same-day negative test result or proof of a booster vaccination. This applies to any other indoor events with more than 10 people as well. </p>
<p data-attrs="{&quot;url&quot;:&quot;https://www.20percent.berlin/p/39-new-corona-regs-kotti-cops-electric?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share&amp;token=eyJ1c2VyX2lkIjo3MjU3NzcyMSwicG9zdF9pZCI6NDcxMTExNzcsImlhdCI6MTY0MjE2MzcwNSwiaXNzIjoicHViLTQ1ODkyOCIsInN1YiI6InBvc3QtcmVhY3Rpb24ifQ.dq7RHyYt5F3T-ZdUes3QPkKhh9HQhl2jAzAlAEAuHmY&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}">
<p data-attrs="{&quot;url&quot;:&quot;https://www.20percent.berlin/p/39-new-corona-regs-kotti-cops-electric?utm_source=substack&utm_medium=email&utm_content=share&action=share&token=eyJ1c2VyX2lkIjo3MjU3NzcyMSwicG9zdF9pZCI6NDcxMTExNzcsImlhdCI6MTY0MjE2MzcwNSwiaXNzIjoicHViLTQ1ODkyOCIsInN1YiI6InBvc3QtcmVhY3Rpb24ifQ.dq7RHyYt5F3T-ZdUes3QPkKhh9HQhl2jAzAlAEAuHmY&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}">
<a href="https://email.mg2.substack.com/c/eJxNksty2jAUhp8G7_Do4gteeEETKG4LKSlhQjYeWzpgYVtyJTmOefrKoZ2pRtKMPp2bjn5WWLgoPaadMtabttyOHaQSBtOAtaC93oDOBU9jEsZxTLDH04DjRbjwhMnPGqAtRJNa3YPX9WUjWGGFkpNHEC4SsvCq9LyAIEJlgUPGITmHlGDAhCMKJccFgnvioucCJIMU3kGPSoLXpJW1nZnR5Yys3RyGwSeoA81AWr8E3QjpcOcWTeau5jlTWsliruFi5rWyVjjSmTk0wKwWbEbXvW1zo3oXYkYfTV8aW7B6RqKJt8BF3zr--aa_kClpXbrJuio0OFqw6YX_AatqmM4wfsOMHMdX0tTZVdHt9YXubmzc_hoE-5rc-Drp3h6yaPfIPraH1Ye7M1nbVNyx7eGEttcV2d7YsHP2xevu5mIItjmKH4c9fnqsx6eHzGRyh08iizL55Z3RvWXtsTrR564kgTjvff47ft6MJxuu6WH-xl_A0P3P-ntVJZt91ZDr8rZslqtlv2lPnkgJIgRhHGBCQ0R94qMI8zJAYRwlJUY89s91OdprXM0C1F6I_69hPlOtp1Mz-kNfle7yMnXskzoRuJ61bS-FHXOQRdkAv-vD3mX22d38AhK0kx_PC5viKCA4ojEKA0TvcpgEFGM34thzablyXtJV3Gl1c__xB_Kk7Mk" rel=""><span>Share</span></a>
</p>
<h3> Kotti police station</h3>
Expand Down Expand Up @@ -76,4 +76,4 @@ <h3> Did you say patreon?</h3>
</p>
</div>
</div>
</div>
</DIV>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
content="https://i.ytimg.com/vi/c3mbELVqAmo/hqdefault.jpg"
/>
<meta property="og:title" content="The Story of Celeste's Development" />
<meta property="og:description" content="" />
<meta property="og:description" content="The Story of Celeste's Development" />
<meta
property="og:article:author"
content="Noclip - Video Game Documentaries"
Expand Down
Loading