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

Ranges with selectors #3

Open
stephenwf opened this issue Feb 7, 2022 · 3 comments
Open

Ranges with selectors #3

stephenwf opened this issue Feb 7, 2022 · 3 comments
Milestone

Comments

@stephenwf
Copy link
Member

Currently when parsing ranges, the id is pulled out and used as a canvas reference.

https://github.com/IIIF-Commons/parser/blob/main/src/presentation-3/traverse.ts#L348-L350

{
  "type": "Range",
  "items": [
     "https://example.org/canvas-1#xywh=0,1,2,3"
  ]
}

But if the ID contains a #xywh=0,1,2,3 it will produce an invalid reference:

{
  "type": "Range",
  "items": [
    { "id": "https://example.org/canvas-1#xywh=0,1,2,3", "type": "Canvas" }
  ]
}

This is still an improvement on the original, normalising to the id / type but breaks the usual vault.get(ref) model, which you might expect to return.

This also relates to Annotation['target'] types, which are not currently normalized, for the same reason.

@stephenwf
Copy link
Member Author

Also SpecificResource

@stephenwf
Copy link
Member Author

stephenwf commented Jun 9, 2022

One possibility is to normalise:

{
  "type": "Range",
  "items": [
     "https://example.org/canvas-1#xywh=0,1,2,3",
    { "id": "https://example.org/canvas-2#xywh=0,1,2,3", "type": "Canvas" }
    { 
      "type": "SpecificResource", 
      "source": "https://example.org/canvas-3", 
      "selector": {
        "type": "FragmentSelector",
        "value": "xywh=0,1,2,3"
      } 
    }
  ]
}

into:

{
  "type": "Range",
  "items": [
    { 
      "type": "SpecificResource", 
      "source": {"id": "https://example.org/canvas-1", "type": "Canvas"},
      "selector": {
        "type": "FragmentSelector",
        "value": "xywh=0,1,2,3"
      } 
    }
    { 
      "type": "SpecificResource", 
      "source": {"id": "https://example.org/canvas-2", "type": "Canvas"},
      "selector": {
        "type": "FragmentSelector",
        "value": "xywh=0,1,2,3"
      } 
    }
    { 
      "type": "SpecificResource", 
      "source": {"id": "https://example.org/canvas-3", "type": "Canvas"},
      "selector": {
        "type": "FragmentSelector",
        "value": "xywh=0,1,2,3"
      } 
    }
  ]
}

and then feed that into the pipeline, along side ranges? An ID would be generated, need to make sure that on the way out there is an option for compressing the specific resource.

This could work along side an additional capability for vault.get() to allow:

vault.get('https://example.org/canvas-1');
vault.get({ id: 'https://example.org/canvas-1', type: 'Canvas' });
vault.get({ 
  type: 'SpecificResource', 
  source: { id: 'https://example.org/canvas-1', type: 'Canvas' },
});
vault.get({ 
  type: 'SpecificResource', 
  source: 'https://example.org/canvas-1',
});
vault.get({ 
  type: 'SpecificResource', 
  source: 'https://example.org/canvas-1',
  selector: {
    type: 'FragmentSelector',
    value" 'xywh=0,1,2,3'
  } 
});

Where these would all return the same thing. You would still need something like the Vault helper to parse the selector itself.

@stephenwf
Copy link
Member Author

A new vault helper / part of vault might be an equality helper:

resourceEquals(a, b);

Where a and b could be any of the above (string, reference, specific resource)

@stephenwf stephenwf added this to the 2.0 milestone Jul 26, 2022
@stephenwf stephenwf mentioned this issue Jul 27, 2022
9 tasks
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