}
export interface ScopeMember {
diff --git a/frontend/src/lib/models/stat.ts b/frontend/src/lib/models/stat.ts
index ddbf114..b5f2175 100644
--- a/frontend/src/lib/models/stat.ts
+++ b/frontend/src/lib/models/stat.ts
@@ -18,35 +18,3 @@ export interface StatAggregate {
acquired: number
required: number
}
-
-const EXAMPLE2: Stat = {
- id: 12,
- name: "Assets",
- description: "The amount of 'assets' produced in the end. This does not contribute towards the weight",
- weight: 0,
-}
-
-const EXAMPLE3: Stat = {
- id: 12,
- name: "Hard Surface Practice",
- description: "A value of the asset complexity, indicating how much general modeling practice is involved.",
- weight: 0.5,
- allowedAmounts: {
- "Rote": 1,
- "Novel": 2,
- "Tutorial": 4,
- "Difficult": 7,
- }
-}
-
-const EXAMPLE: Stat = {
- id: 12,
- name: "Complexity Points",
- description: "A value of the asset complexity, indicating how much general modeling practice is involved.",
- weight: 1,
- allowedAmounts: {
- "Small": 1,
- "Moderate": 3,
- "Complex": 7,
- }
-}
\ No newline at end of file
diff --git a/frontend/src/lib/utils/slugify.ts b/frontend/src/lib/utils/slugify.ts
new file mode 100644
index 0000000..70c69aa
--- /dev/null
+++ b/frontend/src/lib/utils/slugify.ts
@@ -0,0 +1,13 @@
+export default function sluggify(s: string): string {
+ let out = "";
+
+ for (const c of s.toLocaleLowerCase()) {
+ if (c >= 'a' && c <= 'z') {
+ out += c;
+ } else if (!":'".includes(c)) {
+ out += "-";
+ }
+ }
+
+ return out;
+}
diff --git a/frontend/src/routes/[scope].json.ts b/frontend/src/routes/[scope].json.ts
deleted file mode 100644
index dd586d2..0000000
--- a/frontend/src/routes/[scope].json.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import type { RequestHandler } from "@sveltejs/kit";
-
-import config from "$lib/config";
-
-export const get: RequestHandler = async({params, locals}) => {
- const scopeId = parseInt(params.scope);
-
- const db = await config.database();
- const scope = await db.withUser(locals.user.id).scopes().find(scopeId)
- if (scope === null) {
- return {
- status: 404,
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- message: "Scope not found",
- }),
- }
- }
-
- return {
- status: 200,
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- scope
- }),
- }
-}
diff --git a/frontend/src/routes/[scope]/__layout.svelte b/frontend/src/routes/[scope]/__layout.svelte
index 783496f..7e70ddd 100644
--- a/frontend/src/routes/[scope]/__layout.svelte
+++ b/frontend/src/routes/[scope]/__layout.svelte
@@ -2,22 +2,21 @@
import type { Load } from "@sveltejs/kit/types/internal";
export const load: Load = async({ fetch, params }) => {
- const res = await fetch(`/${params.scope}.json`);
+ try {
+ const res: {scope: Scope} = await fetch(`/api/scopes/${params.scope.split("-")[0]}`).then(r => r.json());
- if (res.ok) {
- const data = await res.json();
-
- return {
- props: {
- ...data,
+ return {
+ props: {
+ ...res,
},
stuff: {
- scope: data.scope,
+ scope: res.scope,
+ scopePath: params.scope,
}
- };
- }
+ };
+ } catch(_) {}
- return {fallthrough: true};
+ return {fallthrough: true} as any;
}
const STATUS_ORDER = [
@@ -38,6 +37,8 @@
import MenuCategory from "$lib/components/layout/MenuCategory.svelte";
import type { ProjectEntry } from "$lib/models/project";
import MenuItem from "$lib/components/layout/MenuItem.svelte";
+ import {page} from "$app/stores";
+import sluggify from "$lib/utils/slugify";
export let scope: Scope;
@@ -56,14 +57,14 @@
-
-
+
+
{#each STATUS_ORDER as status (status)}
{#if projectsByStatus[status].length > 0}
{#each projectsByStatus[status] as project (project.id)}
-