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 support for navPlace element #86

Merged
merged 5 commits into from
Nov 21, 2023

Conversation

peetucket
Copy link
Collaborator

Fixes sul-dlss/purl#761 : moves navPlace generation from PURL (added here: sul-dlss/purl#752) to the iiif-presentation gem, as well as removes knowledge of public-xml from the class that generates it (and instead leaves that knowledge in PURL).

Will be paired with a PURL PR to remove this NavPlace class and replace with a call to this class.

VERSION Outdated Show resolved Hide resolved
def coord_for(long_str, lat_str)
long_matcher = long_str.match(COORD_REGEX)
lat_matcher = lat_str.match(COORD_REGEX)
return unless long_matcher && lat_matcher
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to silently fail here, or would an argument exception make it clear that what you are doing is not valid?

Copy link
Collaborator Author

@peetucket peetucket Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I am the correct person to answer this, as this was just a refactor PR to move existing code in PURL to here....but my guess is that by silently failing, we prevent the method from blowing up if there is geo data (in the MODs) but it is not formatted correctly. If we throw an exception, in these cases I'd think we would hit errors in PURL until the data is remediated? Or perhaps there can be multiple formats of geo data in MODs and we only handle one case here?

this is the path where the data is coming from: https://github.com/sul-dlss/purl/pull/821/files#diff-01029093f0ab5a19645c20b7e361bc54e695ff29144aacf226a61bca8dfdd554R353

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you ought to check if you have usable data before calling this method. I think this should let you know when you give it the wrong data. Otherwise it becomes a mystery you have to track down.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

  1. Add a new method to this class to validate coordinates -- it returns true/false
  2. Caller (currently only PURL), calls this first and then only calls build if valid, otherwise noop (or if you really want to raise in PURL, we can do that too, but I will note that is not what is happening in production at the moment and for this refactor work, I'd suggest preserving functionality as is).
  3. build method raises an exception if invalid coordinates are sent in anyway.

Is that what you are thinking

Copy link
Collaborator

@jcoyne jcoyne Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only thinking of 3 for this gem. You, as the user of the gem can determine how you want to ensure what you're passing in is "good". That could be validating the data before you store it, or filtering out the data you have before you call this method.

If doing 1, also helps you acchieve step 3, then go for it. It's probably better that there is a separate method that validates anyways.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did both 1 & 3 (added a .valid? method and used it to determine if we raise an exception on .build?). PURL can use this .valid? method to keep current functionality as is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the validate method be checking the COORD_REGEX though?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I see it does that.

lib/iiif/v3/presentation/nav_place.rb Outdated Show resolved Hide resolved
@peetucket
Copy link
Collaborator Author

Can you merge and then bump version/cut release? I don't have permissions on this repo to do that. I can then move to the PURL changes.

@jcoyne jcoyne merged commit 681baee into iiif-prezi:main Nov 21, 2023
4 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.

Refactor: Move IIIF NavPlace generation to iiif-prezi/osullivan
2 participants