From 3ff1e24e7c5dfe5ae13fdf6b3eafcb086bdc1bc5 Mon Sep 17 00:00:00 2001 From: Akis Date: Fri, 3 Feb 2023 19:55:33 +0200 Subject: [PATCH] better navbar --- .github/workflows/docker-dev.yml | 54 +++++------ .github/workflows/docker.yml | 54 +++++------ README.md | 23 ++--- compose.yml | 2 +- src/app.css | 5 +- src/app.html | 10 +- src/hooks.server.ts | 57 ++++++----- src/lib/BlogCard/Meta.svelte | 35 +++++-- src/lib/BlogCard/PostContent.svelte | 8 +- src/lib/BlogCard/PostOuter.svelte | 11 ++- src/lib/BlogCard/PostsContainer.svelte | 2 +- src/lib/BlogCard/ReadMore.svelte | 2 +- src/lib/BlogCard/SingleWordLists.svelte | 8 +- src/lib/BlogCard/Title.svelte | 13 ++- src/lib/BlogCard/index.ts | 2 +- src/lib/Footer.svelte | 10 +- src/lib/Hero.svelte | 20 +++- src/lib/Nav/Nav.svelte | 87 ++++++----------- src/lib/Nav/ThemeToggle.svelte | 6 +- src/lib/PMargin.svelte | 2 +- src/lib/PageTransition.svelte | 7 +- src/routes/+error.svelte | 4 +- src/routes/+layout.svelte | 23 +++-- src/routes/+layout.ts | 4 +- src/routes/+page.server.ts | 4 +- src/routes/+page.svelte | 30 ++++-- src/routes/admin/+page.svelte | 2 +- src/routes/admin/+page.ts | 8 +- src/routes/blog/+page.server.ts | 4 +- src/routes/blog/+page.svelte | 31 +++++- src/routes/blog/[title]/+page.server.ts | 4 +- src/routes/blog/[title]/+page.svelte | 34 +++++-- src/routes/blog/authors/+page.server.ts | 2 +- src/routes/blog/authors/+page.svelte | 7 +- .../blog/authors/[author]/+page.server.ts | 19 ++-- src/routes/blog/authors/[author]/+page.svelte | 10 +- src/routes/blog/fetchGhost.ts | 17 +++- src/routes/blog/tags/+page.server.ts | 6 +- src/routes/blog/tags/+page.svelte | 7 +- src/routes/blog/tags/[tag]/+page.server.ts | 18 ++-- src/routes/blog/tags/[tag]/+page.svelte | 10 +- src/routes/contact/+page.svelte | 24 ++++- src/routes/contact/+page.ts | 8 +- src/routes/donate/+page.svelte | 44 +++++++-- src/routes/donate/+page.ts | 8 +- src/routes/donate/CryptoInfo.svelte | 12 ++- src/routes/instances/+page.server.ts | 4 +- src/routes/instances/+page.svelte | 20 +++- src/routes/instances/advanced/+page.server.ts | 4 +- src/routes/instances/advanced/+page.svelte | 9 +- src/routes/instances/instances.ts | 2 +- src/routes/legal/+page.svelte | 25 ++++- src/routes/legal/+page.ts | 11 ++- src/routes/legal/privacy-policy/+page.svelte | 97 ++++++++++++++++--- src/routes/legal/privacy-policy/+page.ts | 8 +- src/routes/legal/tos/+page.svelte | 36 +++++-- src/routes/legal/tos/+page.ts | 8 +- src/routes/login/+page.server.ts | 17 +++- src/routes/login/+page.svelte | 30 ++++-- src/routes/pubnix/+page.server.ts | 10 +- src/routes/pubnix/+page.svelte | 25 ++++- src/routes/pubnix/User.svelte | 30 ++++-- src/routes/pubnix/faq/+page.svelte | 5 +- src/routes/pubnix/faq/+page.ts | 8 +- src/routes/pubnix/register/+page.server.ts | 65 +++++++++---- src/routes/pubnix/register/+page.svelte | 27 ++++-- src/routes/pubnix/users/+page.server.ts | 10 +- src/routes/pubnix/users/+page.svelte | 2 +- src/routes/team/+page.svelte | 21 ++-- src/routes/team/+page.ts | 8 +- src/routes/team/Team.json | 2 +- svelte.config.js | 4 +- uno.config.ts | 2 +- vite.config.ts | 6 +- 74 files changed, 839 insertions(+), 415 deletions(-) diff --git a/.github/workflows/docker-dev.yml b/.github/workflows/docker-dev.yml index 7cac226..787e170 100644 --- a/.github/workflows/docker-dev.yml +++ b/.github/workflows/docker-dev.yml @@ -1,36 +1,34 @@ name: Docker dev on: - push: - branches: - - 'dev' + push: + branches: + - "dev" jobs: - build: - name: 'Build' - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + build: + name: "Build" + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: "Build:checkout" - uses: actions/checkout@v3 + - name: "Build:checkout" + uses: actions/checkout@v3 - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ProjectSegfault - password: ${{ secrets.ACCESS_TOKEN }} + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ProjectSegfault + password: ${{ secrets.ACCESS_TOKEN }} - - name: 'Build:dockerimage' - uses: docker/build-push-action@v3 - with: - tags: ghcr.io/projectsegfault/website:dev - context: "." - push: true - no-cache: true \ No newline at end of file + - name: "Build:dockerimage" + uses: docker/build-push-action@v3 + with: + tags: ghcr.io/projectsegfault/website:dev + context: "." + push: true + no-cache: true diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5bca3ab..7eceb2c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,36 +1,34 @@ name: Docker on: - push: - branches: - - 'master' + push: + branches: + - "master" jobs: - build: - name: 'Build' - runs-on: ubuntu-latest - steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + build: + name: "Build" + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: "Build:checkout" - uses: actions/checkout@v3 + - name: "Build:checkout" + uses: actions/checkout@v3 - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ProjectSegfault - password: ${{ secrets.ACCESS_TOKEN }} + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ProjectSegfault + password: ${{ secrets.ACCESS_TOKEN }} - - name: 'Build:dockerimage' - uses: docker/build-push-action@v3 - with: - tags: ghcr.io/projectsegfault/website:latest - context: "." - push: true - no-cache: true \ No newline at end of file + - name: "Build:dockerimage" + uses: docker/build-push-action@v3 + with: + tags: ghcr.io/projectsegfault/website:latest + context: "." + push: true + no-cache: true diff --git a/README.md b/README.md index 5c37599..e66b90c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Live at [projectsegfau.lt](https://projectsegfau.lt). - Install [node.js](https://nodejs.org). - Install [pnpm](https://pnpm.io/). - Learn [Svelte](https://svelte.dev). -- Add the environment variables from the [environment variables section](#environment-variables). +- Add the environment variables from the [environment variables section](#environment-variables). ### Running a dev server. @@ -37,13 +37,14 @@ If you want to run the website locally in production follow the steps in [develo The website has the following **mandatory** environment variables -| Name | Description | -|:------------------ |:------------------------- | -| AUTH_CLIENT_ID | Authentik client ID | -| AUTH_CLIENT_SECRET | Authentik client secret | -| AUTH_ISSUER | Authentication issuer URL | -| AUTH_TRUST_HOST | Your domain | -| AUTH_SECRET | Random 32 char secret | -| GHOST_URL | Your Ghost CMS URL | -| GHOST_API_KEY | Your Ghost CMS API key | -| ORIGIN | Your domain | \ No newline at end of file +| Name | Description | +| :----------------- | :----------------------------------| +| AUTH_CLIENT_ID | Authentik client ID | +| AUTH_CLIENT_SECRET | Authentik client secret | +| AUTH_ISSUER | Authentication issuer URL | +| AUTH_TRUST_HOST | Your domain | +| AUTH_SECRET | Random 32 char secret | +| GHOST_URL | Your Ghost CMS URL | +| GHOST_API_KEY | Your Ghost CMS API key | +| KUMA_URL | Your Uptime Kuma announcements URL | +| ORIGIN | Your domain | diff --git a/compose.yml b/compose.yml index cb501bd..e43d826 100644 --- a/compose.yml +++ b/compose.yml @@ -8,4 +8,4 @@ services: # context: . # dockerfile: Dockerfile ports: - - "127.0.0.1:1339:3000" \ No newline at end of file + - "127.0.0.1:1339:3000" diff --git a/src/app.css b/src/app.css index 9828ee3..a0bb872 100644 --- a/src/app.css +++ b/src/app.css @@ -4,7 +4,8 @@ font-display: swap; } -html, html.light { +html, +html.light { --accent: #00a584; --accent-translucent: #00a58498; --font-primary: "JetBrains Mono", monospace; @@ -74,4 +75,4 @@ details { .button { @apply px-2 py-1 bg-accent text-primary rounded no-underline flex flex-row items-center gap-2; -} \ No newline at end of file +} diff --git a/src/app.html b/src/app.html index cdc364b..c02c1d5 100644 --- a/src/app.html +++ b/src/app.html @@ -2,8 +2,14 @@ - - + + %sveltekit.head% diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 9949933..97c6008 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -6,7 +6,14 @@ import type { Profile } from "@auth/core/types"; import { redirect, type Handle } from "@sveltejs/kit"; import { sequence } from "@sveltejs/kit/hooks"; -const hasAuth = !env.AUTH_CLIENT_ID || !env.AUTH_CLIENT_SECRET || !env.AUTH_ISSUER || !env.AUTH_TRUST_HOST || !env.AUTH_SECRET ? false : true; +const hasAuth = + !env.AUTH_CLIENT_ID || + !env.AUTH_CLIENT_SECRET || + !env.AUTH_ISSUER || + !env.AUTH_TRUST_HOST || + !env.AUTH_SECRET + ? false + : true; export const handle: Handle = sequence( //@ts-ignore @@ -19,26 +26,28 @@ export const handle: Handle = sequence( }) as Provider ] }), - hasAuth ? async ({ event, resolve }) => { - if (event.url.pathname.startsWith("/admin")) { - const session = await event.locals.getSession(); - if (!session) { - throw redirect(303, "/login"); - } - } - - const result = await resolve(event, { - transformPageChunk: ({ html }) => html - }); - return result; - } : async ({ event, resolve }) => { - if (event.url.pathname.startsWith("/admin")) { - throw redirect(303, "/login"); - } - - const result = await resolve(event, { - transformPageChunk: ({ html }) => html - }); - return result; - } -); \ No newline at end of file + hasAuth + ? async ({ event, resolve }) => { + if (event.url.pathname.startsWith("/admin")) { + const session = await event.locals.getSession(); + if (!session) { + throw redirect(303, "/login"); + } + } + + const result = await resolve(event, { + transformPageChunk: ({ html }) => html + }); + return result; + } + : async ({ event, resolve }) => { + if (event.url.pathname.startsWith("/admin")) { + throw redirect(303, "/login"); + } + + const result = await resolve(event, { + transformPageChunk: ({ html }) => html + }); + return result; + } +); diff --git a/src/lib/BlogCard/Meta.svelte b/src/lib/BlogCard/Meta.svelte index 7d762c2..e6871ca 100644 --- a/src/lib/BlogCard/Meta.svelte +++ b/src/lib/BlogCard/Meta.svelte @@ -5,21 +5,38 @@ export let isPost: boolean = false; -
+
{#if post.tags.length > 0}
{#each post.tags as tag} - {tag.name} + {tag.name} {/each}
{/if} {#each post.authors as author} -
{author.name} +
+ {author.name} {/each} -
{dayjs - (post.published_at) - .format("ddd, DD MMM YYYY HH:mm")} -
{post.plaintext.trim().split(/\s+/).length} words -
{post.reading_time} minute read -
\ No newline at end of file +
+ {dayjs(post.published_at).format("ddd, DD MMM YYYY HH:mm")} +
+ {post.plaintext.trim().split(/\s+/).length} words +
+ {post.reading_time} minute read +
diff --git a/src/lib/BlogCard/PostContent.svelte b/src/lib/BlogCard/PostContent.svelte index 1b70a8e..75d47d0 100644 --- a/src/lib/BlogCard/PostContent.svelte +++ b/src/lib/BlogCard/PostContent.svelte @@ -3,6 +3,10 @@
- {data.post.title} image + {data.post.title} image {@html data.post.html} -
\ No newline at end of file +
diff --git a/src/lib/BlogCard/PostOuter.svelte b/src/lib/BlogCard/PostOuter.svelte index 0c43427..d2fd71d 100644 --- a/src/lib/BlogCard/PostOuter.svelte +++ b/src/lib/BlogCard/PostOuter.svelte @@ -3,10 +3,15 @@ export let isPost: boolean = false; -
+
{#if url} - View on Ghost + View on Ghost {/if} -
\ No newline at end of file +
diff --git a/src/lib/BlogCard/PostsContainer.svelte b/src/lib/BlogCard/PostsContainer.svelte index 7c611a8..dac5cb3 100644 --- a/src/lib/BlogCard/PostsContainer.svelte +++ b/src/lib/BlogCard/PostsContainer.svelte @@ -1,3 +1,3 @@
-
\ No newline at end of file +
diff --git a/src/lib/BlogCard/ReadMore.svelte b/src/lib/BlogCard/ReadMore.svelte index 22f10aa..58417cf 100644 --- a/src/lib/BlogCard/ReadMore.svelte +++ b/src/lib/BlogCard/ReadMore.svelte @@ -3,4 +3,4 @@ {post.plaintext.split(" ").slice(0, 20).join(" ") + "..."} -Read more... \ No newline at end of file +Read more... diff --git a/src/lib/BlogCard/SingleWordLists.svelte b/src/lib/BlogCard/SingleWordLists.svelte index 3088758..6d99332 100644 --- a/src/lib/BlogCard/SingleWordLists.svelte +++ b/src/lib/BlogCard/SingleWordLists.svelte @@ -3,9 +3,11 @@ export let name: string; -
{#each items as item} - {item.name} + {item.name} {/each} -
\ No newline at end of file +
diff --git a/src/lib/BlogCard/Title.svelte b/src/lib/BlogCard/Title.svelte index d85d277..054104b 100644 --- a/src/lib/BlogCard/Title.svelte +++ b/src/lib/BlogCard/Title.svelte @@ -5,10 +5,17 @@ {#if !isPost} {#if post.feature_image} - {post.title} image + {post.title} image {/if} - {post.title} + {post.title} {:else} {post.title} {/if} - diff --git a/src/lib/BlogCard/index.ts b/src/lib/BlogCard/index.ts index c019b6e..a9a4485 100644 --- a/src/lib/BlogCard/index.ts +++ b/src/lib/BlogCard/index.ts @@ -4,4 +4,4 @@ export { default as Title } from "./Title.svelte"; export { default as Meta } from "./Meta.svelte"; export { default as ReadMore } from "./ReadMore.svelte"; export { default as PostContent } from "./PostContent.svelte"; -export { default as SingleWordLists } from "./SingleWordLists.svelte"; \ No newline at end of file +export { default as SingleWordLists } from "./SingleWordLists.svelte"; diff --git a/src/lib/Footer.svelte b/src/lib/Footer.svelte index dc182fa..033b677 100644 --- a/src/lib/Footer.svelte +++ b/src/lib/Footer.svelte @@ -1,7 +1,11 @@
-
-

Made with SvelteKit

+
+

+ Made with SvelteKit +

Source code
-
\ No newline at end of file + diff --git a/src/lib/Hero.svelte b/src/lib/Hero.svelte index 37bd5ac..e0dbc82 100644 --- a/src/lib/Hero.svelte +++ b/src/lib/Hero.svelte @@ -1,8 +1,20 @@
-

Project Segfault

+

+ Project Segfault +

Open source development and hosted services.

-
Instances -
Donate + \ No newline at end of file +
diff --git a/src/lib/Nav/Nav.svelte b/src/lib/Nav/Nav.svelte index 3cac869..cd5a4dc 100644 --- a/src/lib/Nav/Nav.svelte +++ b/src/lib/Nav/Nav.svelte @@ -1,8 +1,8 @@ {#key pathname} -
+
-{/key} \ No newline at end of file +{/key} diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index 2f87994..fe0a79f 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -1,8 +1,8 @@

{$page.status}

{$page.error?.message}

-

\ No newline at end of file + diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 1147909..4704332 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -13,18 +13,27 @@ - {$page.data.title} | Project Segfault {$page.url.pathname.startsWith("/blog") ? "blog" : ""} + {$page.data.title} | Project Segfault {$page.url.pathname.startsWith( + "/blog" + ) + ? "blog" + : ""} {#if $page.data.description} - + {/if}