Quick and dirty hack for id generation
This commit is contained in:
parent
9f699e46b5
commit
d92f201fdc
13
vendor/PicoFeed/Parser.php
vendored
13
vendor/PicoFeed/Parser.php
vendored
@ -159,4 +159,17 @@ abstract class Parser
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Hardcoded list of hostname/token to exclude from id generation
|
||||
public function isExcludedFromId($url)
|
||||
{
|
||||
$exclude_list = array('ap.org');
|
||||
|
||||
foreach ($exclude_list as $token) {
|
||||
if (strpos($url, $token) !== false) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
3
vendor/PicoFeed/Parsers/Atom.php
vendored
3
vendor/PicoFeed/Parsers/Atom.php
vendored
@ -26,7 +26,6 @@ class Atom extends \PicoFeed\Parser
|
||||
foreach ($xml->entry as $entry) {
|
||||
|
||||
if (isset($entry->author->name)) {
|
||||
|
||||
$author = (string) $entry->author->name;
|
||||
}
|
||||
|
||||
@ -34,7 +33,7 @@ class Atom extends \PicoFeed\Parser
|
||||
|
||||
$item = new \StdClass;
|
||||
$item->url = $this->getUrl($entry);
|
||||
$item->id = $this->generateId($id !== $item->url ? $id : $item->url, $this->url);
|
||||
$item->id = $this->generateId($id !== $item->url ? $id : $item->url, $this->isExcludedFromId($this->url) ? '' : $this->url);
|
||||
$item->title = $this->stripWhiteSpace((string) $entry->title);
|
||||
$item->updated = $this->parseDate((string) $entry->updated);
|
||||
$item->author = $author;
|
||||
|
2
vendor/PicoFeed/Parsers/Rss10.php
vendored
2
vendor/PicoFeed/Parsers/Rss10.php
vendored
@ -72,7 +72,7 @@ class Rss10 extends \PicoFeed\Parser
|
||||
|
||||
if (empty($item->title)) $item->title = $item->url;
|
||||
|
||||
$item->id = $this->generateId($item->url, $this->url);
|
||||
$item->id = $this->generateId($item->url, $this->isExcludedFromId($this->url) ? '' : $this->url);
|
||||
$item->content = $this->filterHtml($item->content, $item->url);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
4
vendor/PicoFeed/Parsers/Rss20.php
vendored
4
vendor/PicoFeed/Parsers/Rss20.php
vendored
@ -98,11 +98,11 @@ class Rss20 extends \PicoFeed\Parser
|
||||
if (isset($entry->guid) && isset($entry->guid['isPermaLink']) && (string) $entry->guid['isPermaLink'] != 'false') {
|
||||
|
||||
$id = (string) $entry->guid;
|
||||
$item->id = $this->generateId($id !== '' && $id !== $item->url ? $id : $item->url, $this->url);
|
||||
$item->id = $this->generateId($id !== '' && $id !== $item->url ? $id : $item->url, $this->isExcludedFromId($this->url) ? '' : $this->url);
|
||||
}
|
||||
else {
|
||||
|
||||
$item->id = $this->generateId($item->url, $this->url);
|
||||
$item->id = $this->generateId($item->url, $this->isExcludedFromId($this->url) ? '' : $this->url);
|
||||
}
|
||||
|
||||
if (empty($item->title)) $item->title = $item->url;
|
||||
|
Loading…
Reference in New Issue
Block a user