Skip to content

Commit

Permalink
Merge pull request #620 from carpentries/frog-license-1
Browse files Browse the repository at this point in the history
Fix config license change, add support for custom license_url
  • Loading branch information
ErinBecker authored Nov 22, 2024
2 parents d174084 + c4069cc commit bf7a758
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions R/utils-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ initialise_metadata <- function(path = ".") {
this_metadata$set("metadata_template", readLines(template_metadata()))
this_metadata$set("pagetitle", cfg$title)
this_metadata$set("keywords", cfg$keywords)
this_metadata$set("license", cfg$license)
this_metadata$set("license_url", cfg$license_url %||% "LICENSE.html")
created <- cfg$created %||% tail(gert::git_log(max = 1e6, repo = path)$time, 1)
this_metadata$set(c("date", "created"), format(as.Date(created), "%F"))
# TODO: implement custom DESCRIPTION
Expand Down
6 changes: 5 additions & 1 deletion R/utils-translate.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ establish_translation_vars <- function() {
Cite = tr_('Cite'),
Contact = tr_('Contact'),
About = tr_('About'),
MaterialsLicensedUnder = tr_('Materials licensed under {license} by the authors'),
MaterialsLicensedUnder = tr_('Materials licensed under <({license})> by the authors'),
TemplateLicense = tr_('Template licensed under <(CC-BY 4.0)> by {template_authors}'),
Carpentries = tr_('The Carpentries'),
BuiltWith = tr_('Built with {sandpaper_link}, {pegboard_link}, and {varnish_link}'),
Expand Down Expand Up @@ -432,6 +432,7 @@ fill_translation_vars <- function(the_data) {
icons = named_icons,
template_authors = '<a href="https://carpentries.org/">The Carpentries</a>',
license = the_data$license %||% "CC-BY 4.0",
license_url = the_data$license_url %||% "LICENSE.html",
minutes = the_data$minutes %||% NULL,
updated = the_data$updated %||% NULL
)
Expand Down Expand Up @@ -463,6 +464,9 @@ fill_translation_vars <- function(the_data) {
TemplateLicense = replace_link(the_string,
href = "https://creativecommons.org/licenses/by-sa/4.0/"
),
MaterialsLicensedUnder = replace_link(the_string,
href = dat$license_url
),
SpanToTop = replace_html(the_string,
open = '<span class="d-none d-sm-none d-md-none d-lg-none d-xl-block">',
close = '</span>'
Expand Down
8 changes: 6 additions & 2 deletions R/utils-varnish.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ set_globals <- function(path) {
sidebar = learner_sidebar,
more = paste(learner$extras, collapse = ""),
resources = paste(learner$resources, collapse = ""),
translate = tr_varnish()
translate = tr_varnish(),
license = this_metadata$get()[["license"]],
license_url = this_metadata$get()[["license_url"]]
), pkg_versions)
)
instructor_globals$set(key = NULL,
Expand All @@ -125,7 +127,9 @@ set_globals <- function(path) {
sidebar = instructor_sidebar,
more = paste(instructor$extras, collapse = ""),
resources = paste(instructor$resources, collapse = ""),
translate = tr_varnish()
translate = tr_varnish(),
license = this_metadata$get()[["license"]],
license_url = this_metadata$get()[["license_url"]]
), pkg_versions)
)
}
Expand Down

0 comments on commit bf7a758

Please sign in to comment.