Skip to content

Commit

Permalink
Fixed changelog, added logic for EditionStatement, only exclude keywo…
Browse files Browse the repository at this point in the history
…rds from subject export
  • Loading branch information
brendan-oconnell committed Jul 10, 2024
1 parent a9bfb1f commit 7ef77c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- [609](https://github.com/thoth-pub/thoth/pull/609) - Update Project MUSE ONIX 3.0 export to reflect new specifications provided by Project MUSE.
- [538](https://github.com/thoth-pub/thoth/issues/538) - Update Project MUSE ONIX 3.0 export to reflect new specifications provided by Project MUSE.

## [[0.12.6]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.6) - 2024-06-17
### Fixed
Expand Down
29 changes: 25 additions & 4 deletions thoth-export-server/src/xml/onix3_project_muse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,29 @@ impl XmlElementBlock<Onix3ProjectMuse> for Work {
for contribution in &self.contributions {
XmlElementBlock::<Onix3ProjectMuse>::xml_element(contribution, w).ok();
}
if let Some(edition) = &self.edition {
if let Some(edition_statement) = match edition {
// Spell out commonest ordinals
1 => Some("First edition.".to_string()),
2 => Some("Second edition.".to_string()),
3 => Some("Third edition.".to_string()),
_ => {
let suffix = match edition % 10 {
1 if edition % 100 != 11 => "st",
2 if edition % 100 != 12 => "nd",
3 if edition % 100 != 13 => "rd",
_ => "th",
};
Some(format!("{}{} edition.", edition, suffix))
}
} {
write_element_block("EditionStatement", w, |w| {
w.write(XmlEvent::Characters(&edition_statement))
.map_err(|e| e.into())
})?;
}
}

for language in &self.languages {
XmlElementBlock::<Onix3ProjectMuse>::xml_element(language, w).ok();
}
Expand All @@ -207,10 +230,8 @@ impl XmlElementBlock<Onix3ProjectMuse> for Work {
})?;
}
for subject in &self.subjects {
// According to spec, Project MUSE only accepts BIC and BISAC subject codes
if subject.subject_type == SubjectType::BIC
|| subject.subject_type == SubjectType::BISAC
{
// Project MUSE can't process records containing keywords
if subject.subject_type != SubjectType::KEYWORD {
write_element_block("Subject", w, |w| {
XmlElement::<Onix3ProjectMuse>::xml_element(
&subject.subject_type,
Expand Down

0 comments on commit 7ef77c5

Please sign in to comment.