Skip to content

Commit

Permalink
Merge branch 'slides' into new-ag
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO authored Nov 24, 2023
2 parents 047dfd1 + e17c41b commit b5e7445
Show file tree
Hide file tree
Showing 38 changed files with 515 additions and 209 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
permissions:
contents: read
steps:
- uses: inbo/actions/check_pkg@checklist-0.3.2
- uses: inbo/actions/check_pkg@checklist-0.3.6
2 changes: 1 addition & 1 deletion .github/workflows/check_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: inbo/actions/check_pkg@checklist-0.3.2
- uses: inbo/actions/check_pkg@checklist-0.3.6
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: checkout
uses: actions/checkout@v2
- name: build examples
uses: inbo/actions/render_inbomd@inbomd-0.6.0
uses: inbo/actions/render_inbomd@inbomd-0.6.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXAMPLE_BRANCH: main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Get tag message
run: |
TAG=$(git tag --contains $(git rev-parse HEAD))
TAG_BODY=$(git tag --contains {{ github.sha }} -n100 | awk '(NR>1)')
TAG_BODY=$(git tag --contains $(git rev-parse HEAD) -n100 | awk '(NR>2)')
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "TAG_BODY=$TAG_BODY" >> $GITHUB_OUTPUT
id: tag-body
Expand Down
6 changes: 5 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "INBOmd: Markdown Templates for INBO",
"version": "0.6.1",
"version": "0.6.2",
"license": "GPL-3.0",
"upload_type": "software",
"description": "<p>Several templates to generate reports, presentations and posters.<\/p>",
Expand All @@ -15,16 +15,19 @@
"contributors": [
{
"name": "Onkelinx, Thierry",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0001-8804-4216",
"type": "ContactPerson"
},
{
"name": "Vanderhaeghe, Floris",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0002-6378-6229",
"type": "ProjectMember"
},
{
"name": "Lommelen, Els",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0002-3481-5684",
"type": "ProjectMember"
},
Expand All @@ -36,6 +39,7 @@
"creators": [
{
"name": "Onkelinx, Thierry",
"affiliation": "Research Institute for Nature and Forest (INBO)",
"orcid": "0000-0001-8804-4216"
}
],
Expand Down
10 changes: 6 additions & 4 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
cff-version: 1.2.0
message: If you use this software, please cite it using these metadata.
title: 'INBOmd: Markdown Templates for INBO'
title: "INBOmd: Markdown Templates for INBO"
authors:
- given-names: Thierry
family-names: Onkelinx
affiliation: Research Institute for Nature and Forest (INBO)
orcid: 0000-0001-8804-4216
keywords:
- markdown
Expand All @@ -13,15 +14,16 @@ keywords:
contact:
- given-names: Thierry
family-names: Onkelinx
affiliation: Research Institute for Nature and Forest (INBO)
orcid: 0000-0001-8804-4216
doi: 10.5281/zenodo.842223
license: GPL-3.0
repository-code: https://github.com/inbo/INBOmd/
type: software
abstract: Several templates to generate reports, presentations and posters.
abstract: "Several templates to generate reports, presentations and posters."
identifiers:
- type: doi
value: 10.5281/zenodo.842223
- type: url
value: []
version: 0.6.1
value: https://inbo.github.io/INBOmd/
version: 0.6.2
13 changes: 8 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
Type: Package
Package: INBOmd
Title: Markdown Templates for INBO
Version: 0.6.1
Version: 0.6.2
Authors@R: c(
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216")),
comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Floris", "Vanderhaeghe", , "floris.vanderhaeghe@inbo.be", role = "ctb",
comment = c(ORCID = "0000-0002-6378-6229")),
comment = c(ORCID = "0000-0002-6378-6229", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Els", "Lommelen", , "els.lommelen@inbo.be", role = "ctb",
comment = c(ORCID = "0000-0002-3481-5684")),
comment = c(ORCID = "0000-0002-3481-5684", affiliation = "Research Institute for Nature and Forest (INBO)")),
person("Research Institute for Nature and Forest (INBO)", , , "info@inbo.be", role = c("cph", "fnd"))
)
Description: Several templates to generate reports, presentations and
posters.
License: GPL-3
URL: https://github.com/inbo/inbomd, https://doi.org/10.5281/zenodo.842223
URL: https://inbo.github.io/INBOmd/, https://github.com/inbo/inbomd,
https://doi.org/10.5281/zenodo.842223
BugReports: https://github.com/inbo/inbomd/issues
Depends:
R (>= 3.5.0)
Imports:
assertthat,
bookdown (>= 0.23.4),
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ RUN mkdir ${HOME}/.fonts \
&& fc-cache -fv \
&& Rscript -e 'tinytex:::updmap()'

