blob: a321229a64f40c19d81e33ec3c77c8ea36eeda47 [file] [log] [blame]
Marc Kupietzd2be7362023-06-14 07:17:27 +02001#' Posterdown IDS-CD based on HTML format (using pagedown::poster_relaxed)
2#'
3#' @inheritParams pagedown::poster_relaxed
4#' @param ... Additional arguments to `rmarkdown::html_document`
5#'
6#' @return R Markdown output format to pass to
7#' [rmarkdown::render()]
8#'
9#'@examples
10#'\donttest{
11#'file <- file.path(tempdir(),"foo.rmd")
Marc Kupietza39d0cc2024-05-31 12:45:45 +020012#'rmarkdown::draft(file, template="posterdown_ids", package="posterdown.ids")
Marc Kupietzd2be7362023-06-14 07:17:27 +020013#'}
14#'
Marc Kupietza39d0cc2024-05-31 12:45:45 +020015#' @description The output format `posterdown_ids()` mimics the IDS Mannheim
Marc Kupietzd2be7362023-06-14 07:17:27 +020016#' corporate design posters.
Marc Kupietza39d0cc2024-05-31 12:45:45 +020017#' @rdname posterdown_ids
Marc Kupietzd2be7362023-06-14 07:17:27 +020018#' @export
19posterdown_ids <- function(...,
20 template = find_resource("posterdown_ids", "template.html"),
21 css = NULL) {
22 pagedown::poster_relaxed(..., css = css, template = template)
23}
24
Marc Kupietzcbe8b142023-06-24 17:48:20 +020025
26#' @description Print html code for a linked qr code to the given url
27#' @importFrom qrcode add_logo qr_code generate_svg
28#' @export
29qrlink <- function(url, logo = NULL) {
30 tmp <- tempfile(fileext = ".svg")
31 qrcode <- qrcode::qr_code(url, ecl = if(is.null(logo)) "L" else "H")
32 if(!is.null(logo)) {
33 qrcode <- qrcode::add_logo(qrcode, logo, ecl = "L")
34 }
35 qrcode::generate_svg(qrcode, tmp, show = FALSE)
36 return(paste0( sprintf('<a class="qrcode" href="%s"><img class="qrcode">', url),
Marc Kupietz24081892023-06-26 20:51:27 +020037 gsub("\r?\n|\r", "", readChar(tmp, 1e7)),
Marc Kupietzcbe8b142023-06-24 17:48:20 +020038 '</img></a>'
39 ))
40}
41