From eea49969b5168eee567d104400232de0d6e04c68 Mon Sep 17 00:00:00 2001 From: Kevin FEDYNA Date: Wed, 15 Jan 2025 10:15:02 +0100 Subject: [PATCH] Added catalog generation, need to bug fix --- fresh.gen.ts | 14 +++--- routes/(_components)/Footer.tsx | 12 +++++ routes/(_components)/Header.tsx | 17 +++++++ routes/(_islands)/AppNavigator.tsx | 27 +++++++++++ routes/(apps)/notes/(_props)/props.ts | 8 ++++ routes/(apps)/notes/index.tsx | 12 +++++ routes/(modules)/notes/index.tsx | 0 routes/_app.tsx | 34 +++++++------- routes/_middleware.ts | 43 +++++++++++------ routes/about.tsx | 15 ++++++ routes/apps.tsx | 13 +++++ routes/index.tsx | 10 ++-- routes/login.tsx | 68 ++++++++++++++++----------- routes/logout.tsx | 18 ++++--- routes/partials/about.tsx | 15 ------ routes/partials/modules.tsx | 0 static/styles/main.css | 41 ++++++++++++++-- 17 files changed, 248 insertions(+), 99 deletions(-) create mode 100644 routes/(_components)/Footer.tsx create mode 100644 routes/(_components)/Header.tsx create mode 100644 routes/(_islands)/AppNavigator.tsx create mode 100644 routes/(apps)/notes/(_props)/props.ts create mode 100644 routes/(apps)/notes/index.tsx delete mode 100644 routes/(modules)/notes/index.tsx create mode 100644 routes/about.tsx create mode 100644 routes/apps.tsx delete mode 100644 routes/partials/about.tsx delete mode 100644 routes/partials/modules.tsx diff --git a/fresh.gen.ts b/fresh.gen.ts index cce7416..7eb9815 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -2,32 +2,34 @@ // This file SHOULD be checked into source version control. // This file is automatically updated during development when running `dev.ts`. -import * as $_modules_notes_index from "./routes/(modules)/notes/index.tsx"; +import * as $_apps_notes_index from "./routes/(apps)/notes/index.tsx"; import * as $_404 from "./routes/_404.tsx"; import * as $_app from "./routes/_app.tsx"; import * as $_middleware from "./routes/_middleware.ts"; +import * as $about from "./routes/about.tsx"; +import * as $apps from "./routes/apps.tsx"; import * as $index from "./routes/index.tsx"; import * as $login from "./routes/login.tsx"; import * as $logout from "./routes/logout.tsx"; -import * as $partials_about from "./routes/partials/about.tsx"; -import * as $partials_modules from "./routes/partials/modules.tsx"; import * as $Counter from "./islands/Counter.tsx"; +import * as $_islands_AppNavigator from "./routes/(_islands)/AppNavigator.tsx"; import type { Manifest } from "$fresh/server.ts"; const manifest = { routes: { - "./routes/(modules)/notes/index.tsx": $_modules_notes_index, + "./routes/(apps)/notes/index.tsx": $_apps_notes_index, "./routes/_404.tsx": $_404, "./routes/_app.tsx": $_app, "./routes/_middleware.ts": $_middleware, + "./routes/about.tsx": $about, + "./routes/apps.tsx": $apps, "./routes/index.tsx": $index, "./routes/login.tsx": $login, "./routes/logout.tsx": $logout, - "./routes/partials/about.tsx": $partials_about, - "./routes/partials/modules.tsx": $partials_modules, }, islands: { "./islands/Counter.tsx": $Counter, + "./routes/(_islands)/AppNavigator.tsx": $_islands_AppNavigator, }, baseUrl: import.meta.url, } satisfies Manifest; diff --git a/routes/(_components)/Footer.tsx b/routes/(_components)/Footer.tsx new file mode 100644 index 0000000..014638f --- /dev/null +++ b/routes/(_components)/Footer.tsx @@ -0,0 +1,12 @@ +type FooterProps = Record; + +export default function Footer(_props: FooterProps) { + return ( +
+

+ © 2025 PolyMPR -{" "} + About +

+
+ ); +} diff --git a/routes/(_components)/Header.tsx b/routes/(_components)/Header.tsx new file mode 100644 index 0000000..34853ad --- /dev/null +++ b/routes/(_components)/Header.tsx @@ -0,0 +1,17 @@ +type HeaderProps = { + link: string; +}; + +export default function Header(props: HeaderProps) { + return ( +
+

+ PolyMPR +

+ +
+ ); +} diff --git a/routes/(_islands)/AppNavigator.tsx b/routes/(_islands)/AppNavigator.tsx new file mode 100644 index 0000000..a5f1c78 --- /dev/null +++ b/routes/(_islands)/AppNavigator.tsx @@ -0,0 +1,27 @@ +export interface AppProperties { + name: string; + icon: string; +} + +type AppNavigatorProps = Record; + +export default async function AppNavigator(_props: AppNavigatorProps) { + + const apps: Record = {}; + + for await (const appDir of Deno.readDir("../(apps)")) { + try { + const properties: AppProperties = await import(`../(apps)/${appDir.name}/(_props)/props.ts`); + apps[appDir.name] = properties; + } + catch (error) { + console.error(`Couldn't import app "${appDir.name}": ${error}`); + } + } + + return ( + <> +

{JSON.stringify(apps)}

+ + ); +} diff --git a/routes/(apps)/notes/(_props)/props.ts b/routes/(apps)/notes/(_props)/props.ts new file mode 100644 index 0000000..6350ddd --- /dev/null +++ b/routes/(apps)/notes/(_props)/props.ts @@ -0,0 +1,8 @@ +import { AppProperties } from "../../../(_islands)/AppNavigator.tsx"; + +const properties: AppProperties = { + name: "PolyNotes", + icon: "school" +}; + +export default properties; \ No newline at end of file diff --git a/routes/(apps)/notes/index.tsx b/routes/(apps)/notes/index.tsx new file mode 100644 index 0000000..ddfcc34 --- /dev/null +++ b/routes/(apps)/notes/index.tsx @@ -0,0 +1,12 @@ +type ModulesProps = Record; + +export default function Modules(_props: ModulesProps) { + return ( + <> +

All PolyMPR modules

+ + + ); +} \ No newline at end of file diff --git a/routes/(modules)/notes/index.tsx b/routes/(modules)/notes/index.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/routes/_app.tsx b/routes/_app.tsx index 0d62d67..de447b0 100644 --- a/routes/_app.tsx +++ b/routes/_app.tsx @@ -1,8 +1,14 @@ import { FreshContext } from "$fresh/server.ts"; import { Partial } from "$fresh/runtime.ts"; +import { State } from "./_middleware.ts"; +import Header from "./(_components)/Header.tsx"; +import Footer from "./(_components)/Footer.tsx"; - -export default async function App(request: Request, context: FreshContext) { +// deno-lint-ignore require-await +export default async function App( + _request: Request, + context: FreshContext, +) { const link = context.state.isAuthenticated ? "out" : "in"; return ( @@ -11,23 +17,19 @@ export default async function App(request: Request, context: FreshContext) { PolyMPR + + -
-

PolyMPR

- -
- - - -
-

© 2025 PolyMPR - About

-
+
+
+ + + +
+