From bb41208e1575d2f6c128e2f15aec00024be3ed1e Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 4 Nov 2023 00:53:29 +0000 Subject: [PATCH] Remove old components --- src/lib/GitLink.svelte | 14 -- src/lib/card-collections/LatestPosts.svelte | 30 ----- src/lib/card-collections/Projects.svelte | 32 ----- .../card-collections/cards/PostCard.svelte | 36 ----- .../card-collections/cards/ProjectCard.svelte | 21 --- .../card-collections/cards/TagsCard.svelte | 47 ------- src/lib/content-boxes/FullWidthContent.svelte | 20 --- src/lib/database/mongo.server.ts | 12 -- src/lib/feeds/feedTypes.ts | 6 + src/lib/highlights/emphasis.svelte | 14 -- src/lib/posts/PostTag.svelte | 25 ---- src/lib/posts/PostsSummary.svelte | 40 ------ src/lib/posts/types.ts | 20 --- src/lib/projects/ProjectSummary.svelte | 30 ----- src/lib/projects/types.ts | 8 -- src/routes/+page.svelte | 14 +- src/routes/posts/+page.svelte | 11 -- src/routes/posts/[slug]/+page.server.ts | 55 -------- src/routes/posts/[slug]/+page.svelte | 124 ------------------ src/routes/posts/latest/+server.ts | 15 --- src/routes/posts/markdown/map-dots.md | 19 --- src/routes/posts/markdown/notFound.md | 9 -- src/routes/posts/markdown/owlboard.md | 25 ---- src/routes/posts/tag/+page.svelte | 0 src/routes/posts/tag/[tag]/+page.server.ts | 16 --- src/routes/posts/tag/[tag]/+page.svelte | 18 --- src/routes/posts/tag/all/+server.ts | 12 -- src/routes/projects/+page.svelte | 22 ---- src/routes/projects/all/+server.ts | 12 -- src/routes/testing/+page.server.ts | 11 -- src/routes/testing/+page.svelte | 8 -- 31 files changed, 9 insertions(+), 717 deletions(-) delete mode 100644 src/lib/GitLink.svelte delete mode 100644 src/lib/card-collections/LatestPosts.svelte delete mode 100644 src/lib/card-collections/Projects.svelte delete mode 100644 src/lib/card-collections/cards/PostCard.svelte delete mode 100644 src/lib/card-collections/cards/ProjectCard.svelte delete mode 100644 src/lib/card-collections/cards/TagsCard.svelte delete mode 100644 src/lib/content-boxes/FullWidthContent.svelte delete mode 100644 src/lib/database/mongo.server.ts delete mode 100644 src/lib/highlights/emphasis.svelte delete mode 100644 src/lib/posts/PostTag.svelte delete mode 100644 src/lib/posts/PostsSummary.svelte delete mode 100644 src/lib/posts/types.ts delete mode 100644 src/lib/projects/ProjectSummary.svelte delete mode 100644 src/lib/projects/types.ts delete mode 100644 src/routes/posts/+page.svelte delete mode 100644 src/routes/posts/[slug]/+page.server.ts delete mode 100644 src/routes/posts/[slug]/+page.svelte delete mode 100644 src/routes/posts/latest/+server.ts delete mode 100644 src/routes/posts/markdown/map-dots.md delete mode 100644 src/routes/posts/markdown/notFound.md delete mode 100644 src/routes/posts/markdown/owlboard.md delete mode 100644 src/routes/posts/tag/+page.svelte delete mode 100644 src/routes/posts/tag/[tag]/+page.server.ts delete mode 100644 src/routes/posts/tag/[tag]/+page.svelte delete mode 100644 src/routes/posts/tag/all/+server.ts delete mode 100644 src/routes/projects/+page.svelte delete mode 100644 src/routes/projects/all/+server.ts delete mode 100644 src/routes/testing/+page.server.ts delete mode 100644 src/routes/testing/+page.svelte diff --git a/src/lib/GitLink.svelte b/src/lib/GitLink.svelte deleted file mode 100644 index 748ad1f..0000000 --- a/src/lib/GitLink.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - - Git Repository -

