Fix broken OPML generators in subdirectories
This commit is contained in:
parent
c6c970ff05
commit
394451ffbc
|
@ -2,22 +2,22 @@ xquery version "3.0" encoding "utf-8";
|
|||
import module namespace rsrsss = "https://envs.net/~lucidiot/rsrsss/rsrsss-functions" at "../../functions.xqy";
|
||||
|
||||
rsrsss:make-opml(
|
||||
"National Data Buoy Center RSS feeds",
|
||||
"National Data Buoy Center RSS feeds",
|
||||
(
|
||||
<outline
|
||||
type="rss"
|
||||
version="RSS"
|
||||
text="All observations"
|
||||
xmlUrl="https://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=0N&lon=0E&radius=11000"
|
||||
language="en-us"
|
||||
/>
|
||||
{
|
||||
doc("https://www.ndbc.noaa.gov/data/latest_obs/")//a[ends-with(@href, ".rss")]
|
||||
! <outline
|
||||
type="rss"
|
||||
version="RSS"
|
||||
text="{upper-case(substring-before(text(), '.rss'))}"
|
||||
xmlUrl="{resolve-uri(@href)}"
|
||||
language="en-us"
|
||||
/>
|
||||
}
|
||||
/>,
|
||||
doc("https://www.ndbc.noaa.gov/data/latest_obs/")//a[ends-with(@href, ".rss")]
|
||||
! <outline
|
||||
type="rss"
|
||||
version="RSS"
|
||||
text="{upper-case(substring-before(text(), '.rss'))}"
|
||||
xmlUrl="{resolve-uri(@href)}"
|
||||
language="en-us"
|
||||
/>
|
||||
)
|
||||
)
|
||||
|
|
|
@ -6,23 +6,21 @@ rsrsss:make-opml(
|
|||
(:
|
||||
We use unparsed-text(url, encoding) instead of doc(url)
|
||||
because xidel does not support changing the encoding dynamically
|
||||
depending on the HTML content, so it would always use UTF-8
|
||||
depending on the HTML content, so it would always use UTF-8.
|
||||
|
||||
Each feed is listed as a link with an RSS icon inside it,
|
||||
followed by a text node representing the feed name,
|
||||
followed by another link with the URL as its text.
|
||||
Start by picking the link with the image in it…
|
||||
:)
|
||||
x:parse-html(unparsed-text("https://www.nhc.noaa.gov/aboutrss.shtml", "iso-8859-1"))/
|
||||
(:
|
||||
Each feed is listed as a link with an RSS icon inside it,
|
||||
followed by a text node representing the feed name,
|
||||
followed by another link with the URL as its text.
|
||||
Start by picking the link with the image in it…
|
||||
:)
|
||||
for $feed in //a[ends-with(@href, ".xml")][./img]
|
||||
(: Find the text node that follows the image to get the feed name :)
|
||||
let $text := substring-before($feed/following-sibling::text()[1], ":")
|
||||
return <outline
|
||||
type="rss"
|
||||
text="{$text}"
|
||||
xmlUrl="{resolve-uri($feed/@href, 'https://www.nhc.noaa.gov/aboutrss.shtml')}"
|
||||
language="{if (some $word in ('Español', 'Atlantico', 'Cartera') satisfies contains($text, $word)) then 'es' else 'en-us'}"
|
||||
/>
|
||||
(: The only way to determine the feed's language without fetching the feeds themselves is to look for Spanish keywords. :)
|
||||
for $feed in x:parse-html(unparsed-text("https://www.nhc.noaa.gov/aboutrss.shtml", "iso-8859-1"))//a[ends-with(@href, ".xml")][./img]
|
||||
(: Find the text node that follows the image to get the feed name :)
|
||||
let $text := substring-before($feed/following-sibling::text()[1], ":")
|
||||
return <outline
|
||||
type="rss"
|
||||
text="{$text}"
|
||||
xmlUrl="{resolve-uri($feed/@href, 'https://www.nhc.noaa.gov/aboutrss.shtml')}"
|
||||
language="{if (some $word in ('Español', 'Atlantico', 'Cartera') satisfies contains($text, $word)) then 'es' else 'en-us'}"
|
||||
/>
|
||||
(: The only way to determine the feed's language without fetching the feeds themselves is to look for Spanish keywords. :)
|
||||
)
|
||||
|
|
|
@ -2,41 +2,43 @@ import module namespace rsrsss = "https://envs.net/~lucidiot/rsrsss/rsrsss-funct
|
|||
|
||||
rsrsss:make-opml(
|
||||
"USGS Earthquake Hazards Program feeds",
|
||||
<outline text="Atom">
|
||||
{
|
||||
doc('https://earthquake.usgs.gov/earthquakes/feed/v1.0/atom.php')//div[h2[text() = 'Feeds']]/h3
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::ul//a
|
||||
! <outline
|
||||
type="rss"
|
||||
version="ATOM"
|
||||
text="{normalize-space(text())}"
|
||||
xmlUrl="{resolve-uri(@href)}"
|
||||
language="en-us"
|
||||
/>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>
|
||||
<outline text="KML">
|
||||
{
|
||||
doc('https://earthquake.usgs.gov/earthquakes/feed/v1.0/kml.php')//div[h2[text() = 'Automatic Feeds']]/h2
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::h3
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::ul//a
|
||||
! <outline
|
||||
type="link"
|
||||
text="{normalize-space(text())}"
|
||||
url="{resolve-uri(@href)}"
|
||||
/>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>
|
||||
(
|
||||
<outline text="Atom">
|
||||
{
|
||||
doc('https://earthquake.usgs.gov/earthquakes/feed/v1.0/atom.php')//div[h2[text() = 'Feeds']]/h3
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::ul//a
|
||||
! <outline
|
||||
type="rss"
|
||||
version="ATOM"
|
||||
text="{normalize-space(text())}"
|
||||
xmlUrl="{resolve-uri(@href)}"
|
||||
language="en-us"
|
||||
/>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>,
|
||||
<outline text="KML">
|
||||
{
|
||||
doc('https://earthquake.usgs.gov/earthquakes/feed/v1.0/kml.php')//div[h2[text() = 'Automatic Feeds']]/h2
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::h3
|
||||
! <outline text="{normalize-space(text())}">
|
||||
{
|
||||
./following-sibling::ul//a
|
||||
! <outline
|
||||
type="link"
|
||||
text="{normalize-space(text())}"
|
||||
url="{resolve-uri(@href)}"
|
||||
/>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>
|
||||
}
|
||||
</outline>
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue