From 51d27300be280df5d4c91252b3117f2ae7a63c4c Mon Sep 17 00:00:00 2001 From: Antoine Turmel Date: Fri, 8 Apr 2022 21:13:05 +0200 Subject: [PATCH 1/3] [FeedMergeBridge] Add new bridge (#1385) * [FeedMergeBridge] Add new bridge Here is a bridge that merges two or more feeds into one. Co-authored-by: Bocki Co-authored-by: Dag --- bridges/FeedMergeBridge.php | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 bridges/FeedMergeBridge.php diff --git a/bridges/FeedMergeBridge.php b/bridges/FeedMergeBridge.php new file mode 100644 index 00000000..ff13ac9e --- /dev/null +++ b/bridges/FeedMergeBridge.php @@ -0,0 +1,54 @@ + [ + 'name' => 'Feed name', + 'type' => 'text', + 'exampleValue' => 'rss-bridge/FeedMerger', + ], + 'feed_1' => [ + 'name' => 'Feed url', + 'type' => 'text', + 'required' => true, + 'exampleValue' => 'https://lorem-rss.herokuapp.com/feed?unit=day' + ], + 'feed_2' => ['name' => 'Feed url', 'type' => 'text'], + 'feed_3' => ['name' => 'Feed url', 'type' => 'text'], + 'feed_4' => ['name' => 'Feed url', 'type' => 'text'], + 'feed_5' => ['name' => 'Feed url', 'type' => 'text'], + ] + ]; + + public function collectData() { + $limit = 10; + $feeds = [ + $this->getInput('feed_1'), + $this->getInput('feed_2'), + $this->getInput('feed_3'), + $this->getInput('feed_4'), + $this->getInput('feed_5'), + ]; + // Remove empty values + $feeds = array_filter($feeds); + foreach ($feeds as $feed) { + $this->collectExpandableDatas($feed, $limit); + } + } + + public function getIcon() { + return 'https://cdn.jsdelivr.net/npm/famfamfam-silk@1.0.0/dist/png/folder_feed.png'; + } + + public function getName() { + return $this->getInput('feed_name') ?: 'rss-bridge/FeedMerger'; + } +} From 8c18c02c65042add22ef783e0f52a0483f3ffcb3 Mon Sep 17 00:00:00 2001 From: Corentin Garcia Date: Fri, 8 Apr 2022 21:21:13 +0200 Subject: [PATCH 2/3] [GatesNotesBridge] Add feedaxpander bridge for Bill Gate's blog (fix issue #2386) (#2611) --- bridges/GatesNotesBridge.php | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 bridges/GatesNotesBridge.php diff --git a/bridges/GatesNotesBridge.php b/bridges/GatesNotesBridge.php new file mode 100644 index 00000000..bf456d26 --- /dev/null +++ b/bridges/GatesNotesBridge.php @@ -0,0 +1,54 @@ +Could not request ' . $this->getName() . ': ' . $item['uri'] . '

'; + return $item; + } + $article_html = defaultLinkTo($article_html, $this->getURI()); + + $top_description = '

' . $article_html->find('div.article_top_description', 0)->innertext . '

'; + $hero_image = 'getAttribute('data-src') . '>'; + + $article_body = $article_html->find('div.TGN_Article_ReadTimeSection', 0); + // Convert iframe of Youtube videos to link + foreach($article_body->find('iframe') as $found) { + + $iframeUrl = $found->getAttribute('src'); + + if ($iframeUrl) { + $text = 'Embedded Youtube video, click here to watch on Youtube.com'; + $found->outertext = '

' . $text . '

'; + } + } + // Remove CSS ressources + foreach($article_body->find('link') as $found) { + + $linkedRessourceUrl = $found->getAttribute('href'); + + if (str_ends_with($linkedRessourceUrl, '.css')) { + $found->outertext = ''; + } + } + $article_body = sanitize($article_body->innertext); + + $item['content'] = $top_description . $hero_image . $article_body; + + return $item; + } + + public function collectData(){ + $feed = static::URI . '/rss'; + $this->collectExpandableDatas($feed); + } +} From cce11964a4e748d21dd1e3d7ca807cd84463b3b4 Mon Sep 17 00:00:00 2001 From: dag Date: Fri, 8 Apr 2022 21:22:13 +0200 Subject: [PATCH 3/3] feat: add a timeout option for http client (#2600) --- config.default.ini.php | 1 + docs/03_For_Hosts/08_Custom_Configuration.md | 18 ++++++++++++++++++ lib/contents.php | 1 + 3 files changed, 20 insertions(+) diff --git a/config.default.ini.php b/config.default.ini.php index 147a0ca4..c1627aac 100644 --- a/config.default.ini.php +++ b/config.default.ini.php @@ -13,6 +13,7 @@ timezone = "UTC" [http] +timeout = 60 useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" [cache] diff --git a/docs/03_For_Hosts/08_Custom_Configuration.md b/docs/03_For_Hosts/08_Custom_Configuration.md index d8583a06..afc5eb2e 100644 --- a/docs/03_For_Hosts/08_Custom_Configuration.md +++ b/docs/03_For_Hosts/08_Custom_Configuration.md @@ -17,6 +17,7 @@ __Notice__: If a parameter is not specified in your `config.ini.php` RSS-Bridge The configuration file is split into sections: * [system](#system) +* [http client](#http client) * [cache](#cache) * [proxy](#proxy) * [authentication](#authentication) @@ -25,6 +26,8 @@ The configuration file is split into sections: _System_: This section specifies system specific parameters +_Http client_: This section has http client options + _Cache_: This section is all about the caching behavior of RSS-Bridge _Proxy_: This section can be used to specify a proxy server for RSS-Bridge to utilize for fetching contents @@ -98,6 +101,21 @@ Allow users to disable proxy usage for specific requests. `false` = disabled (default) +## Http client + +This section provides the following parameters: + +- timeout +- useragent + +### timeout + +Default network timeout. + +### useragent + +Default user agent. + ## Authentication This section provides following parameters: diff --git a/lib/contents.php b/lib/contents.php index a5591c33..afbf7168 100644 --- a/lib/contents.php +++ b/lib/contents.php @@ -169,6 +169,7 @@ function getContents($url, $header = array(), $opts = array(), $returnHeader = f } curl_setopt($ch, CURLOPT_USERAGENT, Configuration::getConfig('http', 'useragent')); + curl_setopt($ch, CURLOPT_TIMEOUT, Configuration::getConfig('http', 'timeout')); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);