Skip to content

Commit

Permalink
Merge pull request #93 from inbo/slides
Browse files Browse the repository at this point in the history
bugfix in create_report()
  • Loading branch information
ThierryO committed Nov 29, 2023
2 parents 754741f + 2fc92ce commit 47b9e30
Show file tree
Hide file tree
Showing 41 changed files with 655 additions and 268 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Expand Up @@ -15,6 +15,7 @@ Dockerfile
^data-raw$
^docs$
^man-roxygen$
^organisation.yml$
^pkgdown$
create_docker.sh
docker
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_on_branch.yml
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
3 changes: 1 addition & 2 deletions .github/workflows/check_on_different_r_os.yml
Expand Up @@ -42,10 +42,9 @@ jobs:
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r-dependencies@v2

- uses: r-lib/actions/check-r-package@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_on_main.yml
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
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.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EXAMPLE_BRANCH: main
Expand Down
21 changes: 10 additions & 11 deletions .github/workflows/release.yml
Expand Up @@ -5,27 +5,26 @@ on:
tags:
- v*
workflow_run:
workflows: ["check package on main"]
workflows: ["check package on main with checklist"]
types:
- completed

jobs:

build:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Get tag message
- name: Get tag
run: |
git fetch --tags --force
TAG=$(git tag --contains $(git rev-parse HEAD))
TAG_BODY=$(git tag --contains {{ github.sha }} -n100 | awk '(NR>1)')
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "TAG_BODY=$TAG_BODY" >> $GITHUB_OUTPUT
id: tag-body
TAG_BODY=$(git tag --contains $(git rev-parse HEAD) --format='%(contents)')
echo "tag=$TAG" >> $GITHUB_ENV
echo "$TAG_BODY" > body.md
- uses: ncipollo/release-action@v1
with:
name: Release ${{ steps.tag-body.outputs.TAG }}
tag: ${{ steps.tag-body.outputs.TAG }}
body: ${{ steps.tag-body.outputs.TAG_BODY }}
name: Release ${{ env.tag }}
tag: ${{ env.tag }}
bodyFile: body.md
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -14,6 +14,7 @@
*_files
.DS_Store
.RData
.Renviron
.Rhistory
.Rproj.user
.Ruserdata
Expand Down
6 changes: 5 additions & 1 deletion .zenodo.json
@@ -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
@@ -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
@@ -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
16 changes: 15 additions & 1 deletion Dockerfile
Expand Up @@ -108,6 +108,13 @@ RUN apt-get update \
r-cran-tinytex \
r-cran-webshot

## Install textshape
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libfribidi-dev \
libharfbuzz-dev \
&& Rscript -e 'remotes::install_cran("textshape")'

## Install ragg
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -176,7 +183,11 @@ RUN Rscript -e 'remotes::install_cran("lipsum")'
RUN Rscript -e 'remotes::install_cran("here")'

## Install gert
RUN Rscript -e 'remotes::install_cran("gert")'
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
&& Rscript -e 'remotes::install_cran("gert")'

## Install webshot dependency
RUN Rscript -e 'webshot::install_phantomjs()'
Expand All @@ -200,6 +211,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
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
19 changes: 19 additions & 0 deletions NEWS.md
@@ -1,6 +1,25 @@
# INBOmd 0.6.2

* `pdf_report()`, `gitbook()` and `epub_book()` gain an option to create
internal reports with a different colophon.
* `pdf_report()` and `gitbook()` gain a watermark argument.
It adds a text watermark in the margin of every page.
An automatic watermark appears when one of the required colophon fields is
missing.
Adding the information for all required colophon fields will remove this
automatic watermark.
* All INBO personnel must display proper affiliation and ORCID.
* 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
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
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")
}
}

0 comments on commit 47b9e30

Please sign in to comment.