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

feat: human-readable display for back matter media types #861

Merged
merged 13 commits into from
May 17, 2023

Conversation

kylelaker
Copy link
Contributor

@kylelaker kylelaker commented May 15, 2023

This updates how we display resources in Back Matter to try to use a more human-readable name. When media-type is provided, we prefer that; otherwise we fallback to guessing based on the file extension using the mime-db package's database (which includes registrations with IANA as well as the Nginx and Apache databases).

The media types are largely those defined in #111 though with some additional ones found during the implementation that may be useful. The lookup algorithm is not significantly modified besides the feedback given in the issue comments.

The UI is also updated slightly to give more visual indication that it's a button and can be clicked to open the link.

Closes: #111

Screenshots

General Display:
image

OSCAL Media Types:
image

@kylelaker
Copy link
Contributor Author

Todo:

  • Better document how the lookups are performed
  • Write tests for the new code

@kylelaker kylelaker requested a review from tuckerzp May 15, 2023 22:11
@kylelaker kylelaker force-pushed the kyle/bm-media-type branch 2 times, most recently from bf79164 to 0ae16eb Compare May 15, 2023 22:16
Copy link
Contributor

@tuckerzp tuckerzp left a comment

Choose a reason for hiding this comment

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

This is looking really good so far. After seeing your implementation, I now agree mime-db is the better choice here.

Copy link
Contributor

@Bronstrom Bronstrom left a comment

Choose a reason for hiding this comment

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

This is looking good so far @kylelaker! I'm liking the choices you've made with capturing and formatting the media types are great and I think "Unrecognized" is a good fallback for when the media type isn't found.

@kylelaker kylelaker marked this pull request as ready for review May 16, 2023 16:59
Copy link
Contributor

@Bronstrom Bronstrom left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @kylelaker! I appreciate the documentation providing more reasoning on the less clear parts of the code.

@tuckerzp tuckerzp merged commit 97ebb25 into develop May 17, 2023
6 checks passed
@tuckerzp tuckerzp deleted the kyle/bm-media-type branch May 17, 2023 12:09
@kylelaker kylelaker added the enhancement New feature or request label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display Back Matter media types in a human-readable format
3 participants