- - diff --git a/src/lib/card-collections/LatestPosts.svelte b/src/lib/card-collections/LatestPosts.svelte deleted file mode 100644 index 8693662..0000000 --- a/src/lib/card-collections/LatestPosts.svelte +++ /dev/null @@ -1,30 +0,0 @@ - - -{#await getPosts(length)} -

Awaiting posts

-{:then posts} - {#each posts as post} - - {/each} -{:catch} -

Unable to fetch posts

-{/await} - - diff --git a/src/lib/card-collections/Projects.svelte b/src/lib/card-collections/Projects.svelte deleted file mode 100644 index a22e06d..0000000 --- a/src/lib/card-collections/Projects.svelte +++ /dev/null @@ -1,32 +0,0 @@ - - -{#await getProjects()} - -

Fetching Projects...

-
-{:then projects} - {#each projects as project} - - {/each} -{:catch} - -

Unable to fetch projects

-
-{/await} - - diff --git a/src/lib/card-collections/cards/PostCard.svelte b/src/lib/card-collections/cards/PostCard.svelte deleted file mode 100644 index 8d59188..0000000 --- a/src/lib/card-collections/cards/PostCard.svelte +++ /dev/null @@ -1,36 +0,0 @@ - - - - -

{post.title}

- -
-

{post.summary}

-
-
- {#each post.tags as tag} - - {/each} -
-
-
- - diff --git a/src/lib/card-collections/cards/ProjectCard.svelte b/src/lib/card-collections/cards/ProjectCard.svelte deleted file mode 100644 index a0b6529..0000000 --- a/src/lib/card-collections/cards/ProjectCard.svelte +++ /dev/null @@ -1,21 +0,0 @@ - - - - -

{project.name}

- -

{project.description}

-
-
- - diff --git a/src/lib/card-collections/cards/TagsCard.svelte b/src/lib/card-collections/cards/TagsCard.svelte deleted file mode 100644 index e1f82f4..0000000 --- a/src/lib/card-collections/cards/TagsCard.svelte +++ /dev/null @@ -1,47 +0,0 @@ - - - -
- {#await fetchTags()} -

Loading Tags...

- {:then tags} - {#each tags as tag} - - {/each} - {:catch} -

Unable to load tags

- {/await} -
-
- - diff --git a/src/lib/content-boxes/FullWidthContent.svelte b/src/lib/content-boxes/FullWidthContent.svelte deleted file mode 100644 index 154ed4b..0000000 --- a/src/lib/content-boxes/FullWidthContent.svelte +++ /dev/null @@ -1,20 +0,0 @@ -
-
- -
-
- - diff --git a/src/lib/database/mongo.server.ts b/src/lib/database/mongo.server.ts deleted file mode 100644 index ea7d221..0000000 --- a/src/lib/database/mongo.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { MongoClient } from 'mongodb'; - -const MongoUri = 'mongodb://owl:twittwoo@localhost:27017/'; - -let dbClient: MongoClient | null = null; - -export async function mongoConnect() { - if (!dbClient) { - dbClient = await MongoClient.connect(MongoUri); - } - return dbClient; -} diff --git a/src/lib/feeds/feedTypes.ts b/src/lib/feeds/feedTypes.ts index 4b55735..5a17ffa 100644 --- a/src/lib/feeds/feedTypes.ts +++ b/src/lib/feeds/feedTypes.ts @@ -11,4 +11,10 @@ export interface PixelfedFeed { updated: string | null; imgUrl: string | null; pixelfedUrl: string | null; +} + +export interface GitFeed { + title: string | null; + text: string | null; + url: string | null; } \ No newline at end of file diff --git a/src/lib/highlights/emphasis.svelte b/src/lib/highlights/emphasis.svelte deleted file mode 100644 index 7858c2e..0000000 --- a/src/lib/highlights/emphasis.svelte +++ /dev/null @@ -1,14 +0,0 @@ - - - - - diff --git a/src/lib/posts/PostTag.svelte b/src/lib/posts/PostTag.svelte deleted file mode 100644 index 786927c..0000000 --- a/src/lib/posts/PostTag.svelte +++ /dev/null @@ -1,25 +0,0 @@ - - - - {tag} - - - diff --git a/src/lib/posts/PostsSummary.svelte b/src/lib/posts/PostsSummary.svelte deleted file mode 100644 index e59bc84..0000000 --- a/src/lib/posts/PostsSummary.svelte +++ /dev/null @@ -1,40 +0,0 @@ - - - - -
-

{article.title}

-

{article.summary}

-
-
-
- - diff --git a/src/lib/posts/types.ts b/src/lib/posts/types.ts deleted file mode 100644 index 7c189da..0000000 --- a/src/lib/posts/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -export interface ArticleSummary { - title: string; - author: string; - tags: string[]; - pusblished: boolean; - date: Date; - summary: string; - slug: string; -} - -export interface Article { - title: string; - author: string; - tags: string[]; - pusblished: boolean; - date: Date; - summary: string; - slug: string; - content: string; -} diff --git a/src/lib/projects/ProjectSummary.svelte b/src/lib/projects/ProjectSummary.svelte deleted file mode 100644 index 5a62518..0000000 --- a/src/lib/projects/ProjectSummary.svelte +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/src/lib/projects/types.ts b/src/lib/projects/types.ts deleted file mode 100644 index 9174d2a..0000000 --- a/src/lib/projects/types.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface Project { - name: string; - tag: string; - imagePath: string; - summary: string; - lang: string[]; - plat: string[]; -} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index eeafdc1..629ae1a 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,17 +1,11 @@
@@ -37,12 +31,10 @@
-

Posts

- +

I do lots of things, this is a central place you can check it all out.

-
-

Tags

- +
+

Git

diff --git a/src/routes/posts/+page.svelte b/src/routes/posts/+page.svelte deleted file mode 100644 index f045d6a..0000000 --- a/src/routes/posts/+page.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - diff --git a/src/routes/posts/[slug]/+page.server.ts b/src/routes/posts/[slug]/+page.server.ts deleted file mode 100644 index b3230a5..0000000 --- a/src/routes/posts/[slug]/+page.server.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { mongoConnect } from '$lib/database/mongo.server'; -import { marked } from 'marked'; -import * as path from 'path'; -import sanitizeHtml from 'sanitize-html'; - -import type { Article } from '$lib/posts/types'; -import type { _Renderer } from 'Renderer'; - -export async function load({ params }) { - const slug = params.slug; - const db = await mongoConnect(); - const query = { - slug: slug - }; - const col = db.db('fredboniface').collection('posts'); - const res = await col.findOne(query); - - if (!res) { - throw new Error('Post Not Found'); - } - - const renderer = new marked.Renderer(); - renderer.image = function (href, title, text) { - const imgPath = path.join('/images/posts', res.slug, href); - return `
- ${text} -
${title}
-
`; - }; - - const post: Article = { - title: res.title, - author: res.author, - pusblished: res.published, - summary: res.summary, - content: renderMarkdown(res.content, renderer), - slug: res.slug, - tags: res.tags, - date: res.date - }; - - return { data: post }; -} - -function renderMarkdown(md: string, renderer: _Renderer): string { - const rawHtml = marked(md, { renderer }); - const sanitizedHtml = sanitizeHtml(rawHtml, { - allowedTags: ['a', 'br', 'code', 'figcaption', 'figure', 'img', 'p', 'pre'], - allowedAttributes: { - a: ['href'], - img: ['alt', 'class', 'src', 'title'] - } - }); - return sanitizedHtml; -} diff --git a/src/routes/posts/[slug]/+page.svelte b/src/routes/posts/[slug]/+page.svelte deleted file mode 100644 index 01b08ad..0000000 --- a/src/routes/posts/[slug]/+page.svelte +++ /dev/null @@ -1,124 +0,0 @@ - - -
- -
-
-
-

- {#each post.tags as tag} - - {/each}

- Published: {post.date.toLocaleDateString()}
- Author: {post.author} -

- - {@html post.content} - -
-
- -
-

Projects

- - -
-
- - diff --git a/src/routes/posts/latest/+server.ts b/src/routes/posts/latest/+server.ts deleted file mode 100644 index 0b29df7..0000000 --- a/src/routes/posts/latest/+server.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { json } from '@sveltejs/kit'; -import { mongoConnect } from '$lib/database/mongo.server'; - -import type { ArticleSummary } from '$lib/posts/types'; - -const length = 8; // Number of posts to return - -export async function GET({ url }) { - const db = await mongoConnect(); - const col = db.db('fredboniface').collection('posts'); - const res = await col.find().sort({ _id: -1 }).limit(length).toArray(); - return json(res); -} - -// The CONTENT field should be ommitted from the DB response diff --git a/src/routes/posts/markdown/map-dots.md b/src/routes/posts/markdown/map-dots.md deleted file mode 100644 index f48c27a..0000000 --- a/src/routes/posts/markdown/map-dots.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: map-dots -author: Frederick Boniface -date: '2023-08-16' ---- - -[map-dots Repo](https://git.fjla.uk/fred.boniface/map-dots) [map-dots-fetch Repo](https://git.fjla.uk/fred.boniface/map-dots-fetch) - -I'm someone who likes to gather data – a bit of a data hoarder. But truth be told, having the data doesn't mean I always know what to do with it. - -You know those monthly emails from Google that break down your location history? I used to find them fascinating. But, handing over all that info to Google didn't sit right with me. So, I took matters into my own hands and set up a Traccar instance at home, connecting my mobile devices to it. - -Now, my location history is kept under my own roof. I even turned off Google's location history feature. - -However, the downside was losing those monthly reports. You see, Traccar isn't exactly built for that; it's more focused on fleet tracking. - -That's when "map-dots" came into play. It's a Go-based application that can be run through the command line or as an API server. While it's still a work in progress, it's got potential. Currently, it can take in HTTP requests, connect to a Traccar server, retrieve location history data, and turn it into an image. - -To keep things ticking, I created the "map-dots-fetch" script in Python. It fetches a new image at regular intervals, and I've set that image as the wallpaper on my devices. diff --git a/src/routes/posts/markdown/notFound.md b/src/routes/posts/markdown/notFound.md deleted file mode 100644 index 78395b1..0000000 --- a/src/routes/posts/markdown/notFound.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Not Found -date: '2023-08-16' -author: Frederick Boniface ---- - -**404 - The post you requested cannot be found** - -If you came here from a search engine, maybe the post has been removed or renamed. If you got here from a link on my website then there may be a server error. diff --git a/src/routes/posts/markdown/owlboard.md b/src/routes/posts/markdown/owlboard.md deleted file mode 100644 index ea896ac..0000000 --- a/src/routes/posts/markdown/owlboard.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: OwlBoard -author: Frederick Boniface -date: '2023-08-16' ---- - -[Git Organisation](https://git.fjla.uk/owlboard) [Live Website](https://owlboard.info) - -OwlBoard came about because I was sick of dealing with clunky tools that were slow, outdated, and not user-friendly. - -I had a clear goal in mind: make something smoother, faster, and more modern to shake up the tool landscape. - -I decided to take control of the data side of things and built a Python-based db-manager app. It works on a schedule to handle database collections, polish data from different sources, and neatly store it all in the database. - -db-manager eventually grew to pull data from Network Rail's CORPUS and TIMETABLE feeds, as well as downloading PIS and Reason Code data from a git repository. - -OwlBoard started with a simple idea: real-time station departure boards. I used an Express backend alongside a basic HTML/CSS/JS frontend PWA. But as I added more features, it became obvious that a sturdier framework was needed. Both users and developers were struggling with more menus and messier code. - -Enter Svelte, especially SvelteKit. I wasn't just hopping on a trend – I liked that it allowed me to work with plain JS, HTML, and CSS in components. This made my learning curve easier and sped up improvements for users. - -When API responses got lengthy, I turned to TypeScript. It was like flipping a switch, helping me understand what's happening behind the scenes and reducing how much I relied on console.log. - -Later on, I integrated VSTP data from Network Rail using Go. I set up a message handler, subscribed to the VSTP feed using a STOMP library, and processed messages like the db-manager does. This ensured that the database's timetable collection was always up to date, thanks to how I managed transactions. - -Looking ahead, I'm focused on fine-tuning the interactions between the backend and frontend. I want to make things smoother by sending less data, especially important when dealing with shaky data connections. diff --git a/src/routes/posts/tag/+page.svelte b/src/routes/posts/tag/+page.svelte deleted file mode 100644 index e69de29..0000000 diff --git a/src/routes/posts/tag/[tag]/+page.server.ts b/src/routes/posts/tag/[tag]/+page.server.ts deleted file mode 100644 index aafd693..0000000 --- a/src/routes/posts/tag/[tag]/+page.server.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { mongoConnect } from '$lib/database/mongo.server'; - -export async function load({ params }) { - const tag = params.tag; - const db = await mongoConnect(); - const query = { - tags: { - $in: [tag] - } - }; - const col = db.db('fredboniface').collection('posts'); - const res = col.find(query); - const posts = await res.toArray(); - - return { data: JSON.stringify(posts), tag: tag }; -} diff --git a/src/routes/posts/tag/[tag]/+page.svelte b/src/routes/posts/tag/[tag]/+page.svelte deleted file mode 100644 index 82bc96d..0000000 --- a/src/routes/posts/tag/[tag]/+page.svelte +++ /dev/null @@ -1,18 +0,0 @@ - - -
- -{#each posts as post} - -{/each} diff --git a/src/routes/posts/tag/all/+server.ts b/src/routes/posts/tag/all/+server.ts deleted file mode 100644 index f54911e..0000000 --- a/src/routes/posts/tag/all/+server.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Fetches all tags and returns a JSON Array of the tags ordered in their frequency of use - -import { json } from '@sveltejs/kit'; - -import { mongoConnect } from '$lib/database/mongo.server'; - -export async function GET({ url }) { - const db = await mongoConnect(); - const col = db.db('fredboniface').collection('posts'); - const res = await col.distinct('tags'); - return json(res); -} diff --git a/src/routes/projects/+page.svelte b/src/routes/projects/+page.svelte deleted file mode 100644 index d440da7..0000000 --- a/src/routes/projects/+page.svelte +++ /dev/null @@ -1,22 +0,0 @@ - - -
- -{#await getProjects()} -

Fetching projects

-{:then projects} - {#each projects as project} - - {/each} -{:catch} -

Error fetching projects

-{/await} diff --git a/src/routes/projects/all/+server.ts b/src/routes/projects/all/+server.ts deleted file mode 100644 index 100e44c..0000000 --- a/src/routes/projects/all/+server.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Fetches all tags and returns a JSON Array of the tags ordered in their frequency of use - -import { json } from '@sveltejs/kit'; - -import { mongoConnect } from '$lib/database/mongo.server'; - -export async function GET({ url }) { - const db = await mongoConnect(); - const col = db.db('fredboniface').collection('projects'); - const res = await col.find().toArray(); - return json(res); -} diff --git a/src/routes/testing/+page.server.ts b/src/routes/testing/+page.server.ts deleted file mode 100644 index 43dc657..0000000 --- a/src/routes/testing/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { PageServerLoad } from "./$types"; - -export const load: PageServerLoad = async () => { - try { - const res = await fetch("https://pixelfed.scot/users/fbface.atom") - const xml = await res.text(); - return {xml: xml} - } catch (err) { - console.error("Error in load function", err) - } -} \ No newline at end of file diff --git a/src/routes/testing/+page.svelte b/src/routes/testing/+page.svelte deleted file mode 100644 index 6cb1f5c..0000000 --- a/src/routes/testing/+page.svelte +++ /dev/null @@ -1,8 +0,0 @@ - - - \ No newline at end of file