Skip to content

Commit

Permalink
Merge pull request #265 from carpentries/fix-keypoints
Browse files Browse the repository at this point in the history
change keypoints.html to key-points.html
  • Loading branch information
zkamvar authored Mar 3, 2022
2 parents 8ef6993 + de7af63 commit d0c14f6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 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.3.4
Version: 0.3.5
Authors@R: c(
person(given = "Zhian N.",
family = "Kamvar",
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# sandpaper 0.3.5

BUG FIX
-------

* `keypoints.html` is now rendered as `key-points.html` to fix navigation error
with varnish.

# sandpaper 0.3.4

CONTINUOUS INTEGRATION
Expand Down
4 changes: 2 additions & 2 deletions R/build_keypoints.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ build_keypoints <- function(pkg, quiet, sidebar = NULL) {
fix_nodes(html)

this_dat <- list(
this_page = "keypoints.html",
this_page = "key-points.html",
body = use_learner(html),
pagetitle = "Keypoints"
)
Expand All @@ -31,5 +31,5 @@ build_keypoints <- function(pkg, quiet, sidebar = NULL) {
page_globals$meta$update(this_dat)

build_html(template = "extra", pkg = pkg, nodes = html,
global_data = page_globals, path_md = "keypoints.html", quiet = quiet)
global_data = page_globals, path_md = "key-points.html", quiet = quiet)
}
20 changes: 10 additions & 10 deletions tests/testthat/test-build_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,37 +140,37 @@ test_that("[build_profiles()] learner and instructor views are identical", {
test_that("[build_keypoints()] works independently", {

skip_if_not(rmarkdown::pandoc_available("2.11"))
expect_false(fs::file_exists(fs::path(pkg$dst_path, "keypoints.html")))
expect_false(fs::file_exists(fs::path(pkg$dst_path, "instructor", "keypoints.html")))
expect_false(fs::file_exists(fs::path(pkg$dst_path, "key-points.html")))
expect_false(fs::file_exists(fs::path(pkg$dst_path, "instructor", "key-points.html")))
build_keypoints(pkg, quiet = TRUE)
expect_true(fs::file_exists(fs::path(pkg$dst_path, "keypoints.html")))
expect_true(fs::file_exists(fs::path(pkg$dst_path, "instructor", "keypoints.html")))
expect_true(fs::file_exists(fs::path(pkg$dst_path, "key-points.html")))
expect_true(fs::file_exists(fs::path(pkg$dst_path, "instructor", "key-points.html")))

})


test_that("[build_keypoints()] learner and instructor views are identical", {

skip_if_not(rmarkdown::pandoc_available("2.11"))
instruct <- fs::path(pkg$dst_path, "instructor", "keypoints.html")
instruct <- fs::path(pkg$dst_path, "instructor", "key-points.html")
instruct <- xml2::read_html(instruct)

# Instructor sidebar is formatted properly
sidebar <- xml2::xml_find_all(instruct, ".//div[@class='sidebar']")
expect_length(sidebar, 1L)
sidelinks <- as.character(xml2::xml_find_all(sidebar, ".//a"))
expect_length(sidelinks, 4L)
expect_match(sidelinks[[1]], "href=[\"]..[/]keypoints.html")
expect_match(sidelinks[[1]], "href=[\"]..[/]key-points.html")
expect_match(sidelinks[[2]], "Summary and Schedule")

learn <- fs::path(pkg$dst_path, "keypoints.html")
learn <- fs::path(pkg$dst_path, "key-points.html")
learn <- xml2::read_html(learn)

# Learner sidebar is formatted properly
sidebar <- xml2::xml_find_all(learn, ".//div[@class='sidebar']")
expect_length(sidebar, 1L)
sidelinks <- as.character(xml2::xml_find_all(sidebar, ".//a"))
expect_match(sidelinks[[1]], "href=[\"]instructor[/]keypoints.html")
expect_match(sidelinks[[1]], "href=[\"]instructor[/]key-points.html")
expect_match(sidelinks[[2]], "Summary and Setup")

# sections are equal
Expand All @@ -181,11 +181,11 @@ test_that("[build_keypoints()] learner and instructor views are identical", {
# the instructor metadata contains this page information
meta <- xml2::xml_find_first(instruct, ".//script[@type='application/ld+json']")
meta <- trimws(xml2::xml_text(meta))
expect_match(meta, "lesson-example/instructor/keypoints.html")
expect_match(meta, "lesson-example/instructor/key-points.html")

# the learner metadata contains this page information
meta <- xml2::xml_find_first(learn, ".//script[@type='application/ld+json']")
meta <- trimws(xml2::xml_text(meta))
expect_match(meta, "lesson-example/keypoints.html")
expect_match(meta, "lesson-example/key-points.html")
})

0 comments on commit d0c14f6

Please sign in to comment.