Marc Kupietz | d2be736 | 2023-06-14 07:17:27 +0200 | [diff] [blame] | 1 | #' 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 Kupietz | a39d0cc | 2024-05-31 12:45:45 +0200 | [diff] [blame^] | 12 | #'rmarkdown::draft(file, template="posterdown_ids", package="posterdown.ids") |
Marc Kupietz | d2be736 | 2023-06-14 07:17:27 +0200 | [diff] [blame] | 13 | #'} |
| 14 | #' |
Marc Kupietz | a39d0cc | 2024-05-31 12:45:45 +0200 | [diff] [blame^] | 15 | #' @description The output format `posterdown_ids()` mimics the IDS Mannheim |
Marc Kupietz | d2be736 | 2023-06-14 07:17:27 +0200 | [diff] [blame] | 16 | #' corporate design posters. |
Marc Kupietz | a39d0cc | 2024-05-31 12:45:45 +0200 | [diff] [blame^] | 17 | #' @rdname posterdown_ids |
Marc Kupietz | d2be736 | 2023-06-14 07:17:27 +0200 | [diff] [blame] | 18 | #' @export |
| 19 | posterdown_ids <- function(..., |
| 20 | template = find_resource("posterdown_ids", "template.html"), |
| 21 | css = NULL) { |
| 22 | pagedown::poster_relaxed(..., css = css, template = template) |
| 23 | } |
| 24 | |
Marc Kupietz | cbe8b14 | 2023-06-24 17:48:20 +0200 | [diff] [blame] | 25 | |
| 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 |
| 29 | qrlink <- 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 Kupietz | 2408189 | 2023-06-26 20:51:27 +0200 | [diff] [blame] | 37 | gsub("\r?\n|\r", "", readChar(tmp, 1e7)), |
Marc Kupietz | cbe8b14 | 2023-06-24 17:48:20 +0200 | [diff] [blame] | 38 | '</img></a>' |
| 39 | )) |
| 40 | } |
| 41 | |