1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-16 05:24:08 +02:00

[CssSelectorBridge] Retrieve metadata for social media embeds (#3602, #3687) (#3706)

* [CssSelectorBridge] Metadata from social embed (#3602, #3687)

Implement the following metadata sources:
 - Facebook Open Graph
 - Twitter <meta> tags
 - Standard <meta> tags
 - JSON linked data (ld+json)

The following metadata is supported:
 - Canonical URL (may help removing garbage from URLs)
 - Article title
 - Truncated summary
 - Published/Updated timestamp
 - Enclosure/Thumbnail image
 - Author Name or Twitter handle

SitemapBridge will also automatically benefit from this commit.

* [php8backports] Add array_is_list()

Needed this function for ld+json implementation in CssSelectorBridge.

* [SitemapBridge] Add option to discard thumbnail

* [CssSelectorBridge] Fix linting issues
This commit is contained in:
ORelio
2023-09-24 23:07:43 +02:00
committed by GitHub
parent 09f3c1532a
commit e1b911fc1f
3 changed files with 290 additions and 15 deletions

View File

@@ -53,6 +53,11 @@ class SitemapBridge extends CssSelectorBridge
EOT,
'exampleValue' => 'https://example.com/sitemap.xml',
],
'discard_thumbnail' => [
'name' => '[Optional] Discard thumbnail set by site author',
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
'type' => 'checkbox',
],
'limit' => self::LIMIT
]
];
@@ -65,6 +70,7 @@ class SitemapBridge extends CssSelectorBridge
$content_cleanup = $this->getInput('content_cleanup');
$title_cleanup = $this->getInput('title_cleanup');
$site_map = $this->getInput('site_map');
$discard_thumbnail = $this->getInput('discard_thumbnail');
$limit = $this->getInput('limit');
$this->feedName = $this->getPageTitle($url, $title_cleanup);
@@ -77,7 +83,11 @@ class SitemapBridge extends CssSelectorBridge
}
foreach ($links as $link) {
$this->items[] = $this->expandEntryWithSelector($link, $content_selector, $content_cleanup, $title_cleanup);
$item = $this->expandEntryWithSelector($link, $content_selector, $content_cleanup, $title_cleanup);
if ($discard_thumbnail && isset($item['enclosures'])) {
unset($item['enclosures']);
}
$this->items[] = $item;
}
}