-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
589 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": ["prettier-plugin-tailwindcss"], | ||
"printWidth": 120, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
apps/static-site/app/[locale]/manifests/[manifest]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Page } from "@/components/Page"; | ||
import { client, loadJson, loadRelated } from "@/iiif"; | ||
import { unstable_setRequestLocale } from "next-intl/server"; | ||
import { Manifest } from "@iiif/presentation-3"; | ||
import { ManifestPage } from "@/components/pages/ManifestPage"; | ||
import { ManifestLoader } from "@/app/provider"; | ||
import { useSearchParams } from "next/navigation"; | ||
|
||
const related = await loadRelated(); | ||
|
||
export default async function ManifestP({ params }: { params: { locale: string; manifest: string } }) { | ||
unstable_setRequestLocale(params.locale); | ||
|
||
const manifestSlug = `manifests/${params.manifest}`; | ||
const { manifest, meta } = await client.loadManifest(manifestSlug); | ||
const manifestJson = await loadJson<Manifest>(manifest); | ||
const metaJson = await loadJson(meta); | ||
|
||
const relatedItems = related[manifestSlug] || []; | ||
const relatedSnippets = ( | ||
await Promise.all( | ||
relatedItems.map(async (slug) => { | ||
try { | ||
const meta = await loadJson<any>((await client.loadManifest(slug)).meta); | ||
|
||
return { | ||
slug, | ||
label: meta.label || "Untitled", | ||
thumbnail: meta.thumbnail?.id, | ||
meta, | ||
}; | ||
} catch (e) { | ||
return null; | ||
} | ||
}) | ||
) | ||
).filter((x) => x !== null); | ||
|
||
return ( | ||
<Page> | ||
<ManifestLoader manifest={manifestJson}> | ||
<ManifestPage manifest={manifestJson} meta={metaJson as any} related={relatedSnippets} /> | ||
</ManifestLoader> | ||
</Page> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"use client"; | ||
|
||
import { InternationalString } from "@iiif/presentation-3"; | ||
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter"; | ||
import { InstantSearch, SearchBox, Hits, RefinementList } from "react-instantsearch"; | ||
import { Link } from "@/navigation"; | ||
|
||
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({ | ||
server: { | ||
apiKey: "xyz", // Be sure to use the search-only-api-key | ||
nodes: [ | ||
{ | ||
host: "localhost", | ||
port: 8108, | ||
protocol: "http", | ||
}, | ||
], | ||
}, | ||
// The following parameters are directly passed to Typesense's search API endpoint. | ||
// So you can pass any parameters supported by the search endpoint below. | ||
// queryBy is required. | ||
additionalSearchParameters: { | ||
query_by: "label,type,topic_material,topic_Maker", | ||
}, | ||
}); | ||
|
||
function Hit({ | ||
hit, | ||
}: { | ||
hit: { | ||
thumbnail: string; | ||
label: string; | ||
full_label: InternationalString; | ||
slug: string; | ||
}; | ||
}) { | ||
return ( | ||
<article> | ||
<h1>{hit.label}</h1> | ||
<img src={hit.thumbnail} /> | ||
<Link href={hit.slug}>View</Link> | ||
</article> | ||
); | ||
} | ||
|
||
export default function SearchPage() { | ||
return ( | ||
<div> | ||
<h1>Search</h1> | ||
<InstantSearch searchClient={typesenseInstantsearchAdapter.searchClient} indexName="manifests"> | ||
<SearchBox /> | ||
<RefinementList attribute="type" /> | ||
<RefinementList attribute="topic_material" /> | ||
<RefinementList attribute="topic_Maker" /> | ||
<Hits hitComponent={Hit} /> | ||
</InstantSearch> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,55 @@ | ||
import { Manifest } from "@iiif/presentation-3"; | ||
import { AutoLanguage } from "@/components/pages/AutoLanguage"; | ||
import { Exhibition } from "@repo/exhibition-viewer"; | ||
import { createPaintingAnnotationsHelper } from "@iiif/helpers/painting-annotations"; | ||
import { getRenderingStrategy } from "react-iiif-vault/utils"; | ||
import { TitlePanel } from "../exhibitions/TitleBlock"; | ||
import { InfoBlock } from "../exhibitions/InfoBlock"; | ||
import { ImageBlock } from "../exhibitions/ImageBlock"; | ||
import { MediaBlock } from "../exhibitions/MediaBlock"; | ||
|
||
export interface ExhibitionPageProps { | ||
manifest: Manifest; | ||
meta: {}; | ||
slug: string; | ||
viewObjectLinks: Array<{ service: string; slug: string; canvasId: string; targetCanvasId: string }>; | ||
} | ||
|
||
export function ExhibitionPage(props: ExhibitionPageProps) { | ||
export async function ExhibitionPage(props: ExhibitionPageProps) { | ||
const helper = createPaintingAnnotationsHelper(); | ||
const canvas: any = props.manifest.items[0]; | ||
|
||
if (!canvas) return null; | ||
|
||
return ( | ||
<div> | ||
<h1 className="text-3xl font-bold underline my-4"> | ||
<AutoLanguage>{props.manifest.label}</AutoLanguage> | ||
</h1> | ||
<div> | ||
<AutoLanguage lines className="mb-3"> | ||
{props.manifest.summary} | ||
</AutoLanguage> | ||
<AutoLanguage lines className="mb-3"> | ||
{props.manifest.requiredStatement?.label} | ||
</AutoLanguage> | ||
<AutoLanguage lines className="mb-3 font-bold italic"> | ||
{props.manifest.requiredStatement?.value} | ||
</AutoLanguage> | ||
</div> | ||
<div> | ||
<pre>{props.manifest.id}</pre> | ||
<> | ||
<div className="mt-12 auto-rows-auto grid-cols-12 content-center justify-center lg:grid"> | ||
<TitlePanel manifest={props.manifest} /> | ||
|
||
{props.manifest.items.map((canvas: any, idx) => { | ||
const paintables = helper.getPaintables(canvas); | ||
const strategy = getRenderingStrategy({ | ||
canvas, | ||
loadImageService: () => void 0, | ||
paintables, | ||
supports: ["empty", "images", "media", "3d-model", "textual-content", "complex-timeline"], | ||
}); | ||
|
||
const foundLinks = props.viewObjectLinks.filter((link) => link.canvasId === canvas.id); | ||
|
||
if (strategy.type === "textual-content") { | ||
return <InfoBlock canvas={canvas} strategy={strategy} />; | ||
} | ||
|
||
if (strategy.type === "images") { | ||
return <ImageBlock canvas={canvas} index={idx} objectLinks={foundLinks} />; | ||
} | ||
|
||
if (strategy.type === "media") { | ||
return <MediaBlock canvas={canvas} strategy={strategy} index={idx} />; | ||
} | ||
|
||
return null; | ||
})} | ||
</div> | ||
<Exhibition manifest={props.manifest} /> | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.