Skip to content
Open
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
28 changes: 22 additions & 6 deletions bridges/SplCenterBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ class SplCenterBridge extends FeedExpander
const NAME = 'Southern Poverty Law Center Bridge';
const URI = 'https://www.splcenter.org';
const DESCRIPTION = 'Returns the newest posts from the Southern Poverty Law Center';
const MAINTAINER = 'VerifiedJoseph';
const MAINTAINER = 'tyler000000';
const PARAMETERS = [[
'content' => [
'name' => 'Content',
'type' => 'list',
'values' => [
'News' => 'news',
'Stories' => 'stories',
'Hatewatch' => 'hatewatch',
],
'defaultValue' => 'news',
'defaultValue' => 'stories',
]
]
];
Expand All @@ -23,8 +23,19 @@ class SplCenterBridge extends FeedExpander

public function collectData()
{
$url = $this->getURI() . '/rss.xml';
$this->collectExpandableDatas($url);
$dom = getSimpleHTMLDOM($this->getURI());
foreach ($dom->find('ul.wp-block-post-template li') as $li) {
$a = $li->find('h3 > a', 0);
if ($a && trim($a->plaintext) !== '') {
$this->items[] = [
'title' => $a->plaintext,
'uri' => $a->href,
'author' => $li->find('p.wp-block-splc-authors__name', 0)->plaintext,
'content' => $li->find('p.wp-block-post-excerpt__excerpt', 0)->plaintext,
'timestamp' => date("U",strtotime($li->find('time', 0)->getAttribute('datetime'))),
];
}
}
}

protected function parseItem(array $item)
Expand All @@ -44,7 +55,12 @@ protected function parseItem(array $item)
public function getURI()
{
if (!is_null($this->getInput('content'))) {
return self::URI . '/' . $this->getInput('content');
$content = $this->getInput('content');
if ($content == 'news') {
$content = 'stories';
}

return self::URI . '/resources/' . $content;
}

return parent::getURI();
Expand Down
Loading