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

Allow setting a custom Carpentry type #585

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/utils-yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ create_pkgdown_yaml <- function(path) {
branch = siQuote(usr$branch),
contact = siQuote(usr$contact),
# What carpentry are we dealing with?
carpentry_name = siQuote(which_carpentry(usr$carpentry)),
carpentry_name = siQuote(which_carpentry(usr$carpentry, usr$carpentry_description)),
carpentry = siQuote(usr$carpentry),
carpentry_icon = siQuote(which_icon_carpentry(usr$carpentry)),
license = siQuote(usr$license),
Expand Down
5 changes: 4 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ create_description <- function(path) {
desc$write(fs::path(path_site(path), "DESCRIPTION"))
}

which_carpentry <- function(carpentry) {
which_carpentry <- function(carpentry, carpentry_description = NULL) {
if (!is.null(carpentry_description)) {
return(carpentry_description)
}
switch(carpentry,
lc = "Library Carpentry",
dc = "Data Carpentry",
Expand Down
7 changes: 7 additions & 0 deletions inst/templates/config-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
# lc: Library Carpentry
# cp: Carpentries (to use for instructor training for instance)
# incubator: The Carpentries Incubator
# Note that you can also use a custom carpentry type. For more info,
# see the varnish documentation.
milanmlft marked this conversation as resolved.
Show resolved Hide resolved
milanmlft marked this conversation as resolved.
Show resolved Hide resolved
# TODO: add link to varnish documentation once it's there
carpentry: {{ carpentry }}

# Custom carpentry description
# This will be used as the alt text for the logo
# carpentry_description: "Custom Carpentry"

# Overall title for pages.
title: {{ title }}

Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ test_that("a sitemap can be generated for urls", {
urls <- c("https://example.com/one", "https://example.com/two")
expect_snapshot(urls_to_sitemap(urls))
})

test_that("which_carpentry_workshop works for default carpentries", {
expect_equal(which_carpentry("swc"), "Software Carpentry")
expect_equal(which_carpentry("dc"), "Data Carpentry")
expect_equal(which_carpentry("lc"), "Library Carpentry")
expect_equal(which_carpentry("cp"), "The Carpentries")
})

test_that("which_carpentry can take a custom description", {
expect_equal(which_carpentry("ice-cream", "Ice Cream Carpentry"), "Ice Cream Carpentry")
expect_equal(which_carpentry("mexican-guitars"), "mexican-guitars")
})
Loading