From 3fb2331ef011659f5b711d6563c60266b272eb15 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 12:49:36 +0200 Subject: [PATCH 01/10] dynamic route for comparison pages --- src/lib/commons/structures.ts | 4 ++++ src/lib/commons/types.ts | 1 + src/lib/server/fetchers/comparison.ts | 1 + src/lib/server/fetchers/structures.ts | 2 +- src/routes/[type]-comparison/+page.server.ts | 10 ++++++++++ .../+page.svelte | 2 +- .../[type]-comparison/[...ids]/+page.server.ts | 17 +++++++++++++++++ .../[...ids]/+page.svelte | 2 +- src/routes/category-comparison/+page.server.ts | 5 ----- src/routes/category-comparison/+page.svelte | 7 ------- .../[...ids]/+page.server.ts | 12 ------------ .../category-comparison/[...ids]/+page.svelte | 7 ------- src/routes/functor-comparison/+page.server.ts | 5 ----- .../functor-comparison/[...ids]/+page.server.ts | 12 ------------ src/routes/morphism-comparison/+page.server.ts | 5 ----- src/routes/morphism-comparison/+page.svelte | 7 ------- .../[...ids]/+page.server.ts | 12 ------------ .../morphism-comparison/[...ids]/+page.svelte | 7 ------- 18 files changed, 36 insertions(+), 82 deletions(-) create mode 100644 src/routes/[type]-comparison/+page.server.ts rename src/routes/{functor-comparison => [type]-comparison}/+page.svelte (72%) create mode 100644 src/routes/[type]-comparison/[...ids]/+page.server.ts rename src/routes/{functor-comparison => [type]-comparison}/[...ids]/+page.svelte (71%) delete mode 100644 src/routes/category-comparison/+page.server.ts delete mode 100644 src/routes/category-comparison/+page.svelte delete mode 100644 src/routes/category-comparison/[...ids]/+page.server.ts delete mode 100644 src/routes/category-comparison/[...ids]/+page.svelte delete mode 100644 src/routes/functor-comparison/+page.server.ts delete mode 100644 src/routes/functor-comparison/[...ids]/+page.server.ts delete mode 100644 src/routes/morphism-comparison/+page.server.ts delete mode 100644 src/routes/morphism-comparison/+page.svelte delete mode 100644 src/routes/morphism-comparison/[...ids]/+page.server.ts delete mode 100644 src/routes/morphism-comparison/[...ids]/+page.svelte diff --git a/src/lib/commons/structures.ts b/src/lib/commons/structures.ts index 37f9699ae..1767fe15f 100644 --- a/src/lib/commons/structures.ts +++ b/src/lib/commons/structures.ts @@ -2,6 +2,10 @@ import type { StructureType } from './types' export const STRUCTURES: StructureType[] = ['category', 'functor', 'morphism'] +export function is_structure_type(txt: string): txt is StructureType { + return (STRUCTURES as string[]).includes(txt) +} + export const PLURALS = { category: 'categories', functor: 'functors', diff --git a/src/lib/commons/types.ts b/src/lib/commons/types.ts index cc128c81c..969dc4ad9 100644 --- a/src/lib/commons/types.ts +++ b/src/lib/commons/types.ts @@ -145,4 +145,5 @@ export type SearchResults = { export type ComparisonResult = { structures: RelatedStructure[] comparison_table: string[][] + type: StructureType } diff --git a/src/lib/server/fetchers/comparison.ts b/src/lib/server/fetchers/comparison.ts index 23b56cb02..355988889 100644 --- a/src/lib/server/fetchers/comparison.ts +++ b/src/lib/server/fetchers/comparison.ts @@ -89,5 +89,6 @@ export function fetch_comparison_result( return { structures: render_nested_formulas(structures), comparison_table, + type, } } diff --git a/src/lib/server/fetchers/structures.ts b/src/lib/server/fetchers/structures.ts index cc60c6bc8..dd3d4577a 100644 --- a/src/lib/server/fetchers/structures.ts +++ b/src/lib/server/fetchers/structures.ts @@ -15,7 +15,7 @@ export function fetch_structures(type: StructureType) { if (err) error(500, `${capitalize(PLURALS[type])} could not be loaded`) - return { structures } + return { structures, type } } export function fetch_structures_and_tags(type: StructureType) { diff --git a/src/routes/[type]-comparison/+page.server.ts b/src/routes/[type]-comparison/+page.server.ts new file mode 100644 index 000000000..6164bf3ce --- /dev/null +++ b/src/routes/[type]-comparison/+page.server.ts @@ -0,0 +1,10 @@ +import { is_structure_type } from '$lib/commons/structures' +import { fetch_structures } from '$lib/server/fetchers/structures' +import { error } from '@sveltejs/kit' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return fetch_structures(type) +} diff --git a/src/routes/functor-comparison/+page.svelte b/src/routes/[type]-comparison/+page.svelte similarity index 72% rename from src/routes/functor-comparison/+page.svelte rename to src/routes/[type]-comparison/+page.svelte index a572a205c..c7bb8f51d 100644 --- a/src/routes/functor-comparison/+page.svelte +++ b/src/routes/[type]-comparison/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/[type]-comparison/[...ids]/+page.server.ts b/src/routes/[type]-comparison/[...ids]/+page.server.ts new file mode 100644 index 000000000..326717db7 --- /dev/null +++ b/src/routes/[type]-comparison/[...ids]/+page.server.ts @@ -0,0 +1,17 @@ +import { is_structure_type } from '$lib/commons/structures' +import { fetch_comparison_result } from '$lib/server/fetchers/comparison' +import { cache_page } from '$lib/server/utils' +import { error } from '@sveltejs/kit' + +export const prerender = false + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + const compared_ids = event.params.ids.split('/') + + return fetch_comparison_result(compared_ids, type, () => { + cache_page(event) + }) +} diff --git a/src/routes/functor-comparison/[...ids]/+page.svelte b/src/routes/[type]-comparison/[...ids]/+page.svelte similarity index 71% rename from src/routes/functor-comparison/[...ids]/+page.svelte rename to src/routes/[type]-comparison/[...ids]/+page.svelte index e942fb34b..bc78c0081 100644 --- a/src/routes/functor-comparison/[...ids]/+page.svelte +++ b/src/routes/[type]-comparison/[...ids]/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/category-comparison/+page.server.ts b/src/routes/category-comparison/+page.server.ts deleted file mode 100644 index 5095734eb..000000000 --- a/src/routes/category-comparison/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures('category') -} diff --git a/src/routes/category-comparison/+page.svelte b/src/routes/category-comparison/+page.svelte deleted file mode 100644 index e09ee6646..000000000 --- a/src/routes/category-comparison/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/category-comparison/[...ids]/+page.server.ts b/src/routes/category-comparison/[...ids]/+page.server.ts deleted file mode 100644 index 8b747a9c7..000000000 --- a/src/routes/category-comparison/[...ids]/+page.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { fetch_comparison_result } from '$lib/server/fetchers/comparison' -import { cache_page } from '$lib/server/utils' - -export const prerender = false - -export const load = (event) => { - const compared_ids = event.params.ids.split('/') - - return fetch_comparison_result(compared_ids, 'category', () => { - cache_page(event) - }) -} diff --git a/src/routes/category-comparison/[...ids]/+page.svelte b/src/routes/category-comparison/[...ids]/+page.svelte deleted file mode 100644 index e1fd975e3..000000000 --- a/src/routes/category-comparison/[...ids]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/functor-comparison/+page.server.ts b/src/routes/functor-comparison/+page.server.ts deleted file mode 100644 index b26dc673b..000000000 --- a/src/routes/functor-comparison/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures('functor') -} diff --git a/src/routes/functor-comparison/[...ids]/+page.server.ts b/src/routes/functor-comparison/[...ids]/+page.server.ts deleted file mode 100644 index 637158805..000000000 --- a/src/routes/functor-comparison/[...ids]/+page.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { fetch_comparison_result } from '$lib/server/fetchers/comparison' -import { cache_page } from '$lib/server/utils' - -export const prerender = false - -export const load = (event) => { - const compared_ids = event.params.ids.split('/') - - return fetch_comparison_result(compared_ids, 'functor', () => { - cache_page(event) - }) -} diff --git a/src/routes/morphism-comparison/+page.server.ts b/src/routes/morphism-comparison/+page.server.ts deleted file mode 100644 index 27b026bc8..000000000 --- a/src/routes/morphism-comparison/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures('morphism') -} diff --git a/src/routes/morphism-comparison/+page.svelte b/src/routes/morphism-comparison/+page.svelte deleted file mode 100644 index 626b192e5..000000000 --- a/src/routes/morphism-comparison/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/morphism-comparison/[...ids]/+page.server.ts b/src/routes/morphism-comparison/[...ids]/+page.server.ts deleted file mode 100644 index 12443fd9b..000000000 --- a/src/routes/morphism-comparison/[...ids]/+page.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { fetch_comparison_result } from '$lib/server/fetchers/comparison' -import { cache_page } from '$lib/server/utils' - -export const prerender = false - -export const load = (event) => { - const compared_ids = event.params.ids.split('/') - - return fetch_comparison_result(compared_ids, 'morphism', () => { - cache_page(event) - }) -} diff --git a/src/routes/morphism-comparison/[...ids]/+page.svelte b/src/routes/morphism-comparison/[...ids]/+page.svelte deleted file mode 100644 index 11f4d1e6f..000000000 --- a/src/routes/morphism-comparison/[...ids]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - From 7f297224f96ed78a2708ea8803f13ee666c221fe Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 12:51:40 +0200 Subject: [PATCH 02/10] dynamic route for search pages --- src/lib/commons/types.ts | 1 + src/lib/server/fetchers/search.ts | 2 ++ src/routes/[type]-search/+page.server.ts | 10 ++++++++++ src/routes/[type]-search/+page.svelte | 18 ++++++++++++++++++ .../results/+page.server.ts | 7 ++++++- .../results/+page.svelte | 2 +- src/routes/category-search/+page.server.ts | 5 ----- src/routes/category-search/+page.svelte | 13 ------------- .../category-search/results/+page.server.ts | 13 ------------- .../category-search/results/+page.svelte | 7 ------- src/routes/functor-search/+page.server.ts | 5 ----- src/routes/functor-search/+page.svelte | 12 ------------ .../functor-search/results/+page.server.ts | 13 ------------- src/routes/morphism-search/+page.server.ts | 5 ----- src/routes/morphism-search/+page.svelte | 13 ------------- .../morphism-search/results/+page.svelte | 7 ------- 16 files changed, 38 insertions(+), 95 deletions(-) create mode 100644 src/routes/[type]-search/+page.server.ts create mode 100644 src/routes/[type]-search/+page.svelte rename src/routes/{morphism-search => [type]-search}/results/+page.server.ts (64%) rename src/routes/{functor-search => [type]-search}/results/+page.svelte (72%) delete mode 100644 src/routes/category-search/+page.server.ts delete mode 100644 src/routes/category-search/+page.svelte delete mode 100644 src/routes/category-search/results/+page.server.ts delete mode 100644 src/routes/category-search/results/+page.svelte delete mode 100644 src/routes/functor-search/+page.server.ts delete mode 100644 src/routes/functor-search/+page.svelte delete mode 100644 src/routes/functor-search/results/+page.server.ts delete mode 100644 src/routes/morphism-search/+page.server.ts delete mode 100644 src/routes/morphism-search/+page.svelte delete mode 100644 src/routes/morphism-search/results/+page.svelte diff --git a/src/lib/commons/types.ts b/src/lib/commons/types.ts index 969dc4ad9..b1fe52ec6 100644 --- a/src/lib/commons/types.ts +++ b/src/lib/commons/types.ts @@ -140,6 +140,7 @@ export type SearchResults = { dual_unsatisfied_properties: (string | null)[] dual_search_available: boolean found_structures: StructureShort[] + type: StructureType } export type ComparisonResult = { diff --git a/src/lib/server/fetchers/search.ts b/src/lib/server/fetchers/search.ts index 42eb75ee2..30945ae3a 100644 --- a/src/lib/server/fetchers/search.ts +++ b/src/lib/server/fetchers/search.ts @@ -90,6 +90,7 @@ export function fetch_search_results( dual_unsatisfied_properties, dual_search_available, found_structures: [], + type, } } @@ -147,5 +148,6 @@ export function fetch_search_results( dual_unsatisfied_properties, dual_search_available, found_structures, + type, } } diff --git a/src/routes/[type]-search/+page.server.ts b/src/routes/[type]-search/+page.server.ts new file mode 100644 index 000000000..3bdfc3016 --- /dev/null +++ b/src/routes/[type]-search/+page.server.ts @@ -0,0 +1,10 @@ +import { is_structure_type } from '$lib/commons/structures' +import { get_property_ids } from '$lib/server/fetchers/properties' +import { error } from '@sveltejs/kit' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return { all_properties: get_property_ids(type), type } +} diff --git a/src/routes/[type]-search/+page.svelte b/src/routes/[type]-search/+page.svelte new file mode 100644 index 000000000..618df053b --- /dev/null +++ b/src/routes/[type]-search/+page.svelte @@ -0,0 +1,18 @@ + + + + {@html SAMPLES[data.type]} + diff --git a/src/routes/morphism-search/results/+page.server.ts b/src/routes/[type]-search/results/+page.server.ts similarity index 64% rename from src/routes/morphism-search/results/+page.server.ts rename to src/routes/[type]-search/results/+page.server.ts index 390cfa6bd..e6b4e2a6f 100644 --- a/src/routes/morphism-search/results/+page.server.ts +++ b/src/routes/[type]-search/results/+page.server.ts @@ -1,13 +1,18 @@ +import { is_structure_type } from '$lib/commons/structures' import { fetch_search_results } from '$lib/server/fetchers/search' import { cache_page } from '$lib/server/utils' +import { error } from '@sveltejs/kit' export const prerender = false export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + const satisfied_query = event.url.searchParams.get('satisfied') const unsatisfied_query = event.url.searchParams.get('unsatisfied') - return fetch_search_results(satisfied_query, unsatisfied_query, 'morphism', () => + return fetch_search_results(satisfied_query, unsatisfied_query, type, () => cache_page(event), ) } diff --git a/src/routes/functor-search/results/+page.svelte b/src/routes/[type]-search/results/+page.svelte similarity index 72% rename from src/routes/functor-search/results/+page.svelte rename to src/routes/[type]-search/results/+page.svelte index 44516cde3..3ac493da3 100644 --- a/src/routes/functor-search/results/+page.svelte +++ b/src/routes/[type]-search/results/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/category-search/+page.server.ts b/src/routes/category-search/+page.server.ts deleted file mode 100644 index 1d5908868..000000000 --- a/src/routes/category-search/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { get_property_ids } from '$lib/server/fetchers/properties' - -export const load = () => { - return { all_properties: get_property_ids('category') } -} diff --git a/src/routes/category-search/+page.svelte b/src/routes/category-search/+page.svelte deleted file mode 100644 index 083471823..000000000 --- a/src/routes/category-search/+page.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - - - Search for categories with certain properties while excluding others. For example, you - can look for categories that are finitely complete and pointed - but not complete. - diff --git a/src/routes/category-search/results/+page.server.ts b/src/routes/category-search/results/+page.server.ts deleted file mode 100644 index 0646162d4..000000000 --- a/src/routes/category-search/results/+page.server.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { fetch_search_results } from '$lib/server/fetchers/search' -import { cache_page } from '$lib/server/utils' - -export const prerender = false - -export const load = (event) => { - const satisfied_query = event.url.searchParams.get('satisfied') - const unsatisfied_query = event.url.searchParams.get('unsatisfied') - - return fetch_search_results(satisfied_query, unsatisfied_query, 'category', () => - cache_page(event), - ) -} diff --git a/src/routes/category-search/results/+page.svelte b/src/routes/category-search/results/+page.svelte deleted file mode 100644 index 44712f45e..000000000 --- a/src/routes/category-search/results/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/functor-search/+page.server.ts b/src/routes/functor-search/+page.server.ts deleted file mode 100644 index 6aa4f890b..000000000 --- a/src/routes/functor-search/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { get_property_ids } from '$lib/server/fetchers/properties' - -export const load = () => { - return { all_properties: get_property_ids('functor') } -} diff --git a/src/routes/functor-search/+page.svelte b/src/routes/functor-search/+page.svelte deleted file mode 100644 index e174c391d..000000000 --- a/src/routes/functor-search/+page.svelte +++ /dev/null @@ -1,12 +0,0 @@ - - - - Search for functors with certain properties while excluding others. For example, you - can look for functors that are continuous but not cocontinuous. - diff --git a/src/routes/functor-search/results/+page.server.ts b/src/routes/functor-search/results/+page.server.ts deleted file mode 100644 index d5acdfd57..000000000 --- a/src/routes/functor-search/results/+page.server.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { fetch_search_results } from '$lib/server/fetchers/search' -import { cache_page } from '$lib/server/utils' - -export const prerender = false - -export const load = (event) => { - const satisfied_query = event.url.searchParams.get('satisfied') - const unsatisfied_query = event.url.searchParams.get('unsatisfied') - - return fetch_search_results(satisfied_query, unsatisfied_query, 'functor', () => - cache_page(event), - ) -} diff --git a/src/routes/morphism-search/+page.server.ts b/src/routes/morphism-search/+page.server.ts deleted file mode 100644 index 6ba761c34..000000000 --- a/src/routes/morphism-search/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { get_property_ids } from '$lib/server/fetchers/properties' - -export const load = () => { - return { all_properties: get_property_ids('morphism') } -} diff --git a/src/routes/morphism-search/+page.svelte b/src/routes/morphism-search/+page.svelte deleted file mode 100644 index d62dc5d32..000000000 --- a/src/routes/morphism-search/+page.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - - - Search for morphism with certain properties while excluding others. For example, you - can look for morphisms which are monomorphisms and epimorphisms, - but no isomorphisms. - diff --git a/src/routes/morphism-search/results/+page.svelte b/src/routes/morphism-search/results/+page.svelte deleted file mode 100644 index 2a2557f43..000000000 --- a/src/routes/morphism-search/results/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - From 20b3fe1e892125d653e85b7e8bfb85cfc8812d9e Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 13:01:19 +0200 Subject: [PATCH 03/10] dynamic route for implication pages --- src/lib/server/fetchers/implication.ts | 2 +- src/lib/server/fetchers/implications.ts | 2 +- .../[type]-implication/[id]/+page.server.ts | 13 +++++ .../[id]/+page.svelte | 2 +- .../[type]-implications/+page.server.ts | 11 ++++ src/routes/[type]-implications/+page.svelte | 57 +++++++++++++++++++ .../category-implication/[id]/+page.server.ts | 8 --- .../category-implication/[id]/+page.svelte | 7 --- .../category-implications/+page.server.ts | 8 --- src/routes/category-implications/+page.svelte | 36 ------------ .../functor-implication/[id]/+page.server.ts | 8 --- .../functor-implications/+page.server.ts | 8 --- src/routes/functor-implications/+page.svelte | 26 --------- .../morphism-implication/[id]/+page.server.ts | 8 --- .../morphism-implication/[id]/+page.svelte | 7 --- .../morphism-implications/+page.server.ts | 8 --- src/routes/morphism-implications/+page.svelte | 15 ----- 17 files changed, 84 insertions(+), 142 deletions(-) create mode 100644 src/routes/[type]-implication/[id]/+page.server.ts rename src/routes/{functor-implication => [type]-implication}/[id]/+page.svelte (72%) create mode 100644 src/routes/[type]-implications/+page.server.ts create mode 100644 src/routes/[type]-implications/+page.svelte delete mode 100644 src/routes/category-implication/[id]/+page.server.ts delete mode 100644 src/routes/category-implication/[id]/+page.svelte delete mode 100644 src/routes/category-implications/+page.server.ts delete mode 100644 src/routes/category-implications/+page.svelte delete mode 100644 src/routes/functor-implication/[id]/+page.server.ts delete mode 100644 src/routes/functor-implications/+page.server.ts delete mode 100644 src/routes/functor-implications/+page.svelte delete mode 100644 src/routes/morphism-implication/[id]/+page.server.ts delete mode 100644 src/routes/morphism-implication/[id]/+page.svelte delete mode 100644 src/routes/morphism-implications/+page.server.ts delete mode 100644 src/routes/morphism-implications/+page.svelte diff --git a/src/lib/server/fetchers/implication.ts b/src/lib/server/fetchers/implication.ts index f96267c72..f664fb9d6 100644 --- a/src/lib/server/fetchers/implication.ts +++ b/src/lib/server/fetchers/implication.ts @@ -57,5 +57,5 @@ export function fetch_implication(type: StructureType, id: string) { mapped_types[map] = mapped_type } - return { implication, structures, mapped_types } + return { type, implication, structures, mapped_types } } diff --git a/src/lib/server/fetchers/implications.ts b/src/lib/server/fetchers/implications.ts index 594cbd0fb..9be1cca68 100644 --- a/src/lib/server/fetchers/implications.ts +++ b/src/lib/server/fetchers/implications.ts @@ -29,7 +29,7 @@ export function fetch_implications(type: StructureType) { const implications = rows.map(display_implication) - return { implications } + return { type, implications } } /** diff --git a/src/routes/[type]-implication/[id]/+page.server.ts b/src/routes/[type]-implication/[id]/+page.server.ts new file mode 100644 index 000000000..5dc67fa23 --- /dev/null +++ b/src/routes/[type]-implication/[id]/+page.server.ts @@ -0,0 +1,13 @@ +import { is_structure_type } from '$lib/commons/structures' +import { fetch_implication } from '$lib/server/fetchers/implication' +import { render_nested_formulas } from '$lib/server/formulas' +import { error } from '@sveltejs/kit' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + const id = event.params.id + + return render_nested_formulas(fetch_implication(type, id)) +} diff --git a/src/routes/functor-implication/[id]/+page.svelte b/src/routes/[type]-implication/[id]/+page.svelte similarity index 72% rename from src/routes/functor-implication/[id]/+page.svelte rename to src/routes/[type]-implication/[id]/+page.svelte index e3588dd4e..a934b737e 100644 --- a/src/routes/functor-implication/[id]/+page.svelte +++ b/src/routes/[type]-implication/[id]/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/[type]-implications/+page.server.ts b/src/routes/[type]-implications/+page.server.ts new file mode 100644 index 000000000..d8e406583 --- /dev/null +++ b/src/routes/[type]-implications/+page.server.ts @@ -0,0 +1,11 @@ +import { render_nested_formulas } from '$lib/server/formulas' +import { fetch_implications } from '$lib/server/fetchers/implications' +import { is_structure_type } from '$lib/commons/structures' +import { error } from '@sveltejs/kit' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return render_nested_formulas(fetch_implications(type)) +} diff --git a/src/routes/[type]-implications/+page.svelte b/src/routes/[type]-implications/+page.svelte new file mode 100644 index 000000000..c3ba82ca5 --- /dev/null +++ b/src/routes/[type]-implications/+page.svelte @@ -0,0 +1,57 @@ + + + + {#snippet hints()} + {#if data.type === 'category'} +

+ *Deductions from these implications are automatically incorporated into + each category whenever applicable. For instance, if a category is + identified as complete, the property of having a terminal object is + automatically inferred and added. +

+ +

+ Implications can be combined to yield longer, non-obvious deductions that + are not explicitly listed above. For example, the listed implications + imply that every inhabited groupoid with binary products is trivial. +

+ +

+ Moreover, implications are automatically dualized when the corresponding + dual properties exist. For example, the statement that finitely complete + categories with cofiltered limits are complete automatically implies that + finitely cocomplete categories with filtered colimits are cocomplete. + Similarly, if a category is self-dual and, for example, complete, it is + automatically inferred to be cocomplete as well. +

+ {:else if data.type === 'functor'} +

+ *Deductions from these implications are automatically incorporated into + each functor whenever applicable. For instance, if a functor is identified + as monadic, the property of being continuous is automatically inferred and + added. +

+ +

+ Moreover, implications are automatically dualized when the corresponding + dual properties exist. For example, the statement that a right adjoint is + continuous automatically implies that a left adjoint is cocontinuous. +

+ {:else if data.type === 'morphism'} +

+ *Deductions from these implications are automatically incorporated into + each morphism whenever applicable. Moreover, implications are + automatically dualized when the corresponding dual properties exist. +

+ {/if} + +

+ For results that do not quite fit the implication model, + content pages are used instead. +

+ {/snippet} +
diff --git a/src/routes/category-implication/[id]/+page.server.ts b/src/routes/category-implication/[id]/+page.server.ts deleted file mode 100644 index 0483fd870..000000000 --- a/src/routes/category-implication/[id]/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { fetch_implication } from '$lib/server/fetchers/implication' -import { render_nested_formulas } from '$lib/server/formulas' - -export const load = (event) => { - const id = event.params.id - - return render_nested_formulas(fetch_implication('category', id)) -} diff --git a/src/routes/category-implication/[id]/+page.svelte b/src/routes/category-implication/[id]/+page.svelte deleted file mode 100644 index af2c4f39c..000000000 --- a/src/routes/category-implication/[id]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/category-implications/+page.server.ts b/src/routes/category-implications/+page.server.ts deleted file mode 100644 index 2b5992bed..000000000 --- a/src/routes/category-implications/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { fetch_implications } from '$lib/server/fetchers/implications' - -export const load = () => { - const { implications } = fetch_implications('category') - - return render_nested_formulas({ implications }) -} diff --git a/src/routes/category-implications/+page.svelte b/src/routes/category-implications/+page.svelte deleted file mode 100644 index e0e57b85a..000000000 --- a/src/routes/category-implications/+page.svelte +++ /dev/null @@ -1,36 +0,0 @@ - - - - {#snippet hints()} -

- *Deductions from these implications are automatically incorporated into each - category whenever applicable. For instance, if a category is identified as - complete, the property of having a terminal object is automatically inferred - and added. -

- -

- Implications can be combined to yield longer, non-obvious deductions that are - not explicitly listed above. For example, the listed implications imply that - every inhabited groupoid with binary products is trivial. -

- -

- Moreover, implications are automatically dualized when the corresponding dual - properties exist. For example, the statement that finitely complete categories - with cofiltered limits are complete automatically implies that finitely - cocomplete categories with filtered colimits are cocomplete. Similarly, if a - category is self-dual and, for example, complete, it is automatically inferred - to be cocomplete as well. -

- -

- For results that do not quite fit the implication model, - content pages are used instead. -

- {/snippet} -
diff --git a/src/routes/functor-implication/[id]/+page.server.ts b/src/routes/functor-implication/[id]/+page.server.ts deleted file mode 100644 index 8136bece3..000000000 --- a/src/routes/functor-implication/[id]/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { fetch_implication } from '$lib/server/fetchers/implication' -import { render_nested_formulas } from '$lib/server/formulas' - -export const load = (event) => { - const id = event.params.id - - return render_nested_formulas(fetch_implication('functor', id)) -} diff --git a/src/routes/functor-implications/+page.server.ts b/src/routes/functor-implications/+page.server.ts deleted file mode 100644 index b234154c8..000000000 --- a/src/routes/functor-implications/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { fetch_implications } from '$lib/server/fetchers/implications' - -export const load = () => { - const { implications } = fetch_implications('functor') - - return render_nested_formulas({ implications }) -} diff --git a/src/routes/functor-implications/+page.svelte b/src/routes/functor-implications/+page.svelte deleted file mode 100644 index beb32efa4..000000000 --- a/src/routes/functor-implications/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - - - {#snippet hints()} -

- *Deductions from these implications are automatically incorporated into each - functor whenever applicable. For instance, if a functor is identified as - monadic, the property of being continuous is automatically inferred and added. -

- -

- Moreover, implications are automatically dualized when the corresponding dual - properties exist. For example, the statement that a right adjoint is - continuous automatically implies that a left adjoint is cocontinuous. -

- -

- For results that do not quite fit the implication model, - content pages are used instead. -

- {/snippet} -
diff --git a/src/routes/morphism-implication/[id]/+page.server.ts b/src/routes/morphism-implication/[id]/+page.server.ts deleted file mode 100644 index bb302106c..000000000 --- a/src/routes/morphism-implication/[id]/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { fetch_implication } from '$lib/server/fetchers/implication' -import { render_nested_formulas } from '$lib/server/formulas' - -export const load = (event) => { - const id = event.params.id - - return render_nested_formulas(fetch_implication('morphism', id)) -} diff --git a/src/routes/morphism-implication/[id]/+page.svelte b/src/routes/morphism-implication/[id]/+page.svelte deleted file mode 100644 index a97e46ffd..000000000 --- a/src/routes/morphism-implication/[id]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/morphism-implications/+page.server.ts b/src/routes/morphism-implications/+page.server.ts deleted file mode 100644 index c3c4e42b8..000000000 --- a/src/routes/morphism-implications/+page.server.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { fetch_implications } from '$lib/server/fetchers/implications' - -export const load = () => { - const { implications } = fetch_implications('morphism') - - return render_nested_formulas({ implications }) -} diff --git a/src/routes/morphism-implications/+page.svelte b/src/routes/morphism-implications/+page.svelte deleted file mode 100644 index fd3605ac0..000000000 --- a/src/routes/morphism-implications/+page.svelte +++ /dev/null @@ -1,15 +0,0 @@ - - - - {#snippet hints()} -

- *Deductions from these implications are automatically incorporated into each - morphism whenever applicable. Moreover, implications are automatically - dualized when the corresponding dual properties exist. -

- {/snippet} -
From f2bc60898283dc06d05c496d79512fe408bc6836 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 13:12:24 +0200 Subject: [PATCH 04/10] dynamic route for property pages --- src/lib/server/fetchers/properties.ts | 4 ++-- src/lib/server/fetchers/property.ts | 1 + src/routes/[type]-properties/+page.server.ts | 10 ++++++++++ .../+page.svelte | 2 +- src/routes/[type]-properties/[tag]/+page.server.ts | 12 ++++++++++++ .../[tag]/+page.svelte | 2 +- .../[id]/+page.server.ts | 9 ++++++--- .../[id]/+page.svelte | 2 +- src/routes/category-properties/+page.server.ts | 5 ----- src/routes/category-properties/+page.svelte | 7 ------- src/routes/category-properties/[tag]/+page.server.ts | 11 ----------- src/routes/category-properties/[tag]/+page.svelte | 7 ------- src/routes/category-property/[id]/+page.server.ts | 11 ----------- src/routes/category-property/[id]/+page.svelte | 7 ------- src/routes/functor-properties/+page.server.ts | 5 ----- src/routes/functor-properties/[tag]/+page.server.ts | 11 ----------- src/routes/functor-property/[id]/+page.server.ts | 11 ----------- src/routes/morphism-properties/+page.server.ts | 5 ----- src/routes/morphism-properties/+page.svelte | 7 ------- src/routes/morphism-properties/[tag]/+page.server.ts | 11 ----------- src/routes/morphism-properties/[tag]/+page.svelte | 7 ------- src/routes/morphism-property/[id]/+page.svelte | 7 ------- 22 files changed, 34 insertions(+), 120 deletions(-) create mode 100644 src/routes/[type]-properties/+page.server.ts rename src/routes/{functor-properties => [type]-properties}/+page.svelte (72%) create mode 100644 src/routes/[type]-properties/[tag]/+page.server.ts rename src/routes/{functor-properties => [type]-properties}/[tag]/+page.svelte (71%) rename src/routes/{morphism-property => [type]-property}/[id]/+page.server.ts (50%) rename src/routes/{functor-property => [type]-property}/[id]/+page.svelte (72%) delete mode 100644 src/routes/category-properties/+page.server.ts delete mode 100644 src/routes/category-properties/+page.svelte delete mode 100644 src/routes/category-properties/[tag]/+page.server.ts delete mode 100644 src/routes/category-properties/[tag]/+page.svelte delete mode 100644 src/routes/category-property/[id]/+page.server.ts delete mode 100644 src/routes/category-property/[id]/+page.svelte delete mode 100644 src/routes/functor-properties/+page.server.ts delete mode 100644 src/routes/functor-properties/[tag]/+page.server.ts delete mode 100644 src/routes/functor-property/[id]/+page.server.ts delete mode 100644 src/routes/morphism-properties/+page.server.ts delete mode 100644 src/routes/morphism-properties/+page.svelte delete mode 100644 src/routes/morphism-properties/[tag]/+page.server.ts delete mode 100644 src/routes/morphism-properties/[tag]/+page.svelte delete mode 100644 src/routes/morphism-property/[id]/+page.svelte diff --git a/src/lib/server/fetchers/properties.ts b/src/lib/server/fetchers/properties.ts index 3c90e8da2..879509291 100644 --- a/src/lib/server/fetchers/properties.ts +++ b/src/lib/server/fetchers/properties.ts @@ -75,7 +75,7 @@ export function fetch_grouped_properties_and_tags(type: StructureType) { const total = properties.length const grouped_total = grouped_properties.length - return { grouped_properties, total, grouped_total, tags } + return { type, grouped_properties, total, grouped_total, tags } } export function fetch_tagged_properties(type: StructureType, tag: string) { @@ -90,5 +90,5 @@ export function fetch_tagged_properties(type: StructureType, tag: string) { if (err) error(500, `Properties could not be loaded`) - return { properties, tag } + return { type, properties, tag } } diff --git a/src/lib/server/fetchers/property.ts b/src/lib/server/fetchers/property.ts index 105c92121..56aeec955 100644 --- a/src/lib/server/fetchers/property.ts +++ b/src/lib/server/fetchers/property.ts @@ -135,6 +135,7 @@ export function fetch_property(type: StructureType, id: string) { } return { + type, property, related_properties, tags, diff --git a/src/routes/[type]-properties/+page.server.ts b/src/routes/[type]-properties/+page.server.ts new file mode 100644 index 000000000..c9b3687fe --- /dev/null +++ b/src/routes/[type]-properties/+page.server.ts @@ -0,0 +1,10 @@ +import { is_structure_type } from '$lib/commons/structures' +import { fetch_grouped_properties_and_tags } from '$lib/server/fetchers/properties' +import { error } from '@sveltejs/kit' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return fetch_grouped_properties_and_tags(type) +} diff --git a/src/routes/functor-properties/+page.svelte b/src/routes/[type]-properties/+page.svelte similarity index 72% rename from src/routes/functor-properties/+page.svelte rename to src/routes/[type]-properties/+page.svelte index 3e22335dd..cffd0f300 100644 --- a/src/routes/functor-properties/+page.svelte +++ b/src/routes/[type]-properties/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/[type]-properties/[tag]/+page.server.ts b/src/routes/[type]-properties/[tag]/+page.server.ts new file mode 100644 index 000000000..180767c04 --- /dev/null +++ b/src/routes/[type]-properties/[tag]/+page.server.ts @@ -0,0 +1,12 @@ +import { is_structure_type } from '$lib/commons/structures' +import { fetch_tagged_properties } from '$lib/server/fetchers/properties' +import { error } from '@sveltejs/kit' + +export const prerender = false // FIXME + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return fetch_tagged_properties(type, event.params.tag) +} diff --git a/src/routes/functor-properties/[tag]/+page.svelte b/src/routes/[type]-properties/[tag]/+page.svelte similarity index 71% rename from src/routes/functor-properties/[tag]/+page.svelte rename to src/routes/[type]-properties/[tag]/+page.svelte index 8804e18da..9c826c824 100644 --- a/src/routes/functor-properties/[tag]/+page.svelte +++ b/src/routes/[type]-properties/[tag]/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/morphism-property/[id]/+page.server.ts b/src/routes/[type]-property/[id]/+page.server.ts similarity index 50% rename from src/routes/morphism-property/[id]/+page.server.ts rename to src/routes/[type]-property/[id]/+page.server.ts index 3ce350d54..bd418f1dc 100644 --- a/src/routes/morphism-property/[id]/+page.server.ts +++ b/src/routes/[type]-property/[id]/+page.server.ts @@ -1,11 +1,14 @@ import { render_nested_formulas } from '$lib/server/formulas' import { decode_property_ID } from '$lib/commons/property.url' import { fetch_property } from '$lib/server/fetchers/property' +import { is_structure_type } from '$lib/commons/structures' +import { error } from '@sveltejs/kit' export const load = (event) => { - const id = decode_property_ID(event.params.id) + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) - const property_data = fetch_property('morphism', id) + const id = decode_property_ID(event.params.id) - return render_nested_formulas(property_data) + return render_nested_formulas(fetch_property(type, id)) } diff --git a/src/routes/functor-property/[id]/+page.svelte b/src/routes/[type]-property/[id]/+page.svelte similarity index 72% rename from src/routes/functor-property/[id]/+page.svelte rename to src/routes/[type]-property/[id]/+page.svelte index 5ac5a3d01..872796c41 100644 --- a/src/routes/functor-property/[id]/+page.svelte +++ b/src/routes/[type]-property/[id]/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/category-properties/+page.server.ts b/src/routes/category-properties/+page.server.ts deleted file mode 100644 index da7dc35a3..000000000 --- a/src/routes/category-properties/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_grouped_properties_and_tags } from '$lib/server/fetchers/properties' - -export const load = () => { - return fetch_grouped_properties_and_tags('category') -} diff --git a/src/routes/category-properties/+page.svelte b/src/routes/category-properties/+page.svelte deleted file mode 100644 index 72c16cdd3..000000000 --- a/src/routes/category-properties/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/category-properties/[tag]/+page.server.ts b/src/routes/category-properties/[tag]/+page.server.ts deleted file mode 100644 index 3c7531a70..000000000 --- a/src/routes/category-properties/[tag]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { fetch_tagged_properties } from '$lib/server/fetchers/properties' -import { fetch_property_tags } from '$lib/server/fetchers/tags' -import type { EntryGenerator } from './$types' - -export const entries: EntryGenerator = () => { - return fetch_property_tags('category') -} - -export const load = (event) => { - return fetch_tagged_properties('category', event.params.tag) -} diff --git a/src/routes/category-properties/[tag]/+page.svelte b/src/routes/category-properties/[tag]/+page.svelte deleted file mode 100644 index dbd54b293..000000000 --- a/src/routes/category-properties/[tag]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/category-property/[id]/+page.server.ts b/src/routes/category-property/[id]/+page.server.ts deleted file mode 100644 index f6b3b19d2..000000000 --- a/src/routes/category-property/[id]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { decode_property_ID } from '$lib/commons/property.url' -import { fetch_property } from '$lib/server/fetchers/property' - -export const load = (event) => { - const id = decode_property_ID(event.params.id) - - const property_data = fetch_property('category', id) - - return render_nested_formulas(property_data) -} diff --git a/src/routes/category-property/[id]/+page.svelte b/src/routes/category-property/[id]/+page.svelte deleted file mode 100644 index a031bd741..000000000 --- a/src/routes/category-property/[id]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/functor-properties/+page.server.ts b/src/routes/functor-properties/+page.server.ts deleted file mode 100644 index 2e0797ff6..000000000 --- a/src/routes/functor-properties/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_grouped_properties_and_tags } from '$lib/server/fetchers/properties' - -export const load = () => { - return fetch_grouped_properties_and_tags('functor') -} diff --git a/src/routes/functor-properties/[tag]/+page.server.ts b/src/routes/functor-properties/[tag]/+page.server.ts deleted file mode 100644 index 7c4f183c7..000000000 --- a/src/routes/functor-properties/[tag]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { fetch_tagged_properties } from '$lib/server/fetchers/properties' -import { fetch_property_tags } from '$lib/server/fetchers/tags' -import type { EntryGenerator } from './$types' - -export const entries: EntryGenerator = () => { - return fetch_property_tags('functor') -} - -export const load = (event) => { - return fetch_tagged_properties('functor', event.params.tag) -} diff --git a/src/routes/functor-property/[id]/+page.server.ts b/src/routes/functor-property/[id]/+page.server.ts deleted file mode 100644 index b08c10122..000000000 --- a/src/routes/functor-property/[id]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { decode_property_ID } from '$lib/commons/property.url' -import { fetch_property } from '$lib/server/fetchers/property' - -export const load = (event) => { - const id = decode_property_ID(event.params.id) - - const property_data = fetch_property('functor', id) - - return render_nested_formulas(property_data) -} diff --git a/src/routes/morphism-properties/+page.server.ts b/src/routes/morphism-properties/+page.server.ts deleted file mode 100644 index 65095e1bd..000000000 --- a/src/routes/morphism-properties/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_grouped_properties_and_tags } from '$lib/server/fetchers/properties' - -export const load = () => { - return fetch_grouped_properties_and_tags('morphism') -} diff --git a/src/routes/morphism-properties/+page.svelte b/src/routes/morphism-properties/+page.svelte deleted file mode 100644 index dadefb7f8..000000000 --- a/src/routes/morphism-properties/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/morphism-properties/[tag]/+page.server.ts b/src/routes/morphism-properties/[tag]/+page.server.ts deleted file mode 100644 index ccbb6896e..000000000 --- a/src/routes/morphism-properties/[tag]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { fetch_tagged_properties } from '$lib/server/fetchers/properties' -import { fetch_property_tags } from '$lib/server/fetchers/tags' -import type { EntryGenerator } from './$types' - -export const entries: EntryGenerator = () => { - return fetch_property_tags('morphism') -} - -export const load = (event) => { - return fetch_tagged_properties('morphism', event.params.tag) -} diff --git a/src/routes/morphism-properties/[tag]/+page.svelte b/src/routes/morphism-properties/[tag]/+page.svelte deleted file mode 100644 index 62fb6cb9f..000000000 --- a/src/routes/morphism-properties/[tag]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/morphism-property/[id]/+page.svelte b/src/routes/morphism-property/[id]/+page.svelte deleted file mode 100644 index acb5718b5..000000000 --- a/src/routes/morphism-property/[id]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - From b119fbce3b8324b21f1b2881ce1e76fe318a409d Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 20:30:31 +0200 Subject: [PATCH 05/10] dynamic route for structure list pages --- src/components/StructureSelector.svelte | 2 +- src/components/TagList.svelte | 3 +-- src/lib/client/nav.ts | 4 ++-- src/lib/commons/structures.ts | 3 +-- src/lib/server/fetchers/structures.ts | 4 ++-- src/routes/+page.svelte | 8 ++++---- src/routes/[type]-list/+page.server.ts | 10 ++++++++++ src/routes/{functors => [type]-list}/+page.svelte | 2 +- src/routes/[type]-list/[tag]/+page.server.ts | 12 ++++++++++++ .../{functors => [type]-list}/[tag]/+page.svelte | 2 +- src/routes/categories/+page.server.ts | 5 ----- src/routes/categories/+page.svelte | 7 ------- src/routes/categories/[tag]/+page.server.ts | 11 ----------- src/routes/categories/[tag]/+page.svelte | 7 ------- src/routes/functors/+page.server.ts | 5 ----- src/routes/functors/[tag]/+page.server.ts | 12 ------------ src/routes/morphisms/+page.server.ts | 5 ----- src/routes/morphisms/+page.svelte | 7 ------- src/routes/morphisms/[tag]/+page.server.ts | 12 ------------ src/routes/morphisms/[tag]/+page.svelte | 7 ------- 20 files changed, 35 insertions(+), 93 deletions(-) create mode 100644 src/routes/[type]-list/+page.server.ts rename src/routes/{functors => [type]-list}/+page.svelte (72%) create mode 100644 src/routes/[type]-list/[tag]/+page.server.ts rename src/routes/{functors => [type]-list}/[tag]/+page.svelte (71%) delete mode 100644 src/routes/categories/+page.server.ts delete mode 100644 src/routes/categories/+page.svelte delete mode 100644 src/routes/categories/[tag]/+page.server.ts delete mode 100644 src/routes/categories/[tag]/+page.svelte delete mode 100644 src/routes/functors/+page.server.ts delete mode 100644 src/routes/functors/[tag]/+page.server.ts delete mode 100644 src/routes/morphisms/+page.server.ts delete mode 100644 src/routes/morphisms/+page.svelte delete mode 100644 src/routes/morphisms/[tag]/+page.server.ts delete mode 100644 src/routes/morphisms/[tag]/+page.svelte diff --git a/src/components/StructureSelector.svelte b/src/components/StructureSelector.svelte index 9e7472d77..c9063244f 100644 --- a/src/components/StructureSelector.svelte +++ b/src/components/StructureSelector.svelte @@ -24,7 +24,7 @@ } else if (path.includes('-comparison')) { goto(`/${selected_type}-comparison`) } else { - goto(`/${PLURALS[selected_type]}`) + goto(`/${selected_type}-list`) } } diff --git a/src/components/TagList.svelte b/src/components/TagList.svelte index 6323ae2b5..ca9b10233 100644 --- a/src/components/TagList.svelte +++ b/src/components/TagList.svelte @@ -1,6 +1,5 @@ - + diff --git a/src/routes/[type]-list/[tag]/+page.server.ts b/src/routes/[type]-list/[tag]/+page.server.ts new file mode 100644 index 000000000..5e1b29ac1 --- /dev/null +++ b/src/routes/[type]-list/[tag]/+page.server.ts @@ -0,0 +1,12 @@ +import { fetch_tagged_structures } from '$lib/server/fetchers/structures' +import { is_structure_type } from '$lib/commons/structures' +import { error } from '@sveltejs/kit' + +export const prerender = false // FIXME + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + return fetch_tagged_structures(type, event.params.tag) +} diff --git a/src/routes/functors/[tag]/+page.svelte b/src/routes/[type]-list/[tag]/+page.svelte similarity index 71% rename from src/routes/functors/[tag]/+page.svelte rename to src/routes/[type]-list/[tag]/+page.svelte index 62d2d5fe8..adb7a2c73 100644 --- a/src/routes/functors/[tag]/+page.svelte +++ b/src/routes/[type]-list/[tag]/+page.svelte @@ -4,4 +4,4 @@ let { data } = $props() - + diff --git a/src/routes/categories/+page.server.ts b/src/routes/categories/+page.server.ts deleted file mode 100644 index cbedafab7..000000000 --- a/src/routes/categories/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures_and_tags } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures_and_tags('category') -} diff --git a/src/routes/categories/+page.svelte b/src/routes/categories/+page.svelte deleted file mode 100644 index 7a38c6f9f..000000000 --- a/src/routes/categories/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/categories/[tag]/+page.server.ts b/src/routes/categories/[tag]/+page.server.ts deleted file mode 100644 index 2dabfdeeb..000000000 --- a/src/routes/categories/[tag]/+page.server.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { EntryGenerator } from './$types' -import { fetch_tagged_structures } from '$lib/server/fetchers/structures' -import { fetch_structure_tags } from '$lib/server/fetchers/tags' - -export const entries: EntryGenerator = () => { - return fetch_structure_tags('category') -} - -export const load = (event) => { - return fetch_tagged_structures('category', event.params.tag) -} diff --git a/src/routes/categories/[tag]/+page.svelte b/src/routes/categories/[tag]/+page.svelte deleted file mode 100644 index 23a04e044..000000000 --- a/src/routes/categories/[tag]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/functors/+page.server.ts b/src/routes/functors/+page.server.ts deleted file mode 100644 index 77c00b6ce..000000000 --- a/src/routes/functors/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures_and_tags } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures_and_tags('functor') -} diff --git a/src/routes/functors/[tag]/+page.server.ts b/src/routes/functors/[tag]/+page.server.ts deleted file mode 100644 index b0131707c..000000000 --- a/src/routes/functors/[tag]/+page.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { EntryGenerator } from './$types' -import { fetch_tagged_structures } from '$lib/server/fetchers/structures' -import { fetch_structure_tags } from '$lib/server/fetchers/tags' - -export const entries: EntryGenerator = () => { - return fetch_structure_tags('functor') -} - -export const load = (event) => { - const tag = event.params.tag - return fetch_tagged_structures('functor', tag) -} diff --git a/src/routes/morphisms/+page.server.ts b/src/routes/morphisms/+page.server.ts deleted file mode 100644 index 0825b73ec..000000000 --- a/src/routes/morphisms/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { fetch_structures_and_tags } from '$lib/server/fetchers/structures' - -export const load = () => { - return fetch_structures_and_tags('morphism') -} diff --git a/src/routes/morphisms/+page.svelte b/src/routes/morphisms/+page.svelte deleted file mode 100644 index f94edcfc7..000000000 --- a/src/routes/morphisms/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/src/routes/morphisms/[tag]/+page.server.ts b/src/routes/morphisms/[tag]/+page.server.ts deleted file mode 100644 index 7624ca36a..000000000 --- a/src/routes/morphisms/[tag]/+page.server.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { EntryGenerator } from './$types' -import { fetch_tagged_structures } from '$lib/server/fetchers/structures' -import { fetch_structure_tags } from '$lib/server/fetchers/tags' - -export const entries: EntryGenerator = () => { - return fetch_structure_tags('morphism') -} - -export const load = (event) => { - const tag = event.params.tag - return fetch_tagged_structures('morphism', tag) -} diff --git a/src/routes/morphisms/[tag]/+page.svelte b/src/routes/morphisms/[tag]/+page.svelte deleted file mode 100644 index d3340462d..000000000 --- a/src/routes/morphisms/[tag]/+page.svelte +++ /dev/null @@ -1,7 +0,0 @@ - - - From 21a0106b87dcb885f702add38128a8bf5ed3a66a Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sat, 4 Jul 2026 20:55:36 +0200 Subject: [PATCH 06/10] fix prerendering issue --- src/routes/[type]-list/+page.server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/[type]-list/+page.server.ts b/src/routes/[type]-list/+page.server.ts index 24b8585bd..2f0a72c82 100644 --- a/src/routes/[type]-list/+page.server.ts +++ b/src/routes/[type]-list/+page.server.ts @@ -1,6 +1,11 @@ -import { is_structure_type } from '$lib/commons/structures' +import { is_structure_type, STRUCTURES } from '$lib/commons/structures' import { fetch_structures_and_tags } from '$lib/server/fetchers/structures' import { error } from '@sveltejs/kit' +import type { EntryGenerator } from './$types' + +export const entries: EntryGenerator = () => { + return STRUCTURES.map((type) => ({ type })) +} export const load = (event) => { const type = event.params.type From 3b57efd8b53d1dbea879db4ea1440e40126fd034 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sun, 5 Jul 2026 08:36:39 +0200 Subject: [PATCH 07/10] dynamic route for structure detail page - first attempt --- src/lib/server/fetchers/structure.ts | 1 + src/routes/[type]/[id]/+page.server.ts | 37 +++++++ src/routes/[type]/[id]/+page.svelte | 130 +++++++++++++++++++++++ src/routes/category/[id]/+page.server.ts | 34 ------ src/routes/category/[id]/+page.svelte | 74 ------------- src/routes/functor/[id]/+page.server.ts | 40 ------- src/routes/functor/[id]/+page.svelte | 43 -------- src/routes/morphism/[id]/+page.server.ts | 34 ------ src/routes/morphism/[id]/+page.svelte | 16 --- 9 files changed, 168 insertions(+), 241 deletions(-) create mode 100644 src/routes/[type]/[id]/+page.server.ts create mode 100644 src/routes/[type]/[id]/+page.svelte delete mode 100644 src/routes/category/[id]/+page.server.ts delete mode 100644 src/routes/category/[id]/+page.svelte delete mode 100644 src/routes/functor/[id]/+page.server.ts delete mode 100644 src/routes/functor/[id]/+page.svelte delete mode 100644 src/routes/morphism/[id]/+page.server.ts delete mode 100644 src/routes/morphism/[id]/+page.svelte diff --git a/src/lib/server/fetchers/structure.ts b/src/lib/server/fetchers/structure.ts index 9929f93cd..7b17d3d3a 100644 --- a/src/lib/server/fetchers/structure.ts +++ b/src/lib/server/fetchers/structure.ts @@ -142,6 +142,7 @@ export function fetch_structure(type: StructureType, id: string) { .map(display_property_assignment) return { + type, structure, related_structures, tags, diff --git a/src/routes/[type]/[id]/+page.server.ts b/src/routes/[type]/[id]/+page.server.ts new file mode 100644 index 000000000..ad64b10d7 --- /dev/null +++ b/src/routes/[type]/[id]/+page.server.ts @@ -0,0 +1,37 @@ +import { render_nested_formulas } from '$lib/server/formulas' +import { fetch_structure } from '$lib/server/fetchers/structure' +import { is_structure_type } from '$lib/commons/structures' +import { error } from '@sveltejs/kit' +import { fetch_category } from '$lib/server/fetchers/category' +import { fetch_functor } from '$lib/server/fetchers/functor' +import { fetch_morphism } from '$lib/server/fetchers/morphism' +import { add_math, strip_math } from '$lib/server/utils' + +export const load = (event) => { + const type = event.params.type + if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) + + const id = event.params.id + + const structure_data = fetch_structure(type, id) + + // TODO: improve this mess + + const special_structure_data = + type === 'category' + ? { category: fetch_category(id) } + : type === 'functor' + ? { functor: fetch_functor(id) } + : { morphism: fetch_morphism(id) } + + if (type === 'functor' && special_structure_data.functor) { + structure_data.structure.notation = add_math( + `${strip_math(structure_data.structure.notation)}: ${strip_math(special_structure_data.functor.source_notation)} \\to ${strip_math(special_structure_data.functor.target_notation)}`, + ) + } + + return render_nested_formulas({ + special_structure_data, + ...structure_data, + }) +} diff --git a/src/routes/[type]/[id]/+page.svelte b/src/routes/[type]/[id]/+page.svelte new file mode 100644 index 000000000..23c3e161d --- /dev/null +++ b/src/routes/[type]/[id]/+page.svelte @@ -0,0 +1,130 @@ + + + + +{#if data.special_structure_data.category} + {@const category = data.special_structure_data.category} + + {#snippet definition()} +
  • + objects: + {@html category.objects} +
  • +
  • + morphisms: + {@html category.morphisms} +
  • + {/snippet} + + {#snippet specials()} +
    +

    Special objects

    + + {#if category.special_objects.length} +
      + {#each category.special_objects as obj} +
    • {obj.type}: {@html obj.description}
    • + {/each} +
    + {:else} +

    + {/if} +
    + +
    +

    Special morphisms

    + +
      + {#each category.special_morphisms as obj} +
    • + + {#if obj.description} + {obj.type}: {@html obj.description} + {:else} + {obj.type}: + {/if} + +
    • + {/each} +
    +
    + {/snippet} + + {#snippet footer()} + {#if category.functors.length} +
    +

    Functors

    + +

    + {pluralize(category.functors.length, { + one: 'There is 1 functor', + other: 'There are {count} functors', + })} + whose source or target is the {data.structure.name}. +

    + +
    + {/if} + {/snippet} +
    +{:else if data.special_structure_data.functor} + {@const functor = data.special_structure_data.functor} + + {#snippet definition()} +
  • + Source: + {functor.source_name} +
  • + +
  • + Target: + {functor.target_name} +
  • + + {#if functor.left_adjoint} +
  • + Left adjoint functor: + + {@html functor.left_adjoint_notation} + +
  • + {/if} + + {#if functor.right_adjoint} +
  • + Right adjoint functor: + + {@html functor.right_adjoint_notation} + +
  • + {/if} + {/snippet} +
    +{:else if data.special_structure_data.morphism} + {@const morphism = data.special_structure_data.morphism} + + {#snippet definition()} +
  • + Category: + + {morphism.category_name} + +
  • + {/snippet} +
    +{/if} diff --git a/src/routes/category/[id]/+page.server.ts b/src/routes/category/[id]/+page.server.ts deleted file mode 100644 index bb30b3b31..000000000 --- a/src/routes/category/[id]/+page.server.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { render_nested_formulas } from '$lib/server/formulas' -import { fetch_structure } from '$lib/server/fetchers/structure' -import { fetch_category } from '$lib/server/fetchers/category' - -export const load = (event) => { - const id = event.params.id - - const { - structure, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - } = fetch_structure('category', id) - - const category = fetch_category(id) - - return render_nested_formulas({ - structure, - category, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - }) -} diff --git a/src/routes/category/[id]/+page.svelte b/src/routes/category/[id]/+page.svelte deleted file mode 100644 index 464a70234..000000000 --- a/src/routes/category/[id]/+page.svelte +++ /dev/null @@ -1,74 +0,0 @@ - - - - {#snippet definition()} -
  • - objects: - {@html data.category.objects} -
  • -
  • - morphisms: - {@html data.category.morphisms} -
  • - {/snippet} - - {#snippet specials()} -
    -

    Special objects

    - - {#if data.category.special_objects.length} -
      - {#each data.category.special_objects as obj} -
    • {obj.type}: {@html obj.description}
    • - {/each} -
    - {:else} -

    - {/if} -
    - -
    -

    Special morphisms

    - -
      - {#each data.category.special_morphisms as obj} -
    • - - {#if obj.description} - {obj.type}: {@html obj.description} - {:else} - {obj.type}: - {/if} - -
    • - {/each} -
    -
    - {/snippet} - - {#snippet footer()} - {#if data.category.functors.length} -
    -

    Functors

    - -

    - {pluralize(data.category.functors.length, { - one: 'There is 1 functor', - other: 'There are {count} functors', - })} - whose source or target is the {data.structure.name}. -

    - -
    - {/if} - {/snippet} -
    diff --git a/src/routes/functor/[id]/+page.server.ts b/src/routes/functor/[id]/+page.server.ts deleted file mode 100644 index f73f8337d..000000000 --- a/src/routes/functor/[id]/+page.server.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { fetch_functor } from '$lib/server/fetchers/functor' -import { fetch_structure } from '$lib/server/fetchers/structure' -import { render_nested_formulas } from '$lib/server/formulas' -import { add_math, strip_math } from '$lib/server/utils' - -export const load = (event) => { - const id = event.params.id - - const { - structure, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - } = fetch_structure('functor', id) - - const functor = fetch_functor(id) - - // functors are notated as F : C -> D - structure.notation = add_math( - `${strip_math(structure.notation)}: ${strip_math(functor.source_notation)} \\to ${strip_math(functor.target_notation)}`, - ) - - return render_nested_formulas({ - structure, - functor, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - }) -} diff --git a/src/routes/functor/[id]/+page.svelte b/src/routes/functor/[id]/+page.svelte deleted file mode 100644 index 7d708bb00..000000000 --- a/src/routes/functor/[id]/+page.svelte +++ /dev/null @@ -1,43 +0,0 @@ - - - - {#snippet definition()} -
  • - Source: - {data.functor.source_name} -
  • - -
  • - Target: - {data.functor.target_name} -
  • - - {#if data.functor.left_adjoint} -
  • - Left adjoint functor: - - {@html data.functor.left_adjoint_notation} - -
  • - {/if} - - {#if data.functor.right_adjoint} -
  • - Right adjoint functor: - - {@html data.functor.right_adjoint_notation} - -
  • - {/if} - {/snippet} -
    diff --git a/src/routes/morphism/[id]/+page.server.ts b/src/routes/morphism/[id]/+page.server.ts deleted file mode 100644 index 6923eaf43..000000000 --- a/src/routes/morphism/[id]/+page.server.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { fetch_morphism } from '$lib/server/fetchers/morphism' -import { fetch_structure } from '$lib/server/fetchers/structure' -import { render_nested_formulas } from '$lib/server/formulas' - -export const load = (event) => { - const id = event.params.id - - const { - structure, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - } = fetch_structure('morphism', id) - - const morphism = fetch_morphism(id) - - return render_nested_formulas({ - structure, - morphism, - related_structures, - tags, - satisfied_properties, - unsatisfied_properties, - unknown_properties, - undecidable_properties, - undistinguishable_structures, - comments, - }) -} diff --git a/src/routes/morphism/[id]/+page.svelte b/src/routes/morphism/[id]/+page.svelte deleted file mode 100644 index 0e2550a60..000000000 --- a/src/routes/morphism/[id]/+page.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - - - {#snippet definition()} -
  • - Category: - - {data.morphism.category_name} - -
  • - {/snippet} -
    From d68f38af86a310b8315be8dd99e2d36196160905 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sun, 5 Jul 2026 10:28:18 +0200 Subject: [PATCH 08/10] refactoring of structure types array --- databases/catdat/scripts/config.ts | 10 +++++----- databases/catdat/scripts/deduce-implications.ts | 4 ++-- .../catdat/scripts/deduce-structure-properties.ts | 4 ++-- databases/catdat/scripts/seed.ts | 4 ++-- databases/catdat/scripts/test.ts | 4 ++-- src/components/StructureSelector.svelte | 6 +++--- src/lib/commons/structures.ts | 10 +++++----- src/lib/commons/types.ts | 6 ++++-- src/routes/[type]-list/+page.server.ts | 4 ++-- src/routes/missing/+page.server.ts | 6 +++--- src/routes/missing/+page.svelte | 8 ++++---- 11 files changed, 34 insertions(+), 32 deletions(-) diff --git a/databases/catdat/scripts/config.ts b/databases/catdat/scripts/config.ts index b916e3701..e8f506742 100644 --- a/databases/catdat/scripts/config.ts +++ b/databases/catdat/scripts/config.ts @@ -1,4 +1,8 @@ -export type StructureType = 'category' | 'functor' | 'morphism' +export const STRUCTURE_TYPES = ['category', 'functor', 'morphism'] as const + +export type StructureType = (typeof STRUCTURE_TYPES)[number] + +export const STRUCTURE_TYPES_WITH_DUALS: StructureType[] = ['category'] export const PLURALS = { category: 'categories', @@ -6,10 +10,6 @@ export const PLURALS = { morphism: 'morphisms', } as const -export const STRUCTURES: StructureType[] = ['category', 'functor', 'morphism'] - -export const STRUCTURES_WITH_DUALS: StructureType[] = ['category'] - export const TABLES = { category: 'categories', functor: 'functors', diff --git a/databases/catdat/scripts/deduce-implications.ts b/databases/catdat/scripts/deduce-implications.ts index 033d12055..3035c9d71 100644 --- a/databases/catdat/scripts/deduce-implications.ts +++ b/databases/catdat/scripts/deduce-implications.ts @@ -1,4 +1,4 @@ -import { STRUCTURES_WITH_DUALS, type StructureType } from './config' +import { STRUCTURE_TYPES_WITH_DUALS, type StructureType } from './config' import { are_equal_sets, parse_nested_json_set, parse_json_set } from './utils/helpers' import { get_client } from './utils/db' @@ -161,7 +161,7 @@ export function create_dualized_implications(type: StructureType) { * Creates all trivial implications of the form "self-dual + P ===> P^op". */ export function create_self_dual_implications(type: StructureType) { - if (!STRUCTURES_WITH_DUALS.includes(type)) return + if (!STRUCTURE_TYPES_WITH_DUALS.includes(type)) return const relevant_props = db .prepare<[StructureType], { id: string; dual: string }>( diff --git a/databases/catdat/scripts/deduce-structure-properties.ts b/databases/catdat/scripts/deduce-structure-properties.ts index 5dfcc7d03..5fabf8af2 100644 --- a/databases/catdat/scripts/deduce-structure-properties.ts +++ b/databases/catdat/scripts/deduce-structure-properties.ts @@ -17,7 +17,7 @@ import { get_proof_string, NormalizedImplication, } from './utils/implications' -import { STRUCTURES_WITH_DUALS, type StructureType } from './config' +import { STRUCTURE_TYPES_WITH_DUALS, type StructureType } from './config' import { get_structures, is_dual_structure, type StructureMeta } from './utils/structures' /** @@ -428,7 +428,7 @@ export function deduce_properties_for_structures(type: StructureType) { deduction() - if (!STRUCTURES_WITH_DUALS.includes(type)) return + if (!STRUCTURE_TYPES_WITH_DUALS.includes(type)) return const dual_deduction = db.transaction(() => { for (const structure of structures) { diff --git a/databases/catdat/scripts/seed.ts b/databases/catdat/scripts/seed.ts index 0d5c6e5d1..100cfa021 100644 --- a/databases/catdat/scripts/seed.ts +++ b/databases/catdat/scripts/seed.ts @@ -12,7 +12,7 @@ import type { MorphismYaml, } from './utils/seed.types' import { create_schema_hash, get_saved_schema_hash } from './utils/schema' -import { PLURALS, STRUCTURES, type StructureType } from './config' +import { PLURALS, STRUCTURE_TYPES, type StructureType } from './config' const db = get_client() @@ -126,7 +126,7 @@ function seed_config() { ) function insert_config(config: ConfigYaml) { - for (const type of STRUCTURES) { + for (const type of STRUCTURE_TYPES) { for (const tag of config.structure_tags) { structure_tag_insert.run(tag, type) } diff --git a/databases/catdat/scripts/test.ts b/databases/catdat/scripts/test.ts index a1bcfd7db..f6493cfc1 100644 --- a/databases/catdat/scripts/test.ts +++ b/databases/catdat/scripts/test.ts @@ -14,7 +14,7 @@ import decided_functors from './expected-data/decided-functors.json' import decided_morphisms from './expected-data/decided-morphisms.json' import { capitalize } from './utils/helpers' import { get_client } from './utils/db' -import { PLURALS, STRUCTURES, type StructureType } from './config' +import { PLURALS, STRUCTURE_TYPES, type StructureType } from './config' import fs from 'node:fs' import path from 'node:path' import { decode_property_ID } from '../../../src/lib/commons/property.url' @@ -242,7 +242,7 @@ function check_link_targets_exist() { for (const { proof, error_prefix } of proofs) { const link_regex = new RegExp( - ` import { goto } from '$app/navigation' import { page } from '$app/state' - import { PLURALS, STRUCTURES } from '$lib/commons/structures' + import { PLURALS, STRUCTURE_TYPES } from '$lib/commons/structures' import type { StructureType } from '$lib/commons/types' type Props = { @@ -33,8 +33,8 @@ - + {#each STRUCTURE_TYPES as structure} {/each} diff --git a/src/lib/commons/structures.ts b/src/lib/commons/structures.ts index 51d055cbd..d98f646e6 100644 --- a/src/lib/commons/structures.ts +++ b/src/lib/commons/structures.ts @@ -1,19 +1,19 @@ -import type { StructureType } from './types' +export const STRUCTURE_TYPES = ['category', 'functor', 'morphism'] as const -export const STRUCTURES: StructureType[] = ['category', 'functor', 'morphism'] +export type StructureType = (typeof STRUCTURE_TYPES)[number] export function is_structure_type(txt: string): txt is StructureType { - return (STRUCTURES as string[]).includes(txt) + return (STRUCTURE_TYPES as readonly string[]).includes(txt) } -export const PLURALS = { +export const PLURALS: Record = { category: 'categories', functor: 'functors', morphism: 'morphisms', } export function get_selected_type(pathname: string): StructureType { - for (const type of STRUCTURES) { + for (const type of STRUCTURE_TYPES) { const matches = pathname.startsWith(`/${type}`) if (matches) return type } diff --git a/src/lib/commons/types.ts b/src/lib/commons/types.ts index b1fe52ec6..6063bffcd 100644 --- a/src/lib/commons/types.ts +++ b/src/lib/commons/types.ts @@ -1,11 +1,13 @@ +import type { StructureType } from './structures' + +export type { StructureType } + export type Arrayed = { [K in keyof T]: T[K][] } type Replace>> = Omit & R -export type StructureType = 'category' | 'functor' | 'morphism' - export type StructureShort = { id: string name: string diff --git a/src/routes/[type]-list/+page.server.ts b/src/routes/[type]-list/+page.server.ts index 2f0a72c82..a8ad4c0b6 100644 --- a/src/routes/[type]-list/+page.server.ts +++ b/src/routes/[type]-list/+page.server.ts @@ -1,10 +1,10 @@ -import { is_structure_type, STRUCTURES } from '$lib/commons/structures' +import { is_structure_type, STRUCTURE_TYPES } from '$lib/commons/structures' import { fetch_structures_and_tags } from '$lib/server/fetchers/structures' import { error } from '@sveltejs/kit' import type { EntryGenerator } from './$types' export const entries: EntryGenerator = () => { - return STRUCTURES.map((type) => ({ type })) + return STRUCTURE_TYPES.map((type) => ({ type })) } export const load = (event) => { diff --git a/src/routes/missing/+page.server.ts b/src/routes/missing/+page.server.ts index b25f2c69d..5a788f79b 100644 --- a/src/routes/missing/+page.server.ts +++ b/src/routes/missing/+page.server.ts @@ -1,19 +1,19 @@ import { fetch_missing_data } from '$lib/server/fetchers/missing_data' import { fetch_categories_with_missing_morphisms } from '$lib/server/fetchers/category' -import { STRUCTURES } from '$lib/commons/structures' +import { STRUCTURE_TYPES } from '$lib/commons/structures' export const load = () => { const categories_with_missing_morphisms = fetch_categories_with_missing_morphisms() const missing_data = Object.fromEntries( - STRUCTURES.map((type) => [type, fetch_missing_data(type)]), + STRUCTURE_TYPES.map((type) => [type, fetch_missing_data(type)]), ) function select( selector: (data: (typeof missing_data)[keyof typeof missing_data]) => T, ) { return Object.fromEntries( - STRUCTURES.map((type) => [type, selector(missing_data[type])]), + STRUCTURE_TYPES.map((type) => [type, selector(missing_data[type])]), ) } diff --git a/src/routes/missing/+page.svelte b/src/routes/missing/+page.svelte index b566f809f..737ce4199 100644 --- a/src/routes/missing/+page.svelte +++ b/src/routes/missing/+page.svelte @@ -3,7 +3,7 @@ import MetaData from '$components/MetaData.svelte' import SuggestionForm from '$components/SuggestionForm.svelte' import { get_property_url } from '$lib/commons/property.url' - import { PLURALS, STRUCTURES } from '$lib/commons/structures' + import { PLURALS, STRUCTURE_TYPES } from '$lib/commons/structures' import { capitalize } from '$lib/client/utils' const { data } = $props() @@ -21,7 +21,7 @@ contributing to this project.

    -{#each STRUCTURES as type} +{#each STRUCTURE_TYPES as type} {@const structures = data.structures_with_unknown_properties[type]} {@const total = data.unknown_totals[type]}
    @@ -54,7 +54,7 @@
    -{#each STRUCTURES as type} +{#each STRUCTURE_TYPES as type} {@const pairs = data.undistinguishable_pairs[type]} {#if pairs.length > 0} @@ -84,7 +84,7 @@ {/if} {/each} -{#each STRUCTURES as type} +{#each STRUCTURE_TYPES as type} {@const combinations = data.missing_combinations[type]} {#if combinations.length > 0} From c79fd4745d1072828baef5be016d665ba3ad81e4 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sun, 5 Jul 2026 10:49:33 +0200 Subject: [PATCH 09/10] fix prerendering of tag pages --- src/lib/server/fetchers/tags.ts | 14 +++++++------- src/routes/[type]-list/[tag]/+page.server.ts | 6 +++++- src/routes/[type]-properties/[tag]/+page.server.ts | 6 +++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/lib/server/fetchers/tags.ts b/src/lib/server/fetchers/tags.ts index 99d118b73..dfd30d0e1 100644 --- a/src/lib/server/fetchers/tags.ts +++ b/src/lib/server/fetchers/tags.ts @@ -1,10 +1,10 @@ -import type { StructureType, TagObject } from '$lib/commons/types' +import type { StructureType } from '$lib/commons/types' import sql from 'sql-template-tag' import { query } from '$lib/server/db.catdat' -export function fetch_structure_tags(type: StructureType) { - const { rows, err } = query(sql` - SELECT tag FROM structure_tags WHERE type = ${type} +export function fetch_structure_tags() { + const { rows, err } = query<{ tag: string; type: StructureType }>(sql` + SELECT tag, type FROM structure_tags `) if (err) throw new Error('Database error: Failed to load structure tags') @@ -12,9 +12,9 @@ export function fetch_structure_tags(type: StructureType) { return rows } -export function fetch_property_tags(type: StructureType) { - const { rows, err } = query(sql` - SELECT tag FROM property_tags WHERE type = ${type} +export function fetch_property_tags() { + const { rows, err } = query<{ tag: string; type: StructureType }>(sql` + SELECT tag, type FROM property_tags `) if (err) throw new Error('Database error: Failed to load property tags') diff --git a/src/routes/[type]-list/[tag]/+page.server.ts b/src/routes/[type]-list/[tag]/+page.server.ts index 5e1b29ac1..b167a39c3 100644 --- a/src/routes/[type]-list/[tag]/+page.server.ts +++ b/src/routes/[type]-list/[tag]/+page.server.ts @@ -1,8 +1,12 @@ import { fetch_tagged_structures } from '$lib/server/fetchers/structures' import { is_structure_type } from '$lib/commons/structures' import { error } from '@sveltejs/kit' +import type { EntryGenerator } from './$types' +import { fetch_structure_tags } from '$lib/server/fetchers/tags' -export const prerender = false // FIXME +export const entries: EntryGenerator = () => { + return fetch_structure_tags() +} export const load = (event) => { const type = event.params.type diff --git a/src/routes/[type]-properties/[tag]/+page.server.ts b/src/routes/[type]-properties/[tag]/+page.server.ts index 180767c04..28049e913 100644 --- a/src/routes/[type]-properties/[tag]/+page.server.ts +++ b/src/routes/[type]-properties/[tag]/+page.server.ts @@ -1,8 +1,12 @@ import { is_structure_type } from '$lib/commons/structures' import { fetch_tagged_properties } from '$lib/server/fetchers/properties' import { error } from '@sveltejs/kit' +import type { EntryGenerator } from './$types' +import { fetch_property_tags } from '$lib/server/fetchers/tags' -export const prerender = false // FIXME +export const entries: EntryGenerator = () => { + return fetch_property_tags() +} export const load = (event) => { const type = event.params.type From f3a412a9dee3796fc925dd6569fc31d688cca9f7 Mon Sep 17 00:00:00 2001 From: Script Raccoon Date: Sun, 5 Jul 2026 13:22:46 +0200 Subject: [PATCH 10/10] refactor structure detail pages --- src/lib/commons/types.ts | 68 ++++++++----- src/lib/server/fetchers/category.ts | 15 +-- src/lib/server/fetchers/functor.ts | 2 +- src/lib/server/fetchers/morphism.ts | 2 +- src/lib/server/fetchers/structure.ts | 3 +- src/pages/CategoryDetailPage.svelte | 77 ++++++++++++++ src/pages/FunctorDetailPage.svelte | 46 +++++++++ src/pages/MorphismDetailPage.svelte | 19 ++++ src/routes/[type]/[id]/+page.server.ts | 21 ++-- src/routes/[type]/[id]/+page.svelte | 133 ++----------------------- 10 files changed, 217 insertions(+), 169 deletions(-) create mode 100644 src/pages/CategoryDetailPage.svelte create mode 100644 src/pages/FunctorDetailPage.svelte create mode 100644 src/pages/MorphismDetailPage.svelte diff --git a/src/lib/commons/types.ts b/src/lib/commons/types.ts index 6063bffcd..64248f588 100644 --- a/src/lib/commons/types.ts +++ b/src/lib/commons/types.ts @@ -26,32 +26,6 @@ export type StructureDisplay = { dual_structure_notation: string | null } -export type CategorySpecificDisplay = { - objects: string - morphisms: string -} - -export type FunctorSpecificDisplay = { - source: string - source_name: string - source_notation: string - target: string - target_name: string - target_notation: string - left_adjoint: string | null - left_adjoint_name: string | null - left_adjoint_notation: string | null - right_adjoint: string | null - right_adjoint_name: string | null - right_adjoint_notation: string | null -} - -export type MorphismSpecificDisplay = { - category: string - category_name: string - category_notation: string -} - export type MappedTypes = Record export type TagObject = { tag: string } @@ -150,3 +124,45 @@ export type ComparisonResult = { comparison_table: string[][] type: StructureType } + +export type StructureDetails = { + type: StructureType + structure: StructureDisplay + related_structures: RelatedStructure[] + tags: string[] + satisfied_properties: PropertyAssignmentDisplay[] + unsatisfied_properties: PropertyAssignmentDisplay[] + unknown_properties: PropertyShort[] + undecidable_properties: PropertyAssignmentDisplay[] + undistinguishable_structures: StructureShort[] + comments: CommentObject[] +} + +export type CategorySpecificDisplay = { + objects: string + morphisms: string + special_objects: SpecialObject[] + special_morphisms: SpecialMorphism[] + functors: StructureShort[] +} + +export type FunctorSpecificDisplay = { + source: string + source_name: string + source_notation: string + target: string + target_name: string + target_notation: string + left_adjoint: string | null + left_adjoint_name: string | null + left_adjoint_notation: string | null + right_adjoint: string | null + right_adjoint_name: string | null + right_adjoint_notation: string | null +} + +export type MorphismSpecificDisplay = { + category: string + category_name: string + category_notation: string +} diff --git a/src/lib/server/fetchers/category.ts b/src/lib/server/fetchers/category.ts index 4ae32a78d..4eb203f7e 100644 --- a/src/lib/server/fetchers/category.ts +++ b/src/lib/server/fetchers/category.ts @@ -1,16 +1,16 @@ -import type { - CategorySpecificDisplay, - SpecialMorphism, - SpecialObject, - StructureShort, -} from '$lib/commons/types' +import type { SpecialMorphism, SpecialObject, StructureShort } from '$lib/commons/types' import sql from 'sql-template-tag' import { batch, query } from '$lib/server/db.catdat' import { error } from '@sveltejs/kit' export function fetch_category(id: string) { const { results, err } = batch< - [CategorySpecificDisplay, SpecialObject, SpecialMorphism, StructureShort] + [ + { objects: string; morphisms: string }, + SpecialObject, + SpecialMorphism, + StructureShort, + ] >([ // specific information for the category sql` @@ -51,6 +51,7 @@ export function fetch_category(id: string) { if (!categories.length) error(404, `Could not find category with ID '${id}'`) return { + type: 'category' as const, ...categories[0], special_objects, special_morphisms, diff --git a/src/lib/server/fetchers/functor.ts b/src/lib/server/fetchers/functor.ts index c3a4adeaf..e114a9dc7 100644 --- a/src/lib/server/fetchers/functor.ts +++ b/src/lib/server/fetchers/functor.ts @@ -34,5 +34,5 @@ export function fetch_functor(id: string) { if (!functors.length) error(404, `Could not find functor with ID '${id}'`) - return functors[0] + return { type: 'functor' as const, ...functors[0] } } diff --git a/src/lib/server/fetchers/morphism.ts b/src/lib/server/fetchers/morphism.ts index c1b7d33b3..2a43e432e 100644 --- a/src/lib/server/fetchers/morphism.ts +++ b/src/lib/server/fetchers/morphism.ts @@ -21,5 +21,5 @@ export function fetch_morphism(id: string) { if (!morphisms.length) error(404, `Could not find morphism with ID '${id}'`) - return morphisms[0] + return { type: 'morphism' as const, ...morphisms[0] } } diff --git a/src/lib/server/fetchers/structure.ts b/src/lib/server/fetchers/structure.ts index 7b17d3d3a..904389e07 100644 --- a/src/lib/server/fetchers/structure.ts +++ b/src/lib/server/fetchers/structure.ts @@ -3,6 +3,7 @@ import type { PropertyAssignmentDB, PropertyShort, RelatedStructure, + StructureDetails, StructureDisplay, StructureShort, StructureType, @@ -13,7 +14,7 @@ import sql from 'sql-template-tag' import { batch } from '$lib/server/db.catdat' import { display_property_assignment } from '$lib/server/transforms' -export function fetch_structure(type: StructureType, id: string) { +export function fetch_structure(type: StructureType, id: string): StructureDetails { const { err, results } = batch< [ StructureDisplay, diff --git a/src/pages/CategoryDetailPage.svelte b/src/pages/CategoryDetailPage.svelte new file mode 100644 index 000000000..6eaf7cee5 --- /dev/null +++ b/src/pages/CategoryDetailPage.svelte @@ -0,0 +1,77 @@ + + + + {#snippet definition()} +
  • + objects: + {@html data.objects} +
  • +
  • + morphisms: + {@html data.morphisms} +
  • + {/snippet} + + {#snippet specials()} +
    +

    Special objects

    + + {#if data.special_objects.length} +
      + {#each data.special_objects as obj} +
    • {obj.type}: {@html obj.description}
    • + {/each} +
    + {:else} +

    + {/if} +
    + +
    +

    Special morphisms

    + +
      + {#each data.special_morphisms as obj} +
    • + + {#if obj.description} + {obj.type}: {@html obj.description} + {:else} + {obj.type}: + {/if} + +
    • + {/each} +
    +
    + {/snippet} + + {#snippet footer()} + {#if data.functors.length} +
    +

    Functors

    + +

    + {pluralize(data.functors.length, { + one: 'There is 1 functor', + other: 'There are {count} functors', + })} + whose source or target is the {data.structure.name}. +

    + +
    + {/if} + {/snippet} +
    diff --git a/src/pages/FunctorDetailPage.svelte b/src/pages/FunctorDetailPage.svelte new file mode 100644 index 000000000..ebe3c1be1 --- /dev/null +++ b/src/pages/FunctorDetailPage.svelte @@ -0,0 +1,46 @@ + + + + {#snippet definition()} +
  • + Source: + {data.source_name} +
  • + +
  • + Target: + {data.target_name} +
  • + + {#if data.left_adjoint} +
  • + Left adjoint functor: + + {@html data.left_adjoint_notation} + +
  • + {/if} + + {#if data.right_adjoint} +
  • + Right adjoint functor: + + {@html data.right_adjoint_notation} + +
  • + {/if} + {/snippet} +
    diff --git a/src/pages/MorphismDetailPage.svelte b/src/pages/MorphismDetailPage.svelte new file mode 100644 index 000000000..fc15a3b83 --- /dev/null +++ b/src/pages/MorphismDetailPage.svelte @@ -0,0 +1,19 @@ + + + + {#snippet definition()} +
  • + Category: + + {data.category_name} + +
  • + {/snippet} +
    diff --git a/src/routes/[type]/[id]/+page.server.ts b/src/routes/[type]/[id]/+page.server.ts index ad64b10d7..05c13a580 100644 --- a/src/routes/[type]/[id]/+page.server.ts +++ b/src/routes/[type]/[id]/+page.server.ts @@ -7,6 +7,12 @@ import { fetch_functor } from '$lib/server/fetchers/functor' import { fetch_morphism } from '$lib/server/fetchers/morphism' import { add_math, strip_math } from '$lib/server/utils' +const special_fetchers = { + category: fetch_category, + functor: fetch_functor, + morphism: fetch_morphism, +} + export const load = (event) => { const type = event.params.type if (!is_structure_type(type)) error(404, `Invalid structure type: ${type}`) @@ -15,23 +21,16 @@ export const load = (event) => { const structure_data = fetch_structure(type, id) - // TODO: improve this mess - - const special_structure_data = - type === 'category' - ? { category: fetch_category(id) } - : type === 'functor' - ? { functor: fetch_functor(id) } - : { morphism: fetch_morphism(id) } + const special_structure_data = special_fetchers[type](id) - if (type === 'functor' && special_structure_data.functor) { + if (special_structure_data.type === 'functor') { structure_data.structure.notation = add_math( - `${strip_math(structure_data.structure.notation)}: ${strip_math(special_structure_data.functor.source_notation)} \\to ${strip_math(special_structure_data.functor.target_notation)}`, + `${strip_math(structure_data.structure.notation)}: ${strip_math(special_structure_data.source_notation)} \\to ${strip_math(special_structure_data.target_notation)}`, ) } return render_nested_formulas({ + structure_data, special_structure_data, - ...structure_data, }) } diff --git a/src/routes/[type]/[id]/+page.svelte b/src/routes/[type]/[id]/+page.svelte index 23c3e161d..e6f33eab0 100644 --- a/src/routes/[type]/[id]/+page.svelte +++ b/src/routes/[type]/[id]/+page.svelte @@ -1,130 +1,19 @@ - - -{#if data.special_structure_data.category} - {@const category = data.special_structure_data.category} - - {#snippet definition()} -
  • - objects: - {@html category.objects} -
  • -
  • - morphisms: - {@html category.morphisms} -
  • - {/snippet} - - {#snippet specials()} -
    -

    Special objects

    - - {#if category.special_objects.length} -
      - {#each category.special_objects as obj} -
    • {obj.type}: {@html obj.description}
    • - {/each} -
    - {:else} -

    - {/if} -
    - -
    -

    Special morphisms

    - -
      - {#each category.special_morphisms as obj} -
    • - - {#if obj.description} - {obj.type}: {@html obj.description} - {:else} - {obj.type}: - {/if} - -
    • - {/each} -
    -
    - {/snippet} - - {#snippet footer()} - {#if category.functors.length} -
    -

    Functors

    - -

    - {pluralize(category.functors.length, { - one: 'There is 1 functor', - other: 'There are {count} functors', - })} - whose source or target is the {data.structure.name}. -

    - -
    - {/if} - {/snippet} -
    -{:else if data.special_structure_data.functor} - {@const functor = data.special_structure_data.functor} - - {#snippet definition()} -
  • - Source: - {functor.source_name} -
  • - -
  • - Target: - {functor.target_name} -
  • +{#if data.special_structure_data.type === 'category'} + +{/if} - {#if functor.left_adjoint} -
  • - Left adjoint functor: - - {@html functor.left_adjoint_notation} - -
  • - {/if} +{#if data.special_structure_data.type === 'functor'} + +{/if} - {#if functor.right_adjoint} -
  • - Right adjoint functor: - - {@html functor.right_adjoint_notation} - -
  • - {/if} - {/snippet} -
    -{:else if data.special_structure_data.morphism} - {@const morphism = data.special_structure_data.morphism} - - {#snippet definition()} -
  • - Category: - - {morphism.category_name} - -
  • - {/snippet} -
    +{#if data.special_structure_data.type === 'morphism'} + {/if}