## Install kableExtra
RUN Rscript -e 'remotes::install_cran("kableExtra")'

## Install current version of INBOmd
COPY .Rbuildignore inbomd/.Rbuildignore
COPY DESCRIPTION inbomd/DESCRIPTION
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ importFrom(bookdown,gitbook)
importFrom(bookdown,pdf_book)
importFrom(checklist,ask_yes_no)
importFrom(checklist,menu_first)
importFrom(checklist,organisation)
importFrom(checklist,read_checklist)
importFrom(checklist,use_author)
importFrom(dplyr,"%>%")
Expand All @@ -72,7 +73,7 @@ importFrom(knitr,kable)
importFrom(knitr,opts_current)
importFrom(knitr,opts_knit)
importFrom(pdftools,pdf_convert)
importFrom(qrcode,qrcode_gen)
importFrom(qrcode,qr_code)
importFrom(rmarkdown,includes_to_pandoc_args)
importFrom(rmarkdown,knitr_options)
importFrom(rmarkdown,output_format)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# INBOmd 0.6.2

* Bugfixes

# INBOmd 0.6.1

* INBO authors and reviewers now must use their `orcid` and a standardised
`affiliation`.
We infer INBO membership from the author's email address.
* `create_report()` and `add_author()` will set the INBO author affiliation in
the language of the report.
* `slides()` no longer requires a reviewer.
* Install missing `TinyTeX` installation or packages.
* Bugfixes in `create_report()`.

