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

Added new range helpers for generating more usable trees for displaying #14

Merged
merged 1 commit into from
May 9, 2024

Conversation

stephenwf
Copy link
Member

@stephenwf stephenwf commented Apr 23, 2024

Currently this will produce a tree with two types of node.

Full interface:

interface RangeTableOfContentsNode {
  id: string;
  type: 'Canvas' | 'Range';
  label: InternationalString | null;
  resource?: SpecificResource;
  untitled?: boolean;
  isCanvasLeaf: boolean;
  isRangeLeaf: boolean;
  isVirtual?: boolean;
  firstCanvas?: SpecificResource<Reference<'Canvas'>> | null;
  items?: Array<RangeTableOfContentsNode>;
}

Example Range node:

{
  "id": "https://iiif.io/api/cookbook/recipe/0024-book-4-toc/range/r1",
  "type": "Range",
  "isCanvasLeaf": false,
  "isRangeLeaf": true,
  "label": {
    "gez": [
      "Tabiba Tabiban [ጠቢበ ጠቢባን]",
    ],
  },
  "untitled": false,
  "firstCanvas": {
    "source": {
      "id": "https://iiif.io/api/cookbook/recipe/0024-book-4-toc/canvas/p1",
      "type": "Canvas",
    },
    "type": "SpecificResource",
  },
  "items": [ ... ],
}

The "Range" node contains the following:

  • isRangeLeaf: if this range only contains canvases
  • label: from the range itself, will be "Untitled" if not found
  • untitled: boolean, if it is untitled (for display)
  • firstCanvas: SpecificResource with optional selector of the first canvas, for navigation.
  • items: list of items inside the range.

Example Canvas node:

 {
  "id": "https://iiif.io/api/cookbook/recipe/0024-book-4-toc/canvas/p2",
  "isCanvasLeaf": true,
  "isRangeLeaf": false,
  "label": {
    "en": [
      "f. 1v",
    ],
  },
  "resource": {
    "source": {
      "id": "https://iiif.io/api/cookbook/recipe/0024-book-4-toc/canvas/p2",
      "type": "Canvas",
    },
    "type": "SpecificResource",
  },
  "type": "Canvas",
  "untitled": false,
}

Similar properties to the range, if you wanted to display each canvas. The label is grabbed from the canvas (if you use the helper with Vault).

It will also work with AV or regions, and use the normalized "SpecificResource" format, to make it easier to use.

{
  "id": "https://iiif.io/api/cookbook/recipe/0026-toc-opera/canvas/1#t=0,302.05",
  "isCanvasLeaf": true,
  "isRangeLeaf": false,
  "label": {
    "none": [
      "Untitled",
    ],
  },
  "resource": {
    "selector": {
      "type": "FragmentSelector",
      "value": "t=0,302.05",
    },
    "source": {
      "id": "https://iiif.io/api/cookbook/recipe/0026-toc-opera/canvas/1",
      "type": "Canvas",
    },
    "type": "SpecificResource",
  },
  "type": "Canvas",
  "untitled": true,
}

In this example, the canvas ID is pulled out, but the range is Untitled and marked as untitled. The time selector is also pulled out. (Other helpers in the repo can be used to parse it further).

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@stephenwf stephenwf merged commit ea122eb into main May 9, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

1 participant