Skip to content

Commit

Permalink
Merge pull request #84 from inbo/website-inbo
Browse files Browse the repository at this point in the history
small fixes
  • Loading branch information
ThierryO committed Jan 11, 2022
2 parents 1ec1bd4 + 4422a6f commit 45ed2fa
Show file tree
Hide file tree
Showing 31 changed files with 172 additions and 97 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Expand Up @@ -5,6 +5,7 @@
^\.Rproj\.user$
^\.zenodo\.json$
^checklist.yml$
^CITATION\.cff$
^codecov\.yml$
^data-raw$
^docs$
Expand All @@ -15,6 +16,6 @@
CODE_OF_CONDUCT.md
CONTRIBUTING.md
create_docker.sh
Dockerfile
docker
Dockerfile
docs
42 changes: 24 additions & 18 deletions .zenodo.json
@@ -1,21 +1,27 @@
{
"creators": [
{
"name": "Thierry Onkelinx",
"affiliation": "Research Instute for Nature and Forest"
},
{
"name": "Floris Vanderhaeghe",
"affiliation": "Research Instute for Nature and Forest"
}
],
"description": "INBOmd provides several templates to be used with RMarkdown",
"keywords": [
"R",
"LaTeX",
"reproducibility",
"Markdown"
"title": "INBOmd: Markdown Templates for INBO",
"version": "0.5.2",
"description": "Several templates to generate reports, presentations and posters.",
"creators": [
{
"name": "Onkelinx, Thierry",
"orcid": "https://orcid.org/0000-0001-8804-4216"
}
],
"license": "GPL-3",
"title": "INBOmd: RMarkdown Templates for INBO"
"upload_type": "software",
"access_rights": "open",
"license": "GPL-3.0",
"communities": {
"identifier": "inbo"
},
"contributors": [
{
"name": "Vanderhaeghe, Floris",
"orcid": "https://orcid.org/0000-0002-6378-6229"
},
{
"name": "Lommelen, Els",
"orcid": "https://orcid.org/0000-0002-3481-5684"
}
]
}
20 changes: 20 additions & 0 deletions CITATION.cff
@@ -0,0 +1,20 @@
cff-version: 1.2.0
message: If you use this software, please cite it as below.
authors:
- family-names: Onkelinx
given-names: Thierry
orcid: https://orcid.org/0000-0001-8804-4216
contact:
- email: thierry.onkelinx@inbo.be
family-names: Onkelinx
given-names: Thierry
- email: info@inbo.be
name: Research Institute for Nature and Forest
title: 'INBOmd: Markdown Templates for INBO'
version: 0.5.2
abstract: Several templates to generate reports, presentations and posters.
license: GPL-3.0
type: software
doi: 10.5281/zenodo.842223
repository-code: https://github.com/inbo/inbomd
identifiers: []
2 changes: 1 addition & 1 deletion DESCRIPTION
@@ -1,7 +1,7 @@
Type: Package
Package: INBOmd
Title: Markdown Templates for INBO
Version: 0.5.1
Version: 0.5.2
Authors@R: c(
person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216")),
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Expand Up @@ -129,9 +129,12 @@ RUN apt-get update \
r-cran-R.utils \
&& Rscript -e 'remotes::install_cran("qrcode")'

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

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

## Install webshot dependency
RUN Rscript -e 'webshot::install_phantomjs()'

Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Expand Up @@ -59,5 +59,7 @@ importFrom(rmarkdown,render)
importFrom(rmarkdown,yaml_front_matter)
importFrom(utils,compareVersion)
importFrom(utils,file_test)
importFrom(utils,head)
importFrom(utils,install.packages)
importFrom(utils,packageVersion)
importFrom(utils,tail)
10 changes: 10 additions & 0 deletions NEWS.md
@@ -1,3 +1,13 @@
# INBOmd 0.5.2

* Templates now mention url 'vlaanderen.be/inbo' instead of
'https://www.vlaanderen.be/inbo' or 'www.vlaanderen.be/inbo'.
* Bug fix website 'inbomd_examples'.
* `gitbook()` uses the same reference title for chapter bibliografies as the
main bibliography.
* `references()` takes `lang` into account for HTML formats.
* Bugfix in Dockerfile.

# INBOmd 0.5.1

* Add language french for style Flanders
Expand Down
5 changes: 3 additions & 2 deletions R/ebook.R
Expand Up @@ -54,10 +54,11 @@ ebook <- function() {
)
cover_image <- NULL
if (has_name(fm, "cover")) {
if (!file.exists(file.path(getwd(), "cover.jpeg"))) {
cover_path <- file.path(getwd(), "cover.jpeg")
if (!file.exists(cover_path)) {
pdf_convert(
pdf = file.path(getwd(), fm$cover), format = "jpeg", pages = 1,
dpi = 770 * 25.4 / 210, filenames = file.path(getwd(), "cover.jpeg")
dpi = 770 * 25.4 / 210, filenames = cover_path
)
}
cover_image <- "cover.jpeg"
Expand Down
22 changes: 16 additions & 6 deletions R/gitbook.R
Expand Up @@ -10,7 +10,7 @@
#' @importFrom htmltools htmlDependency
#' @importFrom pdftools pdf_convert
#' @importFrom rmarkdown pandoc_variable_arg yaml_front_matter
#' @importFrom utils packageVersion
#' @importFrom utils head packageVersion tail
#' @family output
gitbook <- function() {
fm <- yaml_front_matter(file.path(getwd(), "index.Rmd"))
Expand Down Expand Up @@ -58,15 +58,15 @@ gitbook <- function() {
msg = "You need to render an INBOmd::gitbook() from it's working directory"
)
if (has_name(fm, "cover")) {
if (!file.exists(file.path(getwd(), "cover.jpeg"))) {
cover_path <- file.path(getwd(), "cover.jpeg")
if (!file.exists(cover_path)) {
pdf_convert(
pdf = file.path(getwd(), fm$cover), format = "jpeg", pages = 1,
dpi = 770 * 25.4 / 210, filenames = file.path(getwd(), "cover.jpeg")
dpi = 770 * 25.4 / 210, filenames = cover_path
)
}
pandoc_args <- c(
pandoc_args,
pandoc_variable_arg("cover_image", file.path(getwd(), "cover.jpeg"))
pandoc_args, pandoc_variable_arg("cover_image", cover_path)
)
}
resource_dir <- system.file("css_styles", package = "INBOmd")
Expand All @@ -80,7 +80,7 @@ gitbook <- function() {
pandoc_args <- c(
pandoc_args,
pandoc_variable_arg(
"csspath", paste0("libs/INBOmd-", packageVersion("INBOmd"))
"csspath", file.path("libs", paste0("INBOmd-", packageVersion("INBOmd")))
)
)
template <- system.file(
Expand All @@ -92,6 +92,16 @@ gitbook <- function() {
split_bib = TRUE, table_css = TRUE, pandoc_args = pandoc_args,
template = template, extra_dependencies = list(inbomd_dep)
)
post <- config$post_processor # in case a post processor have been defined
config$post_processor <- function(metadata, input, output, clean, verbose) {
x <- readLines(output, encoding = "UTF-8")
i <- head(grep('^<div id="refs" class="references[^"]*"[^>]*>$', x), 1)
if (length(i) > 0) {
x <- c(head(x, i - 1), "", tail(x, -i + 1))
}
writeLines(x, output)
post(metadata, input, output, clean, verbose)
}
config$clean_supporting <- TRUE
return(config)
}
19 changes: 15 additions & 4 deletions R/references.R
Expand Up @@ -5,15 +5,26 @@
#' Only relevant for pdf output.
#' @family utils
#' @export
#' @importFrom assertthat assert_that is.flag noNA
#' @importFrom assertthat assert_that has_name is.flag noNA
#' @importFrom knitr is_html_output
#' @importFrom rmarkdown yaml_front_matter
references <- function(appendix = FALSE, part = FALSE) {
assert_that(is.flag(appendix), noNA(appendix))
if (is_html_output()) {
output <- c(
"# Referenties {-}", "<div id='refs'></div>",
"# (APPENDIX) Bijlage {-}"[appendix]
fm <- yaml_front_matter(file.path(getwd(), "index.Rmd"))
style <- ifelse(has_name(fm, "style"), fm$style, "INBO")
lang <- ifelse(
has_name(fm, "lang"), fm$lang, ifelse(style == "Flanders", "en", "nl")
)
ref_title <- sprintf(
"# %s {-}",
c(nl = "Referenties", en = "Bibliography", fr = "Bibliographie")[lang]
)
app_title <- sprintf(
"# (APPENDIX) %s {-}",
c(nl = "Bijlage", en = "Appendix", fr = "Annexe")[lang]
)
output <- c(ref_title, "<div id='refs'></div>", app_title[appendix])
} else {
assert_that(is.flag(part), noNA(part))
output <- c(
Expand Down
27 changes: 13 additions & 14 deletions README.md
Expand Up @@ -9,7 +9,8 @@
![GitHub repo size](https://img.shields.io/github/repo-size/inbo/inbomd.svg)
[![DOI](https://zenodo.org/badge/66824259.svg)](https://zenodo.org/badge/latestdoi/66824259)

INBOmd contains templates to generate several types of documents with the corporate identity of INBO or the Flemish government. The current package has following Rmarkdown templates:
INBOmd contains templates to generate several types of documents with the corporate identity of INBO or the Flemish government.
The current package has following Rmarkdown templates:

- INBO report: reports rendered to pdf, html (gitbook style) and epub
- INBO slides: presentations rendered to pdf
Expand All @@ -18,21 +19,27 @@ INBOmd contains templates to generate several types of documents with the corpor

The templates are available in RStudio using `File` > `New file` > `R Markdown` > `From template`.

More details, including instructions for installation and usage are available at the [INBOmd website](https://inbomd.netlify.app/articles/introduction.html).
More details, including instructions for installation and usage are available at the [INBOmd website](https://inbo.github.io/INBOmd/articles/introduction.html).

## In the wild

Below are some documents created with INBOmd

1. https://inbomd-examples.netlify.com
1. https://inbo.github.io/inbomd_examples
1. https://doi.org/10.21436/inbor.14030462
1. https://doi.org/10.21436/inbop.14901626
1. https://pureportal.inbo.be/portal/files/12819590/rbelgium_20170307.pdf
1. https://doi.org/10.21436/inbor.12304086

## Installation

INBOmd requires a working installation of XeLaTeX. We highly recommend to use the TinyTeX. Close all open R sessions and start a fresh R session. Execute the commands below. This will install TinyTeX on your machine. No admin rights are required. Although TinyTeX is a lightweight installation, it still is several 100 MB large.
INBOmd requires a working installation of XeLaTeX.
We highly recommend to use the TinyTeX.
Close all open R sessions and start a fresh R session.
Execute the commands below.
This will install TinyTeX on your machine.
No admin rights are required.
Although TinyTeX is a lightweight installation, it still is several 100 MB large.

```
update.packages(ask = FALSE, checkBuilt = TRUE)
Expand All @@ -44,7 +51,8 @@ if (!tinytex:::is_tinytex()) {
}
```

Once TinyTeX is installed, you need to restart RStudio. Then you can proceed with the installation of `INBOmd`.
Once TinyTeX is installed, you need to restart RStudio.
Then you can proceed with the installation of `INBOmd`.

```
if (!"remotes" %in% rownames(installed.packages())) {
Expand All @@ -59,12 +67,3 @@ tinytex::tlmgr_conf(
)
tinytex::tlmgr_install(c("hyphen-dutch", "hyphen-french"))
```

Make your system fonts available in R

```
if (!"extrafont" %in% rownames(installed.packages())) {
install.packages("extrafont")
}
extrafont::font_import()
```
4 changes: 2 additions & 2 deletions _pkgdown.yml
Expand Up @@ -41,5 +41,5 @@ authors:
Thierry Onkelinx:
href: "https://www.muscardinus.be"
Research Institute for Nature and Forest:
href: "https://www.vlaanderen.be/inbo/en-gb"
html: "<img src='reference/figures/logo-en.png' height=24>"
href: "vlaanderen.be/inbo/en"
html: "<img src='https://inbo.github.io/INBOmd/reference/figures/logo-en.png' height=24>"
18 changes: 13 additions & 5 deletions docker/entrypoint.sh
@@ -1,10 +1,5 @@
#!/bin/sh -l

echo 'repository: ' $GITHUB_REPOSITORY
echo 'ref: ' $GITHUB_REF
echo 'head_ref: ' $GITHUB_HEAD_REF
echo 'Event: ' $GITHUB_EVENT_NAME

export HOME=/root

cd $GITHUB_WORKSPACE
Expand All @@ -27,3 +22,16 @@ echo '\nAll Rmarkdown files rendered successfully\n'
if [ $GITHUB_REPOSITORY = "inbo/inbomd" ] ; then
cp -R /examples/docs/. $GITHUB_WORKSPACE/docs/.
fi

if [ $GITHUB_EVENT_NAME = "push" ] ; then
cd /
git clone --depth 1 -b gh-pages https://$INPUT_TOKEN@github.com/inbo/inbomd_examples
cd /inbomd_examples
git rm -rf --quiet .
cp -R $GITHUB_WORKSPACE/docs/. /inbomd_examples/.
git add --all
git config --global user.email "bwk@inbo.be"
git config --global user.name "INBO BMK"
git commit --amend -m "Automated update of gh-pages with inbomd_examples"
git push --force --set-upstream origin gh-pages
fi
6 changes: 3 additions & 3 deletions inst/CITATION
Expand Up @@ -2,12 +2,12 @@ citHeader("To cite `INBOmd` in publications please use:")
# begin checklist entry
citEntry(
entry = "Manual",
title = "INBOmd: Markdown Templates for INBO. Version 0.5.1",
title = "INBOmd: Markdown Templates for INBO. Version 0.5.2",
author = c(person(given = "Thierry", family = "Onkelinx")),
year = 2021,
year = 2022,
url = "https://github.com/inbo/inbomd",
abstract = "Several templates to generate reports, presentations and posters.",
textVersion = "Onkelinx, Thierry (2021) INBOmd: Markdown Templates for INBO. Version 0.5.1. https://github.com/inbo/inbomd, https://doi.org/10.5281/zenodo.842223",
textVersion = "Onkelinx, Thierry (2022) INBOmd: Markdown Templates for INBO. Version 0.5.2. https://github.com/inbo/inbomd, https://doi.org/10.5281/zenodo.842223",
doi = "10.5281/zenodo.842223",
)
# end checklist entry
Expand Up @@ -281,7 +281,7 @@
\begin{minipage}[b][30mm][b]{250mm}
\begin{flushright}
\usebeamerfont{email}\usebeamercolor[fg]{footline}\@email\\
\usebeamerfont{footline}\usebeamercolor[fg]{footline}www.vlaanderen.be/inbo
\usebeamerfont{footline}\usebeamercolor[fg]{footline}vlaanderen.be/inbo
\end{flushright}
\end{minipage}
}
Expand Down
Expand Up @@ -18,7 +18,7 @@
\coverhorizontal{TRUE}
\coveroffset{0mm}
\coverhoffset{0mm}
\website{www.vlaanderen.be/inbo}
\website{vlaanderen.be/inbo}

\RequirePackage{inboimage_2015}

Expand Down
Expand Up @@ -18,7 +18,7 @@
\coverhorizontal{TRUE}
\coveroffset{0mm}
\coverhoffset{0mm}
\website{www.vlaanderen.be/inbo}
\website{vlaanderen.be/inbo}
\slidelogo{}

\RequirePackage{inboimage_2015}
Expand Down

0 comments on commit 45ed2fa

Please sign in to comment.