# INBOmd 0.6.0
Expand Down
9 changes: 8 additions & 1 deletion R/add_author.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ add_author <- function(path = ".") {

path(path, "index.Rmd") |>
readLines() -> index
lang <- grep("^lang:", index)
assert_that(length(lang) > 0, msg = "No `lang:` entry found in yaml header")
assert_that(
length(lang) == 1, msg = "Multiple `lang:` entries found in yaml header"
)
lang <- gsub("lang: ", "", index[lang])

author <- grep("^author:", index)
assert_that(
length(author) > 0, msg = "No `author:` entry found in yaml header"
)
assert_that(
length(author) == 1, msg = "Multiple `author:` entries found in yaml header"
)
use_author() |>
check_author(lang = lang) |>
author2yaml(corresponding = FALSE) -> extra
top <- grep("^\\w+:", index) - 1
insert <- head(top[top > author], 1)
Expand Down
45 changes: 38 additions & 7 deletions R/create_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
#' @family utils
#' @export
#' @importFrom assertthat assert_that is.string noNA
#' @importFrom checklist ask_yes_no menu_first read_checklist use_author
#' @importFrom checklist ask_yes_no menu_first organisation read_checklist
#' use_author
#' @importFrom fs dir_create file_copy is_dir is_file path
#' @importFrom gert git_find
create_report <- function(path = ".", shortname) {
Expand All @@ -37,6 +38,16 @@ msg = "The report name folder may only contain lower case letters, digits and _"
msg = "The report name folder already exists."
)

lang <- c(nl = "Dutch", en = "English", fr = "French")
lang <- names(lang)[
menu_first(lang, title = "What is the main language of the report?")
]
style <- c("INBO", "Vlaanderen")
style <- ifelse(
lang != "nl", "Flanders",
style[menu_first(style, title = "Which style to use?")]
)

# build new yaml
readline(prompt = "Enter the title: ") |>
gsub(pattern = "[\"|']", replacement = "") |>
Expand All @@ -47,10 +58,10 @@ msg = "The report name folder may only contain lower case letters, digits and _"
gsub(pattern = "[\"|']", replacement = "") -> subtitle
yaml <- c(yaml, paste("subtitle:", subtitle)[subtitle != ""])
cat("Please select the corresponding author")
authors <- use_author()
authors <- check_author(lang = lang)
c(yaml, "author:", author2yaml(authors, corresponding = TRUE)) -> yaml
while (isTRUE(ask_yes_no("Add another author?", default = FALSE))) {
author <- use_author()
author <- check_author(lang = lang)
authors[, c("given", "family", "email")] |>
rbind(author[, c("given", "family", "email")]) |>
anyDuplicated() -> duplo
Expand All @@ -66,7 +77,7 @@ msg = "The report name folder may only contain lower case letters, digits and _"
cat("Please select the reviewer")
duplo <- 1
while (duplo > 0) {
author <- use_author()
author <- check_author(lang = lang)
authors[, c("given", "family", "email")] |>
rbind(author[, c("given", "family", "email")]) |>
anyDuplicated() -> duplo
Expand All @@ -80,6 +91,8 @@ msg = "The report name folder may only contain lower case letters, digits and _"
lang <- names(lang)[
menu_first(lang, title = "What is the main language of the report?")
]
org <- organisation$new()
aff <- org$get_organisation[["inbo.be"]]$affiliation[lang]
style <- c("INBO", "Vlaanderen")
style <- ifelse(
lang != "nl", "Flanders",
Expand All @@ -106,8 +119,7 @@ msg = "The report name folder may only contain lower case letters, digits and _"
"lof: TRUE"[ask_yes_no("Do you want a list of figures?", default = FALSE)],
"lot: TRUE"[ask_yes_no("Do you want a list of tables?", default = FALSE)],
keywords, "community: \"inbo\"", "publication_type: report",
"funder: Research Institute for Nature and Forest (INBO)",
"rightsholder: Research Institute for Nature and Forest (INBO)",
paste("funder:", aff), paste("rightsholder:", aff),
"bibliography: references.bib", "link-citations: TRUE",
"site: bookdown::bookdown_site", "output:", " INBOmd::gitbook: default",
" INBOmd::pdf_report: default", " INBOmd::epub_book: default",
Expand Down Expand Up @@ -245,7 +257,7 @@ author2yaml <- function(author, corresponding = FALSE) {
yaml <- c(yaml, sprintf(" orcid: \"%s\"", author$orcid))
}
if (!is.na(author$affiliation) && author$affiliation != "") {
yaml <- c(yaml, paste(" affiliation: \"%s\"", author$affiliation))
yaml <- c(yaml, sprintf(" affiliation: \"%s\"", author$affiliation))
}
if (!corresponding) {
return(paste(yaml, collapse = "\n"))
Expand Down Expand Up @@ -280,3 +292,22 @@ add_address <- function(type = "client") {
sprintf("%s_logo: %s", type, logo)[logo != ""]
)
}

#' @importFrom checklist use_author
check_author <- function(lang = "nl") {
person <- use_author()
if (is_inbo(person) && !person$affiliation %in% inbo_affiliation) {
paste0("`", inbo_affiliation, "`", collapse = "; ") |>
sprintf(fmt = "INBO staff must use one of %s as affiliation.") |>
cat("Please update the author information.", "\n", sep = " ")
person <- check_author(lang = "nl")
person$affiliation <- inbo_affiliation[lang]
}
if (is_inbo(person) && is.na(person$orcid)) {
cat(
"INBO staff must provide an ORCID.",
"Please update the author information.", "\n", sep = " "
)
person <- check_author(lang = "nl")
}
}
22 changes: 21 additions & 1 deletion R/ebook.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ epub_book <- function() {
yaml_front_matter() |>
validate_persons(reviewer = TRUE) |>
validate_rightsholder() -> fm
assert_that(
!has_name(fm, "nocolophon"), msg = "Legacy option `nocolophon` detected.
Please use the `public_report` option."
)
style <- ifelse(has_name(fm, "style"), fm$style, "INBO")
assert_that(length(style) == 1)
assert_that(style %in% c("INBO", "Vlaanderen", "Flanders"),
Expand All @@ -40,7 +44,6 @@ epub_book <- function() {
style == "Flanders" || lang == "nl",
msg = "Use style: Flanders when the language is not nl"
)
validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1"))

pandoc_args <- c(
"--csl",
Expand All @@ -50,6 +53,23 @@ epub_book <- function() {
"--lua-filter",
system.file(file.path("pandoc", "translations.lua"), package = "INBOmd")
)
validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1"))
if (
!has_name(fm, "doi") && has_name(fm, "public_report") && !fm$public_report
) {
Sys.time() |>
format("%Y-%m-%d %H:%M:%S") |>
c(fm$reportnr) |>
tail(1) |>
pandoc_variable_arg(name = "pagefootmessage") |>
c(pandoc_variable_arg("internal", "true")) |>
c(pandoc_args) -> pandoc_args
} else {
c(fm$doi, "!!! missing DOI !!!") |>
head(1) |>
pandoc_variable_arg(name = "doi") |>
c(pandoc_args) -> pandoc_args
}
file.path("css_styles", c("fonts", "img")) |>
system.file(package = "INBOmd") |>
list.files(full.names = TRUE) -> fonts
Expand Down
23 changes: 20 additions & 3 deletions R/gitbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ gitbook <- function(code_folding = c("none", "show", "hide")) {
split_by %in% c("chapter+number", "section+number"),
msg = "`split_by` must be either 'chapter+number' or `section+number`"
)
validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1"))

pandoc_args <- c(
"--csl",
Expand All @@ -63,6 +62,24 @@ gitbook <- function(code_folding = c("none", "show", "hide")) {
"--lua-filter",
system.file(file.path("pandoc", "translations.lua"), package = "INBOmd")
)
validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1"))
if (
!has_name(fm, "doi") && has_name(fm, "public_report") && !fm$public_report
) {
Sys.time() |>
format("%Y-%m-%d %H:%M:%S") |>
c(fm$reportnr) |>
tail(1) |>
pandoc_variable_arg(name = "pagefootmessage") |>
c(pandoc_variable_arg("internal", "true")) |>
c(pandoc_args) -> pandoc_args
} else {
c(fm$doi, "!!! missing DOI !!!") |>
head(1) |>
pandoc_variable_arg(name = "doi") |>
c(pandoc_args) -> pandoc_args
}

assert_that(
getwd() |>
path("index.Rmd") |>
Expand Down Expand Up @@ -110,7 +127,7 @@ gitbook <- function(code_folding = c("none", "show", "hide")) {
template = template, extra_dependencies = list(inbomd_dep),
code_folding = code_folding
)
post <- config$post_processor # in case a post processor have been defined
op <- config$post_processor # in case a post processor have been defined
config$post_processor <- function(metadata, input, output, clean, verbose) {
file(output, encoding = "UTF-8") |>
readLines() -> x
Expand All @@ -119,7 +136,7 @@ gitbook <- function(code_folding = c("none", "show", "hide")) {
x <- c(head(x, i - 1), "", tail(x, -i + 1))
}
writeLines(x, output)
post(metadata, input, output, clean, verbose)
op(metadata, input, output, clean, verbose)
}
config$clean_supporting <- TRUE
return(config)
Expand Down
Loading

0 comments on commit b5e7445

Please sign in to comment.