Update to improve RSS
This commit is contained in:
parent
73415a4a0d
commit
dfd0f12a15
@ -1,6 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="3600">
|
<meta http-equiv="refresh" content="3600">
|
||||||
|
<script src="FONTAWESOME_SCRIPT_URL" crossorigin="anonymous"></script>
|
||||||
<script type="module" src="./js/RSS.js"></script>
|
<script type="module" src="./js/RSS.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
18
src/RSS.ts
18
src/RSS.ts
@ -41,7 +41,6 @@ export class RSS extends LitElement {
|
|||||||
const result = await response.text();
|
const result = await response.text();
|
||||||
const rss = (new DOMParser()).parseFromString(result.trim(), 'text/xml');
|
const rss = (new DOMParser()).parseFromString(result.trim(), 'text/xml');
|
||||||
const channel = rss.getElementsByTagName('channel')[0] ?? null;
|
const channel = rss.getElementsByTagName('channel')[0] ?? null;
|
||||||
console.log(rss);
|
|
||||||
|
|
||||||
for (let channelI = 0; channelI < channel?.children?.length; channelI++) {
|
for (let channelI = 0; channelI < channel?.children?.length; channelI++) {
|
||||||
const channelChild = channel?.children?.item(channelI);
|
const channelChild = channel?.children?.item(channelI);
|
||||||
@ -98,12 +97,17 @@ export class RSS extends LitElement {
|
|||||||
override render() {
|
override render() {
|
||||||
return html`
|
return html`
|
||||||
<div class="gauge-body">
|
<div class="gauge-body">
|
||||||
<div class="gauge-label">RSS Feed for ${this.rssTitle}${this.rssLink ? html`<a href="${this.rssLink}">link</a>` : ''}</div>
|
${this.rssItems?.length > 0
|
||||||
${this.rssItems.map(rssItem => html`
|
? html`
|
||||||
<div>
|
<div class="gauge-label">RSS Feed for ${this.rssTitle}${this.rssLink ? html` <a href="${this.rssLink}"><i class="fa-solid fa-link"></i></a>` : ''}</div>
|
||||||
<div>${rssItem.link ? html`<a href="${rssItem.link}">${rssItem.title}</a>` : rssItem.title}</div>
|
${this.rssItems.map(rssItem => html`
|
||||||
</div>
|
<div>
|
||||||
`)}
|
<div>${rssItem.link ? html`<a href="${rssItem.link}">${rssItem.title}</a>` : rssItem.title}</div>
|
||||||
|
</div>
|
||||||
|
`)}
|
||||||
|
`
|
||||||
|
: html`<div class="gauge-label">There was no valid RSS feed found.</div>`
|
||||||
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
Reference in New Issue
Block a user