Browse Source

Small RSS 1.0 fixes

master
J. King 4 years ago
parent
commit
7f0c27648e
  1. 23
      lib/Parser/XML/Feed.php
  2. 5
      tests/cases/XML/feed-rss0.yaml
  3. 36
      tests/cases/XML/feed-rss1.yaml

23
lib/Parser/XML/Feed.php

@ -129,7 +129,6 @@ class Feed extends Construct implements \MensBeam\Lax\Parser\Feed {
public function getUrl(): ?Url {
return $this->fetchAtomRelation("self") // Atom 'self' relation URL
?? $this->fetchUrl("self::rss1:channel/@rdf:about") // RDF-about URL from RSS 0.90 or RSS 1.0
?? $this->fetchUrl("self::rss0:channel/@rdf:about") // RDF-about URL from RSS 0.90 or RSS 1.0
?? $this->fetchUrl("apple:new-feed-url"); // iTunes podcast canonical URL
}
@ -153,7 +152,7 @@ class Feed extends Construct implements \MensBeam\Lax\Parser\Feed {
?? $this->fetchText("dc:description", self::TEXT_PLAIN) // Dublin Core description
?? $this->fetchText("rss1:description", self::TEXT_LOOSE) // RSS 1.0 description
?? $this->fetchText("rss0:description", self::TEXT_LOOSE) // RSS 0.90 description
?? $this->fetchText("rss2:description", self::TEXT_LOOSE) // RSS 2.0 description
?? $this->fetchText("rss2:description", self::TEXT_LOOSE) // RSS 2.0 description
?? $this->fetchText("gplay:description", self::TEXT_PLAIN) // Google Play podcast description
?? $this->fetchText("apple:summary", self::TEXT_PLAIN) // iTunes podcast summary
?? $this->fetchText("apple:subtitle", self::TEXT_PLAIN); // iTunes podcast subtitle
@ -176,14 +175,18 @@ class Feed extends Construct implements \MensBeam\Lax\Parser\Feed {
}
public function getImage(): ?Url {
return $this->fetchUrl("atom:logo") // Atom logo URL
?? $this->fetchUrl("rss1:image/rss1:url") // RSS 1.0 channel image
?? $this->fetchUrl("/rdf:RDF/rss1:image/rss1:url") // RSS 1.0 root image
?? $this->fetchUrl("rss0:image/rss0:url") // RSS 0.90 channel image
?? $this->fetchUrl("/rdf:RDF/rss0:image/rss0:url") // RSS 0.90 root image
?? $this->fetchUrl("rss2:image/rss2:url") // RSS 2.0 channel image
?? $this->fetchUrl("gplay:image/@href") // Google Play podcast image
?? $this->fetchUrl("apple:image/@href"); // iTunes podcast image
return $this->fetchUrl("atom:logo") // Atom logo URL
?? $this->fetchUrl("rss1:image/@rdf:resource") // RSS 1.0 channel image RDF resource
?? $this->fetchUrl("rss1:image/rss1:url") // RSS 1.0 channel image
?? $this->fetchUrl("rss1:image/@rdf:about") // RSS 1.0 channel image about-URL
?? $this->fetchUrl("/rdf:RDF/rss1:image/@rdf:resource") // RSS 1.0 root image RDF resource
?? $this->fetchUrl("/rdf:RDF/rss1:image/rss1:url") // RSS 1.0 root image
?? $this->fetchUrl("/rdf:RDF/rss1:image/@rdf:about") // RSS 1.0 root image about-URL
?? $this->fetchUrl("rss0:image/rss0:url") // RSS 0.90 channel image
?? $this->fetchUrl("/rdf:RDF/rss0:image/rss0:url") // RSS 0.90 root image
?? $this->fetchUrl("rss2:image/rss2:url") // RSS 2.0 channel image
?? $this->fetchUrl("gplay:image/@href") // Google Play podcast image
?? $this->fetchUrl("apple:image/@href"); // iTunes podcast image
}
public function getCategories(): CategoryCollection {

5
tests/cases/XML/feed-rss0.yaml

@ -35,7 +35,7 @@ Feed language 1: # demonstrate walking up the DOM
version: '0.90'
lang: fr
Feed language 2: # demonstrate walking up the DOM
Feed language 2:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://channel.netscape.com/rdf/simple/0.9/" xml:lang=" ">
<channel xml:lang="fr"/>
@ -45,7 +45,7 @@ Feed language 2: # demonstrate walking up the DOM
version: '0.90'
lang: fr
Canonical URL: # this is not actually a feature of RSS 0.90, but is consistent with RSS 1.0's use of RDF
Canonical URL: # this is not a feature of RSS 0.90
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 rdf:about="http://example.com/"/>
@ -53,7 +53,6 @@ Canonical URL: # this is not actually a feature of RSS 0.90, but is consistent w
output:
format: rdf
version: '0.90'
url: 'http://example.com/'
Feed link:
input: >

36
tests/cases/XML/feed-rss1.yaml

@ -323,7 +323,7 @@ Feed root image:
version: '1.0'
image: 'http://example.com/'
Feed channel and root images:
Feed channel and root images: # Channel takes precedence
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<image>
@ -340,6 +340,40 @@ Feed channel and root images:
version: '1.0'
image: 'http://example.com/'
Feed channel RDF image resource:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel>
<image rdf:resource="http://example.com/"/>
</channel>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'
Feed root image about-URL:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel/>
<image rdf:about="http://example.com/"/>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'
Feed root RDF image resource:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
<channel/>
<image rdf:resource="http://example.com/"/>
</rdf:RDF>
output:
format: rdf
version: '1.0'
image: 'http://example.com/'
Categories by way of Dublin Core subjects:
input: >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">

Loading…
Cancel
Save