Skip to content

Commit

Permalink
Consolidate canopy and options configurations. (#171)
Browse files Browse the repository at this point in the history
* Consolidate canopy and options configurations.

* Modify test build workflows, add unit testing.
  • Loading branch information
mathewjordan authored Dec 4, 2023
1 parent 3c1422f commit 3607721
Show file tree
Hide file tree
Showing 22 changed files with 259 additions and 344 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ on: push
jobs:
test-build:
runs-on: ubuntu-latest
# Only run if the repository is canopy-iiif/canopy-iiif
if: github.repository == 'canopy-iiif/canopy-iiif'
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: IIIF Presentation API 2.x Collection (Aggregation)
- name: Unit testing
run: npm run test:ci
- name: 2.x Collection (Aggregation)
run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-2.json
- name: IIIF Presentation API 2.x Collection (Build)
- name: 2.x Collection (Build)
run: npm run test-build
- name: IIIF Presentation API 3.0 Collection (Aggregation)
- name: 3.0 Collection (Aggregation)
run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-3.json
- name: IIIF Presentation API 3.0 Collection (Build)
- name: 3.0 Collection (Build)
run: npm run test-build
- name: Customize Search (Aggregation)
run: npm run prebuild -- --path=./config/.fixtures/canopy.customize-search.json
- name: Customize Search (Build)
run: npm run test-build
- name: Minimal Configuration (Aggregation)
run: npm run prebuild -- --path=./config/.fixtures/canopy.minimal.json
- name: Minimal Configuration (Build)
run: npm run test-build
15 changes: 4 additions & 11 deletions canopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,16 @@ const args = process.argv;
?.split("=")
?.pop();

const config = buildConfig.getConfig(path);
const options = buildConfig.getOptions();
const { prod, dev } = config;
const isDev = args.includes("dev");
const config = buildConfig.getConfig(path, isDev);

config.environment = args.includes("dev") ? dev : prod;
config.options = options;

const url = args.includes("dev")
? `http://localhost:5001`
: process.env.NEXT_PUBLIC_URL;
const url = isDev ? `http://localhost:5001` : process.env.NEXT_PUBLIC_URL;
const basePath = process.env.NEXT_PUBLIC_BASE_PATH;
const baseUrl = basePath ? `${url}${basePath}` : url;

const env = {
CANOPY_CONFIG: {
...config.environment,
...config.options,
...config,
url,
basePath,
baseUrl,
Expand Down
78 changes: 64 additions & 14 deletions config/.default/canopy.default.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,68 @@
{
"prod": {
"label": { "none": ["Canopy IIIF"] },
"collection": "https://api.dc.library.northwestern.edu/api/v2/search?query=%22nez%20perce%22&as=iiif&size=250",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/cd5e1b9c-370b-40e5-b3d9-defc1d8e0777?as=iiif"
],
"metadata": ["Subject", "Date", "Dimensions"]
"collection": "https://api.dc.library.northwestern.edu/api/v2/search?query=%22nez%20perce%22&as=iiif&size=125",
"metadata": ["Subject", "Date", "Dimensions"],
"locales": [
{
"config": "locales/en.json",
"label": "English",
"lang": "en"
}
],
"map": {
"defaultBounds": [[51.505, -0.09]],
"enabled": false,
"icon": {
"iconUrl": "images/marker-icon.png",
"iconSize": [24, 36],
"iconAnchor": [12, 36]
},
"tileLayers": [
{
"name": "OpenStreetMap",
"url": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
"attribution": "&copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"
}
]
},
"dev": {
"label": { "none": ["Canopy IIIF"] },
"collection": "https://api.dc.library.northwestern.edu/api/v2/search?query=%22nez%20perce%22&as=iiif&size=250",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/cd5e1b9c-370b-40e5-b3d9-defc1d8e0777?as=iiif"
],
"metadata": ["Subject", "Date", "Dimensions"]
"search": {
"enabled": true,
"flexSearch": {
"charset": "latin:extra",
"optimize": true,
"tokenize": "strict",
"bidirectional": false,
"document": {
"index": [
{
"field": "label",
"tokenize": "full",
"resolution": 9,
"depth": 3,
"bidirectional": true
},
{
"field": "metadata",
"resolution": 2
},
{
"field": "summary",
"resolution": 1
}
]
}
},
"index": {
"metadata": {
"enabled": true,
"all": false
},
"summary": {
"enabled": false
}
}
},
"theme": {
"defaultTheme": "light",
"toggleEnabled": false
}
}
86 changes: 0 additions & 86 deletions config/.default/options.default.json

This file was deleted.

44 changes: 44 additions & 0 deletions config/.fixtures/canopy.customize-search.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif"
],
"metadata": ["Date", "Subject"],
"search": {
"enabled": true,
"flexSearch": {
"charset": ["latin:extra"],
"optimize": true,
"tokenize": "strict",
"bidirectional": false,
"document": {
"index": [
{
"field": "label",
"tokenize": "full",
"resolution": 9,
"depth": 3,
"bidirectional": true
},
{
"field": "metadata",
"resolution": 2
},
{
"field": "summary",
"resolution": 1
}
]
}
},
"index": {
"metadata": {
"enabled": true,
"all": true
},
"summary": {
"enabled": true
}
}
}
}
4 changes: 4 additions & 0 deletions config/.fixtures/canopy.dev-collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif",
"devCollection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif&size=5"
}
3 changes: 3 additions & 0 deletions config/.fixtures/canopy.minimal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif"
}
22 changes: 6 additions & 16 deletions config/.fixtures/canopy.presentation-2.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
{
"prod": {
"collection": "https://iiif.bodleian.ox.ac.uk/iiif/collection/hobhouse",
"featured": [
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/8da97e8c-4e12-457d-aad8-3327b3aec183.json",
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/2968d5c7-3718-44ef-92ea-ee4cc58cc677.json"
],
"metadata": ["Extent", "Date Statement"]
},
"dev": {
"collection": "https://iiif.bodleian.ox.ac.uk/iiif/collection/hobhouse",
"featured": [
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/8da97e8c-4e12-457d-aad8-3327b3aec183.json",
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/2968d5c7-3718-44ef-92ea-ee4cc58cc677.json"
],
"metadata": ["Extent", "Date Statement"]
}
"collection": "https://iiif.bodleian.ox.ac.uk/iiif/collection/hobhouse",
"featured": [
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/8da97e8c-4e12-457d-aad8-3327b3aec183.json",
"https://iiif.bodleian.ox.ac.uk/iiif/manifest/2968d5c7-3718-44ef-92ea-ee4cc58cc677.json"
],
"metadata": ["Extent", "Date Statement"]
}
19 changes: 5 additions & 14 deletions config/.fixtures/canopy.presentation-3.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
{
"prod": {
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif"
],
"metadata": ["Date", "Subject", "Genre", "Dimensions"]
},
"dev": {
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif"
],
"metadata": ["Date", "Subject", "Genre", "Dimensions"]
}
"collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif",
"featured": [
"https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif"
],
"metadata": ["Date", "Subject", "Genre", "Dimensions"]
}
33 changes: 10 additions & 23 deletions config/canopy.sample.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
{
"prod": {
"label": { "none": ["Collection Title"] },
"summary": {
"none": ["Brief description of the site and its contents."]
},
"collection": "https://example.org/iiif/collection.json",
"featured": [
"https://example.org/manifest-1.json",
"https://example.org/manifest-2.json"
],
"metadata": ["Date", "Subject"]
},
"dev": {
"label": { "none": ["Collection Title"] },
"summary": {
"none": ["Brief description of the site and its contents."]
},
"collection": "https://example.org/iiif/collection.json",
"featured": [
"https://example.org/manifest-1.json",
"https://example.org/manifest-2.json"
],
"metadata": ["Date", "Subject"]
"collection": "https://example.org/iiif/collection.json",
"devCollection": "https://example.org/iiif/collection-small-sample.json",
"featured": [
"https://example.org/manifest-1.json",
"https://example.org/manifest-2.json"
],
"metadata": ["Date", "Subject"],
"label": { "none": ["Collection Title"] },
"summary": {
"none": ["Brief description of the site and its contents."]
}
}
Loading

0 comments on commit 3607721

Please sign in to comment.