Skip to content

Commit

Permalink
Merge pull request #561 from carpentries/release-0.16.2
Browse files Browse the repository at this point in the history
Add `inLanguage` metadata item; Release 0.16.2
  • Loading branch information
zkamvar authored Dec 19, 2023
2 parents 1529dfd + 155efd6 commit ed0bd3f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sandpaper
Title: Create and Curate Carpentries Lessons
Version: 0.16.1.9000
Version: 0.16.2
Authors@R: c(
person(given = "Zhian N.",
family = "Kamvar",
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# sandpaper 0.16.1.9000 (unreleased)
# sandpaper 0.16.2 (2023-12-19)

## MISC

* JSON metadata now contains the `inLanguage` key.

## DOCUMENTATION

Expand Down
1 change: 1 addition & 0 deletions R/utils-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fill_metadata_template <- function(meta) {
if (endsWith(local_meta$url, "/")) {
local_meta$url <- paste0(local_meta$url, "index.html")
}
local_meta$lang <- sub("_", "-", local_meta$lang %||% "en")
title <- local_meta$pagetitle
if (grepl("<", title, fixed = TRUE)) {
local_meta$pagetitle <- xml2::xml_text(xml2::read_html(title))
Expand Down
1 change: 1 addition & 0 deletions inst/templates/metadata-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"@context": "https://schema.org",
"@type": "TrainingMaterial",
"@id": "<% url %>",
"inLanguage": "<% lang %>",
"dct:conformsTo": "https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE",
"description": "<% desc %><% ^desc %>A Carpentries Lesson teaching foundational data and coding skills to researchers worldwide<% /desc %>",
"keywords": "<% keywords %><% ^keywords %>software,data,lesson,The Carpentries<% /keywords %>",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/utils-metadata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# metadata can be initialised with custom items added

"{\n \"@context\": \"https://schema.org\",\n \"@type\": \"TrainingMaterial\",\n \"@id\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"dct:conformsTo\": \"https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE\",\n \"description\": \"A Carpentries Lesson teaching foundational data and coding skills to researchers worldwide\",\n \"keywords\": \"software, data, lesson, The Carpentries\",\n \"name\": \"The Importance of Being Ernest Scared Stupid\",\n \"creativeWorkStatus\": \"active\",\n \"url\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"identifier\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"dateCreated\": \"2022-02-01\",\n \"dateModified\": \"2022-02-08\",\n \"datePublished\": \"2022-02-09\"\n}\n"
"{\n \"@context\": \"https://schema.org\",\n \"@type\": \"TrainingMaterial\",\n \"@id\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"inLanguage\": \"en\",\n \"dct:conformsTo\": \"https://bioschemas.org/profiles/TrainingMaterial/1.0-RELEASE\",\n \"description\": \"A Carpentries Lesson teaching foundational data and coding skills to researchers worldwide\",\n \"keywords\": \"software, data, lesson, The Carpentries\",\n \"name\": \"The Importance of Being Ernest Scared Stupid\",\n \"creativeWorkStatus\": \"active\",\n \"url\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"identifier\": \"https://zkamvar.github.io/lesson-example/vern.html\",\n \"dateCreated\": \"2022-02-01\",\n \"dateModified\": \"2022-02-08\",\n \"datePublished\": \"2022-02-09\"\n}\n"

13 changes: 12 additions & 1 deletion tests/testthat/test-utils-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,27 @@ test_that("metadata can be initialised with custom items added ", {
on.exit(this_metadata$clear())
# metadata has same values as config
expect_equal(this_metadata$get()[["carpentry"]], "incubator")
met <- create_metadata_jsonld(res,
met <- create_metadata_jsonld(res,
date = list(created = "2022-02-01", modified = "2022-02-08", published = "2022-02-09"),
pagetitle = "The Importance of Being Ernest Scared Stupid",
url = "https://zkamvar.github.io/lesson-example/vern.html"
)
expect_type(met, "character")
expect_match(met, "Ernest Scared Stupid")
expect_match(met, "\"inLanguage\": \"en\"", fixed = TRUE)
expect_length(met, 1L)
skip_on_os("windows") # dang carriage returns
expect_snapshot_value(met)

met <- create_metadata_jsonld(res,
pagetitle = "The Importance of Being Ernest Scared Stupid",
url = "https://zkamvar.github.io/lesson-example/vern.html",
lang = "es_AR"
)
expect_type(met, "character")
expect_match(met, "Ernest Scared Stupid")
expect_match(met, "\"inLanguage\": \"es-AR\"", fixed = TRUE)
expect_length(met, 1L)
})


0 comments on commit ed0bd3f

Please sign in to comment.