mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-16 21:58:21 +01:00
* Implement <time> metadata tag as timestamp source * Add setting to include thumbnail as article header
This commit is contained in:
parent
12a90e2074
commit
bb36eb9eb8
@ -56,6 +56,11 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
],
|
],
|
||||||
|
'thumbnail_as_header' => [
|
||||||
|
'name' => '[Optional] Insert thumbnail as article header',
|
||||||
|
'title' => 'Insert article main image on top of article contents.',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
],
|
||||||
'limit' => self::LIMIT
|
'limit' => self::LIMIT
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -89,6 +94,7 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
$content_cleanup = $this->getInput('content_cleanup');
|
$content_cleanup = $this->getInput('content_cleanup');
|
||||||
$title_cleanup = $this->getInput('title_cleanup');
|
$title_cleanup = $this->getInput('title_cleanup');
|
||||||
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
||||||
|
$thumbnail_as_header = $this->getInput('thumbnail_as_header');
|
||||||
$limit = $this->getInput('limit') ?? 10;
|
$limit = $this->getInput('limit') ?? 10;
|
||||||
|
|
||||||
$html = defaultLinkTo(getSimpleHTMLDOM($this->homepageUrl), $this->homepageUrl);
|
$html = defaultLinkTo(getSimpleHTMLDOM($this->homepageUrl), $this->homepageUrl);
|
||||||
@ -109,6 +115,9 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
if ($discard_thumbnail && isset($item['enclosures'])) {
|
if ($discard_thumbnail && isset($item['enclosures'])) {
|
||||||
unset($item['enclosures']);
|
unset($item['enclosures']);
|
||||||
}
|
}
|
||||||
|
if ($thumbnail_as_header && isset($item['enclosures'][0])) {
|
||||||
|
$item['content'] = '<p><img src="' . $item['enclosures'][0] . '" /></p>' . $item['content'];
|
||||||
|
}
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,6 +320,7 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
// Facebook Open Graph (og:KEY) - https://developers.facebook.com/docs/sharing/webmasters
|
// Facebook Open Graph (og:KEY) - https://developers.facebook.com/docs/sharing/webmasters
|
||||||
// Twitter (twitter:KEY) - https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started
|
// Twitter (twitter:KEY) - https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started
|
||||||
// Standard meta tags - https://www.w3schools.com/tags/tag_meta.asp
|
// Standard meta tags - https://www.w3schools.com/tags/tag_meta.asp
|
||||||
|
// Standard time tag - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time
|
||||||
|
|
||||||
// Each Entry field mapping defines a list of possible <meta> tags names that contains the expected value
|
// Each Entry field mapping defines a list of possible <meta> tags names that contains the expected value
|
||||||
static $meta_mappings = [
|
static $meta_mappings = [
|
||||||
@ -323,16 +333,16 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
'uri' => [
|
'uri' => [
|
||||||
'og:url',
|
'og:url',
|
||||||
'twitter:url',
|
'twitter:url',
|
||||||
'canonical'
|
'canonical',
|
||||||
],
|
],
|
||||||
'title' => [
|
'title' => [
|
||||||
'og:title',
|
'og:title',
|
||||||
'twitter:title'
|
'twitter:title',
|
||||||
],
|
],
|
||||||
'content' => [
|
'content' => [
|
||||||
'og:description',
|
'og:description',
|
||||||
'twitter:description',
|
'twitter:description',
|
||||||
'description'
|
'description',
|
||||||
],
|
],
|
||||||
'timestamp' => [
|
'timestamp' => [
|
||||||
'article:published_time',
|
'article:published_time',
|
||||||
@ -342,7 +352,8 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
'article:modified_time',
|
'article:modified_time',
|
||||||
'og:article:modified_time',
|
'og:article:modified_time',
|
||||||
'lastModified',
|
'lastModified',
|
||||||
'lastmodified'
|
'lastmodified',
|
||||||
|
'time',
|
||||||
],
|
],
|
||||||
'enclosures' => [
|
'enclosures' => [
|
||||||
'og:image:secure_url',
|
'og:image:secure_url',
|
||||||
@ -350,7 +361,7 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
'og:image',
|
'og:image',
|
||||||
'twitter:image',
|
'twitter:image',
|
||||||
'thumbnailImg',
|
'thumbnailImg',
|
||||||
'thumbnailimg'
|
'thumbnailimg',
|
||||||
],
|
],
|
||||||
'author' => [
|
'author' => [
|
||||||
'article:author',
|
'article:author',
|
||||||
@ -375,6 +386,8 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
$element = null;
|
$element = null;
|
||||||
if ($field === 'canonical') {
|
if ($field === 'canonical') {
|
||||||
$element = $entry_html->find('link[rel=canonical]');
|
$element = $entry_html->find('link[rel=canonical]');
|
||||||
|
} else if ($field === 'time') {
|
||||||
|
$element = $entry_html->find('time[datetime]');
|
||||||
} else {
|
} else {
|
||||||
$element = $entry_html->find("meta[property=$field], meta[name=$field]");
|
$element = $entry_html->find("meta[property=$field], meta[name=$field]");
|
||||||
}
|
}
|
||||||
@ -384,6 +397,8 @@ class CssSelectorBridge extends BridgeAbstract
|
|||||||
$field_value = '';
|
$field_value = '';
|
||||||
if ($field === 'canonical') {
|
if ($field === 'canonical') {
|
||||||
$field_value = $element->href;
|
$field_value = $element->href;
|
||||||
|
} else if ($field === 'time') {
|
||||||
|
$field_value = $element->datetime;
|
||||||
} else {
|
} else {
|
||||||
$field_value = $element->content;
|
$field_value = $element->content;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,11 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
|||||||
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
],
|
],
|
||||||
|
'thumbnail_as_header' => [
|
||||||
|
'name' => '[Optional] Insert thumbnail as article header',
|
||||||
|
'title' => 'Insert article main image on top of article contents.',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
],
|
||||||
'limit' => self::LIMIT
|
'limit' => self::LIMIT
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -48,6 +53,7 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
|||||||
$content_cleanup = $this->getInput('content_cleanup');
|
$content_cleanup = $this->getInput('content_cleanup');
|
||||||
$dont_expand_metadata = $this->getInput('dont_expand_metadata');
|
$dont_expand_metadata = $this->getInput('dont_expand_metadata');
|
||||||
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
||||||
|
$thumbnail_as_header = $this->getInput('thumbnail_as_header');
|
||||||
$limit = $this->getInput('limit');
|
$limit = $this->getInput('limit');
|
||||||
|
|
||||||
$feedParser = new FeedParser();
|
$feedParser = new FeedParser();
|
||||||
@ -100,6 +106,13 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge
|
|||||||
unset($item_expanded['enclosures']);
|
unset($item_expanded['enclosures']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($thumbnail_as_header && isset($item_expanded['enclosures'][0])) {
|
||||||
|
$item_expanded['content'] = '<p><img src="'
|
||||||
|
. $item_expanded['enclosures'][0]
|
||||||
|
. '" /></p>'
|
||||||
|
. $item_expanded['content'];
|
||||||
|
}
|
||||||
|
|
||||||
$this->items[] = $item_expanded;
|
$this->items[] = $item_expanded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,11 @@ class SitemapBridge extends CssSelectorBridge
|
|||||||
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
],
|
],
|
||||||
|
'thumbnail_as_header' => [
|
||||||
|
'name' => '[Optional] Insert thumbnail as article header',
|
||||||
|
'title' => 'Insert article main image on top of article contents.',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
],
|
||||||
'limit' => self::LIMIT
|
'limit' => self::LIMIT
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
@ -71,6 +76,7 @@ class SitemapBridge extends CssSelectorBridge
|
|||||||
$title_cleanup = $this->getInput('title_cleanup');
|
$title_cleanup = $this->getInput('title_cleanup');
|
||||||
$site_map = $this->getInput('site_map');
|
$site_map = $this->getInput('site_map');
|
||||||
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
$discard_thumbnail = $this->getInput('discard_thumbnail');
|
||||||
|
$thumbnail_as_header = $this->getInput('thumbnail_as_header');
|
||||||
$limit = $this->getInput('limit');
|
$limit = $this->getInput('limit');
|
||||||
|
|
||||||
$this->feedName = $this->titleCleanup($this->getPageTitle($this->homepageUrl), $title_cleanup);
|
$this->feedName = $this->titleCleanup($this->getPageTitle($this->homepageUrl), $title_cleanup);
|
||||||
@ -87,6 +93,9 @@ class SitemapBridge extends CssSelectorBridge
|
|||||||
if ($discard_thumbnail && isset($item['enclosures'])) {
|
if ($discard_thumbnail && isset($item['enclosures'])) {
|
||||||
unset($item['enclosures']);
|
unset($item['enclosures']);
|
||||||
}
|
}
|
||||||
|
if ($thumbnail_as_header && isset($item['enclosures'])) {
|
||||||
|
$item['content'] = '<p><img src="' . $item['enclosures'][0] . '" /></p>' . $item['content'];
|
||||||
|
}
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user