svelte-migrate: updated files
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/kit": "^1.0.0-next.350",
|
||||
"@sveltejs/kit": "^1.0.0-next.544",
|
||||
"@tailwindcss/typography": "^0.5.2",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/svelte": "^3.1.3",
|
||||
|
||||
2
webapp/pnpm-lock.yaml
generated
2
webapp/pnpm-lock.yaml
generated
@@ -3,7 +3,7 @@ lockfileVersion: 5.4
|
||||
specifiers:
|
||||
'@sveltejs/adapter-auto': next
|
||||
'@sveltejs/adapter-node': ^1.0.0-next.78
|
||||
'@sveltejs/kit': ^1.0.0-next.350
|
||||
'@sveltejs/kit': ^1.0.0-next.544
|
||||
'@tailwindcss/typography': ^0.5.2
|
||||
'@testing-library/jest-dom': ^5.16.4
|
||||
'@testing-library/svelte': ^3.1.3
|
||||
|
||||
@@ -1,42 +1,21 @@
|
||||
<script context="module" lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
|
||||
export const load: Load = ({ error, status }) => {
|
||||
let explainText = '';
|
||||
let title = '';
|
||||
|
||||
if (status == 404) {
|
||||
title = `404: No note found 🕵️`;
|
||||
explainText = `No note was found at this link. Are you from the future?`;
|
||||
}
|
||||
|
||||
if (status == 410) {
|
||||
title = '📝💨 This note is no longer here! ';
|
||||
explainText = `Notes are stored for a limited amount of time. The note at this link was either set to expire, or deleted due to inactivity. Sorry!`;
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
status: status,
|
||||
title: title,
|
||||
explainText: explainText
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let status: number;
|
||||
export let title: string;
|
||||
export let explainText: string;
|
||||
import { page } from '$app/stores';
|
||||
</script>
|
||||
|
||||
<div class="prose max-w-2xl prose-zinc dark:prose-invert">
|
||||
<h1>{title}</h1>
|
||||
<p class="prose-xl">{explainText}</p>
|
||||
{#if $page.status === 404}
|
||||
<h1>404: No note found 🕵️</h1>
|
||||
<p class="prose-xl">No note was found at this link. Are you from the future?</p>
|
||||
{:else if $page.status === 410}
|
||||
<h1>📝💨 This note is no longer here!</h1>
|
||||
<p class="prose-xl">
|
||||
Notes are stored for a limited amount of time. The note at this link was either set to expire,
|
||||
or deleted due to inactivity. Sorry!
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div class="not-prose w-full flex justify-center mt-16">
|
||||
{#if status == 404 || status == 410}
|
||||
{#if $page.status === 404 || $page.status === 410}
|
||||
<img src="/expired_note.svg" alt="encrypted-art" class="w-80" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
2
webapp/src/routes/+page.js
Normal file
2
webapp/src/routes/+page.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// try making this false to prevent LinkedIn crawler returning 416
|
||||
export const prerender = false;
|
||||
@@ -1,8 +1,3 @@
|
||||
<script context="module">
|
||||
// try making this false to prevent LinkedIn crawler returning 416
|
||||
export const prerender = false;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import Tile from '$lib/components/index/tile.svelte';
|
||||
</script>
|
||||
|
||||
1
webapp/src/routes/about/+page.js
Normal file
1
webapp/src/routes/about/+page.js
Normal file
@@ -0,0 +1 @@
|
||||
export const prerender = true;
|
||||
@@ -1,7 +1,3 @@
|
||||
<script context="module">
|
||||
export const prerender = true;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>About | {import.meta.env.VITE_BRANDING}</title>
|
||||
</svelte:head>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script context="module" lang="ts">
|
||||
export const prerender = true;
|
||||
|
||||
// @ts-expect-error - Markdown files are not recognized by Svelte
|
||||
import { toc, html } from '/CHANGELOG.md';
|
||||
<script lang="ts">
|
||||
export let html: string;
|
||||
</script>
|
||||
|
||||
<div class="md:py-8 prose prose-md max-w-3xl dark:prose-invert">
|
||||
|
||||
8
webapp/src/routes/changelog/+page.ts
Normal file
8
webapp/src/routes/changelog/+page.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const prerender = true;
|
||||
|
||||
// @ts-expect-error - Markdown files are not recognized by Vite
|
||||
import { html } from '/CHANGELOG.md';
|
||||
|
||||
export function load() {
|
||||
return { html };
|
||||
}
|
||||
1
webapp/src/routes/contact/+page.js
Normal file
1
webapp/src/routes/contact/+page.js
Normal file
@@ -0,0 +1 @@
|
||||
export const prerender = true;
|
||||
@@ -1,7 +1,3 @@
|
||||
<script context="module">
|
||||
export const prerender = true;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Contact | {import.meta.env.VITE_BRANDING}</title>
|
||||
</svelte:head>
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<script context="module" lang="ts">
|
||||
export const prerender = true;
|
||||
|
||||
// @ts-expect-error - Markdown files are not recognized by Svelte
|
||||
import { toc, html } from './funding.md';
|
||||
<script lang="ts">
|
||||
export let html: string;
|
||||
</script>
|
||||
|
||||
<div class="md:py-8 prose prose-md max-w-3xl dark:prose-invert">
|
||||
|
||||
8
webapp/src/routes/funding/+page.ts
Normal file
8
webapp/src/routes/funding/+page.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export const prerender = true;
|
||||
|
||||
// @ts-expect-error - Markdown files are not recognized by Svelte
|
||||
import { html } from '../funding.md';
|
||||
|
||||
export function load() {
|
||||
return { html };
|
||||
}
|
||||
1
webapp/src/routes/install/+page.js
Normal file
1
webapp/src/routes/install/+page.js
Normal file
@@ -0,0 +1 @@
|
||||
export const prerender = true;
|
||||
@@ -1,7 +1,3 @@
|
||||
<script context="module">
|
||||
export const prerender = true;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Get the plugin | {import.meta.env.VITE_BRANDING}</title>
|
||||
<script src="https://tarptaeya.github.io/repo-card/repo-card.js"></script>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const get: RequestHandler = async ({ request, clientAddress, params }) => {
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const get: PageServerLoad = async ({ request, clientAddress, params, setHeaders }) => {
|
||||
const ip = (request.headers.get('x-forwarded-for') || clientAddress) as string;
|
||||
const url = `${import.meta.env.VITE_SERVER_INTERNAL}/api/note/${params.id}`;
|
||||
const response = await fetch(url, {
|
||||
@@ -16,27 +18,16 @@ export const get: RequestHandler = async ({ request, clientAddress, params }) =>
|
||||
note.insert_time = new Date(note.insert_time as unknown as string);
|
||||
note.expire_time = new Date(note.expire_time as unknown as string);
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
return {
|
||||
status: response.status,
|
||||
headers: {
|
||||
'Cache-Control': `public, max-age=${maxage}`
|
||||
},
|
||||
cache: {
|
||||
maxage: maxage,
|
||||
private: false
|
||||
},
|
||||
body: { note }
|
||||
};
|
||||
|
||||
setHeaders({
|
||||
maxage: maxage,
|
||||
'Cache-Control': `max-age=${maxage}, public`
|
||||
});
|
||||
return { note };
|
||||
} catch {
|
||||
return {
|
||||
status: 500,
|
||||
error: response.statusText
|
||||
};
|
||||
error(500, response.statusText);
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
status: response.status,
|
||||
error: response.statusText
|
||||
};
|
||||
error(response.status, response.statusText);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,34 +1,19 @@
|
||||
<script context="module" , lang="ts">
|
||||
import type { Load } from '@sveltejs/kit';
|
||||
|
||||
export const load: Load = async ({ props }) => {
|
||||
const note: EncryptedNote = props.note;
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
return {
|
||||
status: 200,
|
||||
cache: {
|
||||
maxage: maxage,
|
||||
private: false
|
||||
},
|
||||
props: { note }
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { decrypt } from '$lib/crypto/decrypt';
|
||||
import MarkdownRenderer from '$lib/components/MarkdownRenderer.svelte';
|
||||
import LogoMarkdown from 'svelte-icons/io/IoLogoMarkdown.svelte';
|
||||
import IconEncrypted from 'svelte-icons/md/MdLockOutline.svelte';
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
import { browser } from '$app/env';
|
||||
import RawRenderer from '$lib/components/RawRenderer.svelte';
|
||||
import LogoDocument from 'svelte-icons/md/MdUndo.svelte';
|
||||
import Dismissable from '$lib/components/Dismissable.svelte';
|
||||
|
||||
// Auto-loaded from [id].ts endpoint
|
||||
export let note: EncryptedNote;
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
let { note } = data;
|
||||
let plaintext: string;
|
||||
let timeString: string;
|
||||
let decryptFailed = false;
|
||||
|
||||
14
webapp/src/routes/note/[id]/+page.ts
Normal file
14
webapp/src/routes/note/[id]/+page.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { EncryptedNote } from '$lib/model/EncryptedNote';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ data, setHeaders }) => {
|
||||
const note: EncryptedNote = data.note;
|
||||
const maxage = Math.floor((note.expire_time.valueOf() - note.insert_time.valueOf()) / 1000);
|
||||
|
||||
setHeaders({
|
||||
maxage: maxage,
|
||||
'Cache-Control': `max-age=${maxage}, public`
|
||||
});
|
||||
|
||||
return { note };
|
||||
};
|
||||
1
webapp/src/routes/roadmap/+page.js
Normal file
1
webapp/src/routes/roadmap/+page.js
Normal file
@@ -0,0 +1 @@
|
||||
export const prerender = true;
|
||||
@@ -1,7 +1,3 @@
|
||||
<script context="module">
|
||||
export const prerender = true;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Roadmap | {import.meta.env.VITE_BRANDING}</title>
|
||||
</svelte:head>
|
||||
|
||||
Reference in New Issue
Block a user