Skip to content

Commit

Permalink
Merge branch 'main' into refactor-k8s-hono-api
Browse files Browse the repository at this point in the history
  • Loading branch information
wruiwr authored Oct 10, 2024
2 parents 010d79b + 5b41d82 commit a0e03ef
Show file tree
Hide file tree
Showing 216 changed files with 8,830 additions and 2,385 deletions.
10 changes: 5 additions & 5 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},
"dependencies": {
"@elastic/elasticsearch": "8.12.2",
"@hono/zod-openapi": "^0.15.1",
"@hono/zod-validator": "^0.2.2",
"@hono/zod-openapi": "0.16.4",
"@hono/zod-validator": "0.4.1",
"@iiif/builder": "^2.0.1",
"@scalar/hono-api-reference": "^0.5.144",
"@scalar/hono-api-reference": "0.5.152",
"@thegetty/linkedart.js": "^0.20.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
Expand All @@ -22,7 +22,7 @@
"dotenv": "^16.4.1",
"edtf": "^4.6.0",
"fetch-retry-ts": "^1.3.1",
"hono": "^4.5.3",
"hono": "4.6.3",
"jsonld": "^8",
"jsonld-contexts": "*",
"lodash": "^4.17.21",
Expand All @@ -33,7 +33,7 @@
"rate-limiter-flexible": "5.0.0",
"rtl-detect-intl": "^0.1.2",
"types": "*",
"zod": "3.21.4"
"zod": "3.23.8"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
Expand Down
33 changes: 23 additions & 10 deletions apps/api/src/helpers/mappers/iiif/constructIIIFStructure.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { env } from '@config/env';
import { IIIFBuilder } from '@iiif/builder';
import { getPrimaryName, getRightsStatements } from '@thegetty/linkedart.js';
import { getCopyright } from './getCopyright';
import { getThumbnailVisualItem } from './getThumbnailVisualItem';

Expand All @@ -21,16 +20,14 @@ export function constructIIIFStructure(data: any) {
const filesetID = fileset?._source.id

const thumbnail = getThumbnailVisualItem(item._source)
const manifestID = `${env.API_URL}/items/${filesetID}`
const manifestID = `${env.API_URL}/items/${filesetID}?as=iiif`
const homepage = `https://marcus.uib.no/items/${filesetID}`
const rightsStatement = getRightsStatements(item._source)
console.log("🚀 ~ constructIIIFStructure ~ rightsStatement:", rightsStatement)

// Create the manifest
const manifest = builder.createManifest(
manifestID,
(manifest: any) => {
manifest.setLabel(getPrimaryName(item._source) ?? "Mangler tittel");
manifest.setLabel(item._source._label ?? { "no": ["Mangler tittel"], "en": ["Missing title"] });
if (thumbnail) {
manifest.addThumbnail({
id: thumbnail,
Expand Down Expand Up @@ -75,20 +72,36 @@ export function constructIIIFStructure(data: any) {
en: ["Attribution"]
},
value: {

/* no: ["Tilgjengeliggjort av Universitetsbiblioteket i Bergen"],
en: ["Provided by University of Bergen Library"] */
no: ["Tilgjengeliggjort av Universitetsbiblioteket i Bergen"],
en: ["Provided by University of Bergen Library"]
}
});
manifest.setRights(getCopyright(item._source, filesetID));
manifest.setMetadata([
{
label: {
no: ["Tittel"],
en: ["Title"]
},
value: { "no": ["Eksempel tittel"], "en": ["Example title"] }
},
{
label: {
no: ["Emneord"],
en: ["Keywords"]
},
value: { "no": ["Eksempel emneord"], "en": ["Example keywords"] }
}
]);

if (fileset) {
fileset._source.data.hasPart.map((item: any) => {
const root = `${env.API_URL}/items/${filesetID}`
const canvasID = `${root}/canvas/${item.sequenceNr}`
const annotationPageID = `${root}/canvas/${item.sequenceNr}/annotation-page/1`;
const annotationID = `${root}/canvas/${item.sequenceNr}/annotation/1`;
manifest.createCanvas(canvasID, (canvas: any) => {
canvas.setLabel(item._label.none[0] ?? "Mangler tittel");
canvas.setLabel({ no: [item._label.none[0] ?? "Mangler tittel"] });
canvas.setWidth(1024);
canvas.setHeight(1024);
canvas.addThumbnail({
Expand Down Expand Up @@ -126,5 +139,5 @@ export function constructIIIFStructure(data: any) {
const manifestV3: any = builder.toPresentation3({ id: manifest.id, type: 'Manifest' });
manifestV3.identifier = data.identifier

return [item, manifestV3]
return manifestV3
}
14 changes: 7 additions & 7 deletions apps/api/src/helpers/mappers/staticMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export const aatSiblingsType = {
* Rights and Licenses
*/
export const ccPublicDomainMarkType = {
id: "https://creativecommons.org/publicdomain/zero/1.0/",
id: "http://creativecommons.org/publicdomain/zero/1.0/",
type: "Type",
_label: "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
identified_by: [
Expand Down Expand Up @@ -424,7 +424,7 @@ export const rsInCopyrighttype = {
}

export const attributionNonCommercialNoDerivsType = {
id: 'https://creativecommons.org/licenses/by-nc-nd/4.0/',
id: 'http://creativecommons.org/licenses/by-nc-nd/4.0/',
type: 'Type',
_label: 'CC BY-NC-ND 4.0',
identified_by: [
Expand All @@ -450,7 +450,7 @@ export const attributionNonCommercialNoDerivsType = {
]
};
export const attributionType = {
id: 'https://creativecommons.org/licenses/by/4.0/',
id: 'http://creativecommons.org/licenses/by/4.0/',
type: 'Type',
_label: 'CC BY 4.0',
identified_by: [
Expand All @@ -476,7 +476,7 @@ export const attributionType = {
]
};
export const attributionShareAlikeType = {
id: 'https://creativecommons.org/licenses/by-sa/4.0/',
id: 'http://creativecommons.org/licenses/by-sa/4.0/',
type: 'Type',
_label: 'CC BY-SA 4.0',
identified_by: [
Expand All @@ -503,7 +503,7 @@ export const attributionShareAlikeType = {
};

export const attributionNonCommercialType = {
id: 'https://creativecommons.org/licenses/by-nc/4.0/',
id: 'http://creativecommons.org/licenses/by-nc/4.0/',
type: 'Type',
_label: 'CC NC 4.0',
identified_by: [
Expand All @@ -530,7 +530,7 @@ export const attributionNonCommercialType = {
};

export const attributionNoDerivsType = {
id: 'https://creativecommons.org/licenses/by-nd/4.0/',
id: 'http://creativecommons.org/licenses/by-nd/4.0/',
type: 'Type',
_label: 'CC ND 4.0',
identified_by: [
Expand All @@ -557,7 +557,7 @@ export const attributionNoDerivsType = {
};

export const publicDomainType = {
id: 'https://creativecommons.org/publicdomain/mark/1.0',
id: 'http://creativecommons.org/publicdomain/mark/1.0',
type: 'Type',
_label: 'Public Domain Mark',
identified_by: [
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/routes/references.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ app.get(
url: '/openapi',
},
pageTitle: 'UiB-UB API',
defaultHttpClient: {
targetKey: 'node',
clientKey: 'fetch',
}
}),
)

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/sparql/file-sets/file-set.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HTTPException } from 'hono/http-exception'

const route = new OpenAPIHono()

const PersonSchema = z.record(z.string(), z.any()).openapi('Perosn')
const PersonSchema = z.record(z.string(), z.any()).openapi('Person')

export const getItem = createRoute({
method: 'get',
Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/routes/sparql/file-sets/file-sets.route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { DATA_SOURCES } from '@config/constants'
import { cleanJsonld } from '@helpers/cleaners/cleanJsonLd'
import { createRoute, OpenAPIHono } from '@hono/zod-openapi'
import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi'
import executeQuery from '@lib/executeQuery'
import { sqb } from '@lib/sparqlQueryBuilder'
import { PaginationParamsSchema, SourceParamsSchema } from '@models'
import { listFileSetsSparqlQuery } from '@services/sparql/queries'
import { HTTPException } from 'hono/http-exception'
import jsonld, { ContextDefinition } from 'jsonld'
import ubbontContext from 'jsonld-contexts/src/ubbontContext'
import { z } from 'zod'

const route = new OpenAPIHono()

Expand Down
50 changes: 26 additions & 24 deletions apps/sps-stadnamn-web/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
# Stadnamportalen
Frontend and REST API for Språksamlingane's place name collections.

## Getting Started
Leaflet implementation based on [next-leaflet-starter](https://github.com/colbyfayock/next-leaflet-starter)

First, run the development server:
Data for elasticsearch:
https://git.app.uib.no/spraksamlingane/stadnamn/datasett/stadnamn-archive


IIIF-data:
https://git.app.uib.no/spraksamlingane/stadnamn/iiif.spraksamlingane.no

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
## Develop locally

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:
## Environment variables

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
The following environment variables are used in the application:

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
```bash
SN_ENV=local
#ES_ENDPOINT=https://search.ub.uib.no/
#ES_TOKEN=
ES_ENDPOINT=https://search.testdu.uib.no/search/ # Comment out when testing fallback
ES_TOKEN=
ES_ENDPOINT_TEST=https://search.testdu.uib.no/search/
ES_TOKEN_TEST=

```
Note that the test and production endpoints should be the same locally unless you are testing the fallback mechanism,
as indices created for local development (without pushing changes and running the cicd pipeline in stadnamn-archive) will not be available in the production cluster.
When SN_ENV is defined as prod in the vercel deployment, the test enpoint will serve as fallback.
In preview deployments, the test endpoint will be used as the primary endpoint, while the production endpoint will serve as fallback.

## Facets and fields

* Search fields: fields that can be long or are nearly 1-1 for each entry, e. g. comments
* Client facet/hierarchical facet: hierarchical facet that small enough to be handled client side - mainly administrative division
* Server facet: Supports query patterns and one level of nesting
5 changes: 3 additions & 2 deletions apps/sps-stadnamn-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"openseadragon": "^4.1.0",
"react": "^18",
"react-dom": "^18",
"react-icons": "^5.0.1",
"react-icons": "^5.3.0",
"react-leaflet": "^4.2.1"
},
"devDependencies": {
Expand All @@ -31,8 +31,9 @@
"eslint": "^8",
"eslint-config-custom": "*",
"eslint-config-next": "14.1.0",
"next-plausible": "^3.12.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"tailwindcss": "^3.4.4",
"tsconfig": "*",
"typescript": "^5"
}
Expand Down
Binary file added apps/sps-stadnamn-web/public/datasets/SOF.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/sps-stadnamn-web/public/datasets/toten.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/sps-stadnamn-web/public/fonts/no____.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions apps/sps-stadnamn-web/public/googlee3b9c58a0a12d382.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: googlee3b9c58a0a12d382.html
File renamed without changes
27 changes: 27 additions & 0 deletions apps/sps-stadnamn-web/public/markerAccentFill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions apps/sps-stadnamn-web/public/markerPrimary.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions apps/sps-stadnamn-web/public/markerPrimaryFill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a0e03ef

Please sign in to comment.