Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path-to-regexp for slug config #8

Open
stephenwf opened this issue Jan 10, 2025 · 0 comments
Open

Add path-to-regexp for slug config #8

stephenwf opened this issue Jan 10, 2025 · 0 comments

Comments

@stephenwf
Copy link
Member

stephenwf commented Jan 10, 2025

The headless static site needs to know how to extract IDs from URLs in order to map remote resources.

For example:

https://iiif.wellcomecollection.org/presentation/b30496974

This points to a IIIF Manifest, we want to be able to extract:

b30496974

And also optionally add a prefix, so that on the headless static site output it can be found at:

/manifests/wellcome-b30496974

In order to this currently we have a configuration object that must be specified by the user:

slugs:
  wellcome-manifest:
    type: Manifest
    domain: iiif.wellcomecollection.org
    prefix: /presentation/
    addedPrefix: wellcome-
    examples:
      - https://iiif.wellcomecollection.org/presentation/b30496974

An alternative might be possible with Path to regex which is fast.

Here is the current store configuration, which references the slugs config above.

  wellcomePaintings:
    type: iiif-remote
    url: https://iiif.wellcomecollection.org/presentation/collections/digitalcollections/digpaintings
    slugTemplates:
      - wellcome-manifest
      - wellcome-collection

With path-to-regex it could be:

wellcomePaintings:
  type: iiif-remote
  url: https://iiif.wellcomecollection.org/presentation/collections/digitalcollections/digpaintings
  router:
    - from: https://iiif.wellcomecollection.org/presentation/collections/{*collectionPath}
      to: /collections/{*collectionPath}

    - from: https://iiif.wellcomecollection.org/presentation/{manifestId}
      to: /manifests/wellcome-{manifestId}

That would greatly simplify both the configuration and implementation.

With this configuration, if a static page was requested:

/manifests/wellcome-b30496974

The configuration provides enough information to match it against the router.

 from: https://iiif.wellcomecollection.org/presentation/{manifestId}
+to: /manifests/wellcome-{manifestId}

And then find the original manifest to fetch:

https://iiif.wellcomecollection.org/presentation/{manifestId}

Fetching:

https://iiif.wellcomecollection.org/presentation/b30496974

It would also still have the original path to fetch the meta.json and indices.json which are not hosted at Wellcome:

/iiif/manifests/wellcome-b30496974/meta.json
/iiif/manifests/wellcome-b30496974/indices.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant