mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[PlantUMLReleasesBridge] Bridge optimizations (#2459)
This commit is contained in:
parent
3187592dba
commit
105fbe9dda
@ -5,62 +5,41 @@
|
|||||||
* @author nicolas-delsaux
|
* @author nicolas-delsaux
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PlantUMLReleasesBridge extends BridgeAbstract
|
class PlantUMLReleasesBridge extends BridgeAbstract {
|
||||||
{
|
|
||||||
const MAINTAINER = 'Riduidel';
|
const MAINTAINER = 'Riduidel';
|
||||||
|
|
||||||
const NAME = 'PlantUML Releases';
|
const NAME = 'PlantUML Releases';
|
||||||
|
|
||||||
const AUTHOR = 'PlantUML team';
|
const AUTHOR = 'PlantUML team';
|
||||||
|
const URI = 'https://plantuml.com/changes';
|
||||||
// URI is no more valid, since we can address the whole gq galaxy
|
|
||||||
const URI = 'http://plantuml.com/fr/changes';
|
|
||||||
|
|
||||||
const CACHE_TIMEOUT = 7200; // 2h
|
const CACHE_TIMEOUT = 7200; // 2h
|
||||||
const DESCRIPTION = 'PlantUML releases bridge, showing for each release the changelog';
|
const DESCRIPTION = 'PlantUML releases bridge, showing for each release the changelog';
|
||||||
|
const ITEM_LIMIT = 10;
|
||||||
|
|
||||||
const DEFAULT_DOMAIN = 'plantuml.com';
|
public function getURI() {
|
||||||
|
|
||||||
const PARAMETERS = array( array(
|
|
||||||
));
|
|
||||||
|
|
||||||
const REPLACED_ATTRIBUTES = array(
|
|
||||||
'href' => 'href',
|
|
||||||
'src' => 'src',
|
|
||||||
'data-original' => 'src'
|
|
||||||
);
|
|
||||||
|
|
||||||
private function getDomain() {
|
|
||||||
$domain = $this->getInput('domain');
|
|
||||||
if (empty($domain))
|
|
||||||
$domain = self::DEFAULT_DOMAIN;
|
|
||||||
if (strpos($domain, '://') === false)
|
|
||||||
$domain = 'https://' . $domain;
|
|
||||||
return $domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getURI()
|
|
||||||
{
|
|
||||||
return self::URI;
|
return self::URI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData()
|
public function collectData() {
|
||||||
{
|
$html = defaultLinkTo(getSimpleHTMLDOM($this->getURI()), self::URI);
|
||||||
$html = getSimpleHTMLDOM($this->getURI());
|
|
||||||
|
|
||||||
// Since GQ don't want simple class scrapping, let's do it the hard way and ... discover content !
|
$num_items = 0;
|
||||||
$main = $html->find('div[id=root]', 0);
|
$main = $html->find('div[id=root]', 0);
|
||||||
foreach ($main->find('h2') as $release) {
|
foreach ($main->find('h2') as $release) {
|
||||||
|
// Limit to $ITEM_LIMIT number of results
|
||||||
|
if ($num_items++ >= self::ITEM_LIMIT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['author'] = self::AUTHOR;
|
$item['author'] = self::AUTHOR;
|
||||||
$release_text = $release->innertext;
|
$release_text = $release->innertext;
|
||||||
if (preg_match('/(.+) \((.*)\)/', $release_text, $matches)) {
|
if (preg_match('/(.+) \((.*)\)/', $release_text, $matches)) {
|
||||||
$item['title'] = $matches[1];
|
$item['title'] = $matches[1];
|
||||||
// And now, build the date from the date text
|
$item['timestamp'] = preg_replace('/(\d+) (\w{3})\w*, (\d+)/', '${1} ${2} ${3}', $matches[2]);
|
||||||
$item['timestamp'] = strtotime($matches[2]);
|
} else {
|
||||||
|
$item['title'] = $release_text;
|
||||||
}
|
}
|
||||||
$item['uri'] = $this->getURI();
|
$item['uri'] = $this->getURI();
|
||||||
$item['content'] = $release->next_sibling ();
|
$item['content'] = $release->next_sibling();
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user