From 6f65e9d3cd910d80214635e45f3cc37d674b44f6 Mon Sep 17 00:00:00 2001 From: Benjamin Jesuiter Date: Sat, 12 Jul 2025 20:10:00 +0200 Subject: [PATCH 01/10] add min w to message log --- islands/Log.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/islands/Log.tsx b/islands/Log.tsx index 5129c41..a5316da 100644 --- a/islands/Log.tsx +++ b/islands/Log.tsx @@ -27,6 +27,7 @@ export default function Log() { ? "block" : "none", }} + class="md:min-w-[250px]" > {lastMessage} From b4b97e81b02a473b154335512b80b11ed2dba1c7 Mon Sep 17 00:00:00 2001 From: Benjamin Jesuiter Date: Sat, 12 Jul 2025 20:22:51 +0200 Subject: [PATCH 02/10] move createSecret code to new page --- fresh.gen.ts | 2 ++ routes/create.tsx | 11 +++++++++++ routes/index.tsx | 16 +++++++--------- utils/routing.ts | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 routes/create.tsx create mode 100644 utils/routing.ts diff --git a/fresh.gen.ts b/fresh.gen.ts index cfe976b..cd52b1f 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -7,6 +7,7 @@ import * as $_app from "./routes/_app.tsx"; import * as $api_create from "./routes/api/create.ts"; import * as $api_res_tailwind_css from "./routes/api/res/tailwind.css.ts"; import * as $api_secret_uuid_ from "./routes/api/secret/[uuid].ts"; +import * as $create from "./routes/create.tsx"; import * as $index from "./routes/index.tsx"; import * as $secret_uuid_ from "./routes/secret/[uuid].tsx"; import * as $CreateSecret from "./islands/CreateSecret.tsx"; @@ -21,6 +22,7 @@ const manifest = { "./routes/api/create.ts": $api_create, "./routes/api/res/tailwind.css.ts": $api_res_tailwind_css, "./routes/api/secret/[uuid].ts": $api_secret_uuid_, + "./routes/create.tsx": $create, "./routes/index.tsx": $index, "./routes/secret/[uuid].tsx": $secret_uuid_, }, diff --git a/routes/create.tsx b/routes/create.tsx new file mode 100644 index 0000000..ff8b3d5 --- /dev/null +++ b/routes/create.tsx @@ -0,0 +1,11 @@ +import CreateSecret from "../islands/CreateSecret.tsx"; +import Log from "../islands/Log.tsx"; + +export default function CreateSecretPage() { + return ( +
+ + +
+ ); +} diff --git a/routes/index.tsx b/routes/index.tsx index 37c0b79..3f76c5e 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -1,11 +1,9 @@ -import CreateSecret from "../islands/CreateSecret.tsx"; -import Log from "../islands/Log.tsx"; +import { redirectTo } from "../utils/routing.ts"; -export default function Home() { - return ( -
- - -
- ); +/** + * @bjesuiter: "async" is required here, otherwise the redirectTo will not work for some reason + * (async pages are handled slightly differently in fresh than sync pages) + */ +export default async function Home() { + return redirectTo("/create"); } diff --git a/utils/routing.ts b/utils/routing.ts new file mode 100644 index 0000000..20c4339 --- /dev/null +++ b/utils/routing.ts @@ -0,0 +1,15 @@ +/** + * Usage from a route handler: + * + * ```ts + * return redirectTo("/login"); + * ``` + */ +export function redirectTo(relativePath: string) { + const headers = new Headers(); + headers.set("location", relativePath); + return new Response(null, { + status: 303, + headers, + }); +} From 15addd216c6b79560c1d08e67d22e1371f0ab6e6 Mon Sep 17 00:00:00 2001 From: Benjamin Jesuiter Date: Sat, 12 Jul 2025 21:13:41 +0200 Subject: [PATCH 03/10] wip --- fresh.gen.ts | 2 ++ islands/CreateSecret.tsx | 9 +++--- islands/Log.tsx | 53 +++++++++++++--------------------- islands/messages/StringMsg.tsx | 30 +++++++++++++++++++ src/formHandler/create.ts | 5 +++- src/formHandler/fetch.ts | 34 ++++++++++++++++------ src/utils/crypt.ts | 20 ++++++++++--- src/utils/log.ts | 20 ++++++++++++- 8 files changed, 120 insertions(+), 53 deletions(-) create mode 100644 islands/messages/StringMsg.tsx diff --git a/fresh.gen.ts b/fresh.gen.ts index cd52b1f..99ec502 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -13,6 +13,7 @@ import * as $secret_uuid_ from "./routes/secret/[uuid].tsx"; import * as $CreateSecret from "./islands/CreateSecret.tsx"; import * as $FetchSecret from "./islands/FetchSecret.tsx"; import * as $Log from "./islands/Log.tsx"; +import * as $messages_StringMsg from "./islands/messages/StringMsg.tsx"; import type { Manifest } from "$fresh/server.ts"; const manifest = { @@ -30,6 +31,7 @@ const manifest = { "./islands/CreateSecret.tsx": $CreateSecret, "./islands/FetchSecret.tsx": $FetchSecret, "./islands/Log.tsx": $Log, + "./islands/messages/StringMsg.tsx": $messages_StringMsg, }, baseUrl: import.meta.url, } satisfies Manifest; diff --git a/islands/CreateSecret.tsx b/islands/CreateSecret.tsx index c33919e..edf40af 100644 --- a/islands/CreateSecret.tsx +++ b/islands/CreateSecret.tsx @@ -20,8 +20,7 @@ export default function CreateSecret() { name="hidden" type="text" style="display:none;" - > - + />