J. King
4 years ago
10 changed files with 168 additions and 106 deletions
@ -1,35 +0,0 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2018 J. King et al. |
|||
* See LICENSE and AUTHORS files for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace MensBeam\Lax\Parser\XML\Primitives; |
|||
|
|||
use MensBeam\Lax\Parser\XML\XPath; |
|||
|
|||
trait Entry { |
|||
/** Primitive to fetch a collection of authors associated with an Atom entry |
|||
* |
|||
* This differs from feeds in that an entry's <source> element (which possibly contains metadata for the source feed) is checked for authors if the entry itself has none |
|||
*/ |
|||
protected function getAuthorsAtom() { |
|||
return $this->fetchPeopleAtom("atom:author", "author") ?? $this->fetchPeopleAtom("atom:source[1]/atom:author", "author"); |
|||
} |
|||
|
|||
/** Primitive to fetch an RDF entry's canonical URL */ |
|||
protected function getUrlRss1() { |
|||
// XPath doesn't seem to like the query we'd need for this, so it must be done the hard way. |
|||
$node = $this->subject; |
|||
if ($node->localName === "item" && ($node->namespaceURI === XPath::NS['rss1'] || $node->namespaceURI == XPath::NS['rss0']) && $node->hasAttributeNS(XPath::NS['rdf'], "about")) { |
|||
return $this->resolveNodeUrl($node, "about", XPath::NS['rdf']); |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
/** Primitive to fetch the modification date of an RSS feed */ |
|||
protected function getDateModifiedRss2() { |
|||
return $this->fetchDate("pubDate"); |
|||
} |
|||
} |
@ -1,54 +0,0 @@ |
|||
Empty entry: |
|||
input: > |
|||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/"> |
|||
<channel> |
|||
<item/> |
|||
</channel> |
|||
<item/> |
|||
</rdf:RDF> |
|||
output: |
|||
format: rdf |
|||
version: '0.90' |
|||
|
|||
Entry link: |
|||
input: > |
|||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/"> |
|||
<channel> |
|||
<item> |
|||
<link>http://example.com/</link> |
|||
</item> |
|||
</channel> |
|||
<item> |
|||
<link>http://example.com/</link> |
|||
</item> |
|||
</rdf:RDF> |
|||
output: |
|||
format: rdf |
|||
version: '0.90' |
|||
entries: |
|||
- link: 'http://example.com/' |
|||
- link: 'http://example.com/' |
|||
|
|||
Entry title: |
|||
input: > |
|||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/"> |
|||
<item> |
|||
<title>Loose title</title> |
|||
</item> |
|||
</rdf:RDF> |
|||
output: |
|||
format: rdf |
|||
version: '0.90' |
|||
entries: |
|||
- title: {loose: 'Loose title'} |
|||
|
|||
Entry content: # RSS 0.90 didn't have entry descriptions |
|||
input: > |
|||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/"> |
|||
<item> |
|||
<description>Bogus description</description> |
|||
</item> |
|||
</rdf:RDF> |
|||
output: |
|||
format: rdf |
|||
version: '0.90' |
Loading…
Reference in new issue