Add gitea feed and test built package

This commit is contained in:
Fred Boniface 2023-11-06 21:18:22 +00:00
parent e35e438c7d
commit 6a960f775a
7 changed files with 151 additions and 88 deletions

138
package-lock.json generated
View File

@ -465,6 +465,15 @@
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
} }
}, },
"node_modules/@fastify/busboy": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
"dev": true,
"engines": {
"node": ">=14"
}
},
"node_modules/@humanwhocodes/config-array": { "node_modules/@humanwhocodes/config-array": {
"version": "0.11.10", "version": "0.11.10",
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz",
@ -558,6 +567,15 @@
"@jridgewell/sourcemap-codec": "^1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"node_modules/@mongodb-js/saslprep": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz",
"integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==",
"optional": true,
"dependencies": {
"sparse-bitfield": "^3.0.3"
}
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -817,9 +835,9 @@
} }
}, },
"node_modules/@sveltejs/kit": { "node_modules/@sveltejs/kit": {
"version": "1.22.6", "version": "1.27.3",
"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.22.6.tgz", "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.27.3.tgz",
"integrity": "sha512-SDKxI/QpsReCwIn5czjT53fKlPBybbmMk67d317gUqfeORroBAFN1Z6s/x0E1JYi+04i7kKllS+Sz9wVfmUkAQ==", "integrity": "sha512-pd7qwX6ww5noA0/FLk45B0aKUeOXWR+pfZsGTrv3dRmj3lTmnki9UTmTdWzHJGrje+BBkGUZHfgGrsSOQQBQpQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
@ -830,11 +848,12 @@
"esm-env": "^1.0.0", "esm-env": "^1.0.0",
"kleur": "^4.1.5", "kleur": "^4.1.5",
"magic-string": "^0.30.0", "magic-string": "^0.30.0",
"mime": "^3.0.0", "mrmime": "^1.0.1",
"sade": "^1.8.1", "sade": "^1.8.1",
"set-cookie-parser": "^2.6.0", "set-cookie-parser": "^2.6.0",
"sirv": "^2.0.2", "sirv": "^2.0.2",
"undici": "~5.23.0" "tiny-glob": "^0.2.9",
"undici": "~5.26.2"
}, },
"bin": { "bin": {
"svelte-kit": "svelte-kit.js" "svelte-kit": "svelte-kit.js"
@ -1417,9 +1436,9 @@
} }
}, },
"node_modules/bson": { "node_modules/bson": {
"version": "5.4.0", "version": "5.5.1",
"resolved": "https://registry.npmjs.org/bson/-/bson-5.4.0.tgz", "resolved": "https://registry.npmjs.org/bson/-/bson-5.5.1.tgz",
"integrity": "sha512-WRZ5SQI5GfUuKnPTNmAYPiKIof3ORXAF4IRU5UcgmivNIon01rWQlw5RUH954dpu8yGL8T59YShVddIPaU/gFA==", "integrity": "sha512-ix0EwukN2EpC0SRWIj/7B5+A6uQMQy6KMREI9qQqvgpkV2frH63T0UDVd1SYedL6dNCmDBYB3QtXi4ISk9YT+g==",
"engines": { "engines": {
"node": ">=14.20.1" "node": ">=14.20.1"
} }
@ -1445,18 +1464,6 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/busboy": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
"dev": true,
"dependencies": {
"streamsearch": "^1.1.0"
},
"engines": {
"node": ">=10.16.0"
}
},
"node_modules/cac": { "node_modules/cac": {
"version": "6.7.14", "version": "6.7.14",
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
@ -2247,9 +2254,9 @@
"dev": true "dev": true
}, },
"node_modules/get-func-name": { "node_modules/get-func-name": {
"version": "2.0.0", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz",
"integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": "*" "node": "*"
@ -2302,6 +2309,12 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/globalyzer": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/globalyzer/-/globalyzer-0.1.0.tgz",
"integrity": "sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==",
"dev": true
},
"node_modules/globby": { "node_modules/globby": {
"version": "11.1.0", "version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
@ -2322,6 +2335,12 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/globrex": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/globrex/-/globrex-0.1.2.tgz",
"integrity": "sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==",
"dev": true
},
"node_modules/graceful-fs": { "node_modules/graceful-fs": {
"version": "4.2.11", "version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
@ -2744,18 +2763,6 @@
"node": ">=8.6" "node": ">=8.6"
} }
}, },
"node_modules/mime": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz",
"integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==",
"dev": true,
"bin": {
"mime": "cli.js"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/min-indent": { "node_modules/min-indent": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",
@ -2811,11 +2818,11 @@
} }
}, },
"node_modules/mongodb": { "node_modules/mongodb": {
"version": "5.7.0", "version": "5.9.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.7.0.tgz", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.9.1.tgz",
"integrity": "sha512-zm82Bq33QbqtxDf58fLWBwTjARK3NSvKYjyz997KSy6hpat0prjeX/kxjbPVyZY60XYPDNETaHkHJI2UCzSLuw==", "integrity": "sha512-NBGA8AfJxGPeB12F73xXwozt8ZpeIPmCUeWRwl9xejozTXFes/3zaep9zhzs1B/nKKsw4P3I4iPfXl3K7s6g+Q==",
"dependencies": { "dependencies": {
"bson": "^5.4.0", "bson": "^5.5.0",
"mongodb-connection-string-url": "^2.6.0", "mongodb-connection-string-url": "^2.6.0",
"socks": "^2.7.1" "socks": "^2.7.1"
}, },
@ -2823,12 +2830,12 @@
"node": ">=14.20.1" "node": ">=14.20.1"
}, },
"optionalDependencies": { "optionalDependencies": {
"saslprep": "^1.0.3" "@mongodb-js/saslprep": "^1.1.0"
}, },
"peerDependencies": { "peerDependencies": {
"@aws-sdk/credential-providers": "^3.201.0", "@aws-sdk/credential-providers": "^3.188.0",
"@mongodb-js/zstd": "^1.1.0", "@mongodb-js/zstd": "^1.0.0",
"kerberos": "^2.0.1", "kerberos": "^1.0.0 || ^2.0.0",
"mongodb-client-encryption": ">=2.3.0 <3", "mongodb-client-encryption": ">=2.3.0 <3",
"snappy": "^7.2.2" "snappy": "^7.2.2"
}, },
@ -3103,9 +3110,9 @@
} }
}, },
"node_modules/postcss": { "node_modules/postcss": {
"version": "8.4.28", "version": "8.4.31",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.28.tgz", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz",
"integrity": "sha512-Z7V5j0cq8oEKyejIKfpD8b4eBy9cwW2JWPk0+fB1HOAMsfHbnAXLLS+PfVWlzMSLQaWttKDt607I0XHmpE67Vw==", "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@ -3469,18 +3476,6 @@
"postcss": "^8.3.11" "postcss": "^8.3.11"
} }
}, },
"node_modules/saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"dependencies": {
"sparse-bitfield": "^3.0.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/semver": { "node_modules/semver": {
"version": "7.5.4", "version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
@ -3618,15 +3613,6 @@
"integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==", "integrity": "sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==",
"dev": true "dev": true
}, },
"node_modules/streamsearch": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
"dev": true,
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/strip-ansi": { "node_modules/strip-ansi": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
@ -3889,6 +3875,16 @@
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
"dev": true "dev": true
}, },
"node_modules/tiny-glob": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz",
"integrity": "sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==",
"dev": true,
"dependencies": {
"globalyzer": "0.1.0",
"globrex": "^0.1.2"
}
},
"node_modules/tinybench": { "node_modules/tinybench": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.5.0.tgz",
@ -4025,12 +4021,12 @@
"dev": true "dev": true
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.23.0", "version": "5.26.5",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.23.0.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-5.26.5.tgz",
"integrity": "sha512-1D7w+fvRsqlQ9GscLBwcAJinqcZGHUKjbOmXdlE/v8BvEGXjeWAax+341q44EuTcHXXnfyKNbKRq4Lg7OzhMmg==", "integrity": "sha512-cSb4bPFd5qgR7qr2jYAi0hlX9n5YKK2ONKkLFkxl+v/9BvC0sOpZjBHDBSXc5lWAf5ty9oZdRXytBIHzgUcerw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"busboy": "^1.6.0" "@fastify/busboy": "^2.0.0"
}, },
"engines": { "engines": {
"node": ">=14.0" "node": ">=14.0"

View File

@ -1,9 +1,9 @@
export interface AtomFeed { export interface AtomFeed<T> {
title: string | null; title: string | null;
subtitle: string | null; subtitle: string | null;
updated: string | null; updated: string | null;
url: string | null; url: string | null;
content: PixelfedFeed[]; content: T[];
} }
export interface PixelfedFeed { export interface PixelfedFeed {
@ -13,8 +13,6 @@ export interface PixelfedFeed {
pixelfedUrl: string | null; pixelfedUrl: string | null;
} }
export interface GitFeed { export interface GiteaFeed {
title: string | null; title: string | null;
text: string | null;
url: string | null;
} }

View File

@ -0,0 +1,61 @@
<script lang="ts">
import EmptyCard from "$lib/card-collections/cards/EmptyCard.svelte";
import { parse } from "path";
import type { AtomFeed, GiteaFeed } from "./feedTypes";
export let giteaFeed: string | undefined;
async function loadFeed(feed: string) {
try {
const parser = new DOMParser();
const doc = parser.parseFromString(feed, "text/xml");
const feedTitle = doc.getElementsByTagName('title')[0].textContent;
const feedUpdated = doc.getElementsByTagName('pubDate')[0].textContent;
// Get link to profile
const feedLink = doc.getElementsByTagName('link')[0].textContent;
// Parse feed entries
const entries = doc.getElementsByTagName('item');
let entryArray: GiteaFeed[] = [];
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
const entryTitle = entry.getElementsByTagName('title')[0].textContent;
const feedItem: GiteaFeed = {
title: entryTitle
}
entryArray.push(feedItem);
}
const parsedFeed: AtomFeed<GiteaFeed> = {
title: feedTitle,
subtitle: "Gitea Feed",
updated: feedUpdated,
url: feedLink,
content: entryArray
}
return parsedFeed
} catch (err) {
console.error("Unable to load Pixelfed feed", err);
throw new Error("Unable to load Pixelfed feed");
}
}
</script>
{#await loadFeed(giteaFeed)}
<h5>Loading Gitea Feed</h5>
{:then feedData}
{#each feedData.content as feedItem}
<EmptyCard>
<p>{@html feedItem.title}</p>
</EmptyCard>
{/each}
{:catch}
<h5>Error connecting to Gitea</h5>
{/await}

View File

@ -1,12 +1,14 @@
<script lang="ts"> <script lang="ts">
import EmptyCard from "$lib/card-collections/cards/EmptyCard.svelte"; import EmptyCard from "$lib/card-collections/cards/EmptyCard.svelte";
import type { AtomFeed, PixelfedFeed } from "./feedTypes"; import type { AtomFeed, PixelfedFeed } from "./feedTypes";
export let pixelfedFeed: string; export let pixelfedFeed: string | undefined;
const atomUrl = "https://pixelfed.scot/users/fbface.atom"; async function loadFeed(feed: string | undefined) {
if (typeof feed == 'undefined') {
async function loadFeed(feed: string) { return 'undefined'
}
try { try {
const parser = new DOMParser(); const parser = new DOMParser();
const doc = parser.parseFromString(feed, "text/xml"); const doc = parser.parseFromString(feed, "text/xml");
@ -39,7 +41,7 @@ import type { AtomFeed, PixelfedFeed } from "./feedTypes";
entryArray.push(feedItem); entryArray.push(feedItem);
} }
const parsedFeed: AtomFeed = { const parsedFeed: AtomFeed<PixelfedFeed> = {
title: feedTitle, title: feedTitle,
subtitle: feedSubtitle, subtitle: feedSubtitle,
updated: feedUpdated, updated: feedUpdated,
@ -47,7 +49,6 @@ import type { AtomFeed, PixelfedFeed } from "./feedTypes";
content: entryArray, content: entryArray,
} }
console.log(JSON.stringify(parsedFeed))
return parsedFeed return parsedFeed
} catch (err) { } catch (err) {

View File

@ -2,9 +2,13 @@ import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async () => { export const load: PageServerLoad = async () => {
try { try {
const res = await fetch("https://pixelfed.scot/users/fbface.atom") const resPix = await fetch("https://pixelfed.scot/users/fbface.atom");
const xml = await res.text(); const xmlPix = await resPix.text();
return {xml: xml} const resGit = await fetch("https://git.fjla.uk/fred.boniface.rss");
const xmlGit = await resGit.text();
const data = {pixelfed: xmlPix, gitea: xmlGit}
console.log(JSON.stringify(data))
return data
} catch (err) { } catch (err) {
console.error("Error in load function", err) console.error("Error in load function", err)
} }

View File

@ -1,7 +1,9 @@
<script lang="ts"> <script lang="ts">
import Header from '$lib/header.svelte'; import Header from '$lib/header.svelte';
import Pixelfed from "$lib/feeds/pixelfed.svelte"; import Pixelfed from "$lib/feeds/pixelfed.svelte";
import type { PageData } from "../$types"; import Gitea from '$lib/feeds/gitea.svelte';
import type { PageData } from './$types';
export let data: PageData; export let data: PageData;
@ -28,13 +30,14 @@
<section id="meta-links"> <section id="meta-links">
<div id="pixelfed" class="col"> <div id="pixelfed" class="col">
<h1>Photos</h1> <h1>Photos</h1>
<Pixelfed pixelfedFeed={data.xml} /> <Pixelfed pixelfedFeed={data.pixelfed} />
</div> </div>
<div id="posts" class="col"> <div id="posts" class="col">
<p>I do lots of things, this is a central place you can check it all out.</p> <p>I do lots of things, this is a central place you can check it all out.</p>
</div> </div>
<div id="git" class="col"> <div id="git" class="col">
<h1>Git</h1> <h1>Git</h1>
<Gitea giteaFeed={data.gitea} />
</div> </div>
</section> </section>

View File