presentation/views/ontology.view.ts

presentation/views/ontology.view.ts is a file in Bane's Lab Site. 73 lines of code and 4 definitions.

import {
    AUTHOR,
    DATASET_FRAGMENT,
    DATASET_TYPE,
    DATA_CATALOG,
    DATA_CATALOG_ID,
} from "#configuration/constants/schema.constants";
import {
    CREATIVE_COMMONS,
    REPOSITORY_TREE,
    SITE_URL,
    faceIndexPath,
    pageIndexPath,
    pagePath,
} from "#core/assets/link.assets";
import { CREATIVE_COMMONS_LICENSE, ONTOLOGY_DESCRIPTION, ONTOLOGY_TITLE } from "#configuration/strings/page.strings";
import { mountTabSwitching, renderTabbedPage } from "#presentation/widgets/tab.widget";
import { JSON_FORMAT } from "#configuration/constants/code.constants";
import { ONTOLOGY_FACES } from "@govlab/constants";
import { ONTOLOGY_META } from "#configuration/strings/ontology.strings";
import { ONTOLOGY_PAGE } from "#core/ids/page.ids";
import { ONTOLOGY_TABS } from "#configuration/strings/ontology.fragment.strings";
import { ONTOLOGY_TONE } from "#configuration/constants/tab.constants";
import type { PageDefinition } from "#types/page.types";
import type { SchemaEntity } from "#types/schema.types";
import type { TabbedPage } from "#types/tab.types";

const ONTOLOGY_ENTITY: SchemaEntity = {
    "@id": SITE_URL + pagePath(ONTOLOGY_PAGE) + DATASET_FRAGMENT,
    "@type": DATASET_TYPE,
    creator: AUTHOR,
    description: ONTOLOGY_DESCRIPTION,
    distribution: [...ONTOLOGY_FACES].map((face) => ({
        "@type": "DataDownload",
        contentUrl: SITE_URL + faceIndexPath(face),
        encodingFormat: JSON_FORMAT,
        name: face,
    })),
    identifier: SITE_URL + pageIndexPath(ONTOLOGY_PAGE),
    includedInDataCatalog: { "@id": DATA_CATALOG_ID },
    isAccessibleForFree: true,
    keywords: [...ONTOLOGY_FACES],
    license: CREATIVE_COMMONS,
    name: ONTOLOGY_META.title,
    sameAs: REPOSITORY_TREE + ONTOLOGY_PAGE,
    url: SITE_URL + pagePath(ONTOLOGY_PAGE),
    version: ONTOLOGY_META.version,
};

const DEFINITION: TabbedPage = {
    layout: "grid",
    meta: ONTOLOGY_META,
    page: ONTOLOGY_PAGE,
    tabs: ONTOLOGY_TABS,
    tone: ONTOLOGY_TONE,
};

const renderOntology = function renderOntology(): Element {
    return renderTabbedPage(DEFINITION);
};

void mountTabSwitching(DEFINITION);

export const PAGE: PageDefinition = {
    content: {
        kind: "tabbed",
        layout: DEFINITION.layout,
        meta: ONTOLOGY_META,
        tabs: ONTOLOGY_TABS,
        tone: DEFINITION.tone,
    },
    description: ONTOLOGY_DESCRIPTION,
    entities: [ONTOLOGY_ENTITY, DATA_CATALOG],
    id: ONTOLOGY_PAGE,
    license: CREATIVE_COMMONS_LICENSE,
    render: renderOntology,
    title: ONTOLOGY_TITLE,
};