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

Extend lesson YAML to enable DOI badge for peer-reviewed lessons #535

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Changes from all 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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,10 @@
appended. Note that when clicking these links, the user will remain in
instructor view. This behaviour may change in future iterations (reported:
@karenword, #394; fixed: @ErinBecker, #530, reviewed: @zkamvar)
* DOI badges can now be displayed when paired with {varnish} version 0.4.0 by
adding the `doi:` key to the `config.yaml` file with either the raw DOI or
the URL to the DOI (reported: @tobyhodges, carpentries/workbench#67;
fixed: @tobyhodges, #535).

## BUG FIX

15 changes: 10 additions & 5 deletions R/utils-yaml.R
Original file line number Diff line number Diff line change
@@ -161,6 +161,10 @@ create_pkgdown_yaml <- function(path) {
handout <- if (is.null(usr$handout)) "~" else usr$handout
handout <- if (isTRUE(handout)) "files/code-handout.R" else handout
yaml <- get_yaml_text(template_pkgdown())
# Should we display DOI info? If so, parse the URL and return the doi
# note that a missing doi will return nothing
doi <- sub("^[/]", "", xml2::url_parse(usr$doi)$path)
doi <- if (length(doi) == 1L && nzchar(doi)) siQuote(doi) else "~"
yaml <- whisker::whisker.render(yaml,
data = list(
# Basic information
@@ -182,10 +186,12 @@ create_pkgdown_yaml <- function(path) {
dc = usr$carpentry == 'dc',
swc = usr$carpentry == 'swc',
# Should we display a lifecycle banner?
life_cycle = if (usr$life_cycle == "stable") "~" else siQuote(usr$life_cycle),
pre_alpha = if (usr$life_cycle == "pre-alpha") TRUE else "~",
alpha = if (usr$life_cycle == "alpha") TRUE else "~",
beta = if (usr$life_cycle == "beta") TRUE else "~",
life_cycle = siQuote(usr$life_cycle),
pre_alpha = usr$life_cycle == "pre-alpha",
alpha = usr$life_cycle == "alpha",
beta = usr$life_cycle == "beta",
stable = usr$life_cycle == "stable",
doi = doi,
NULL
)
)
@@ -238,4 +244,3 @@ quote_config_items <- function(yaml) {
}
yaml
}

6 changes: 4 additions & 2 deletions inst/templates/pkgdown-yaml-template.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ------------------------------------------------------------------ information
# ------------------------------------------------------------------ information
# This file was generated by sandpaper version {{ version }}
# If you want to make changes, please edit {{ config }}
# ------------------------------------------------------------------ information
# ------------------------------------------------------------------ information
title: {{ title }} # needed to set the site title
home:
title: Home
@@ -27,3 +27,5 @@ template:
pre_alpha: {{ pre_alpha }}
alpha: {{ alpha }}
beta: {{ beta }}
stable: {{ stable }}
doi: {{ doi }}