brentthorne | 8ee0076 | 2019-04-24 12:57:51 -0400 | [diff] [blame] | 1 | #' Posterdown HTML format (using pagedown::poster_relaxed) |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 2 | #' |
brentthorne | 275dbbe | 2019-02-05 13:31:30 -0500 | [diff] [blame] | 3 | #' @inheritParams pagedown::poster_relaxed |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 4 | #' @param ... Additional arguments to `rmarkdown::html_document` |
brentthorne | 275dbbe | 2019-02-05 13:31:30 -0500 | [diff] [blame] | 5 | #' |
| 6 | #' @return R Markdown output format to pass to |
brentthorne | 8ee0076 | 2019-04-24 12:57:51 -0400 | [diff] [blame] | 7 | #' [rmarkdown::render()] |
brentthorne | 275dbbe | 2019-02-05 13:31:30 -0500 | [diff] [blame] | 8 | #' |
brentthorne | 164b9a8 | 2019-10-09 10:08:13 -0400 | [diff] [blame] | 9 | #'@examples |
| 10 | #'\donttest{ |
| 11 | #'file <- file.path(tempdir(),"foo.rmd") |
| 12 | #'rmarkdown::draft(file, template="posterdown_html", package="posterdown") |
| 13 | #'} |
| 14 | #' |
brentthorne | 275dbbe | 2019-02-05 13:31:30 -0500 | [diff] [blame] | 15 | #' @export |
| 16 | posterdown_html <- function(..., |
| 17 | template = find_resource("posterdown_html", "template.html"), |
| 18 | css = NULL) { |
| 19 | pagedown::poster_relaxed(..., css = css, template = template) |
| 20 | } |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 21 | |
Marc Kupietz | d2be736 | 2023-06-14 07:17:27 +0200 | [diff] [blame] | 22 | #' Posterdown IDS-CD based on HTML format (using pagedown::poster_relaxed) |
| 23 | #' |
| 24 | #' @inheritParams pagedown::poster_relaxed |
| 25 | #' @param ... Additional arguments to `rmarkdown::html_document` |
| 26 | #' |
| 27 | #' @return R Markdown output format to pass to |
| 28 | #' [rmarkdown::render()] |
| 29 | #' |
| 30 | #'@examples |
| 31 | #'\donttest{ |
| 32 | #'file <- file.path(tempdir(),"foo.rmd") |
| 33 | #'rmarkdown::draft(file, template="posterdown_ids", package="posterdown") |
| 34 | #'} |
| 35 | #' |
| 36 | #' @description The output format `poster_ids()` mimics the IDS Mannheim |
| 37 | #' corporate design posters. |
| 38 | #' @rdname posterdown_html |
| 39 | #' @export |
| 40 | posterdown_ids <- function(..., |
| 41 | template = find_resource("posterdown_ids", "template.html"), |
| 42 | css = NULL) { |
| 43 | pagedown::poster_relaxed(..., css = css, template = template) |
| 44 | } |
| 45 | |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 46 | #' @description The output format `poster_betterland()` mimics the style of the |
brentthorne | 8ee0076 | 2019-04-24 12:57:51 -0400 | [diff] [blame] | 47 | #' BetterPoster movement from twitter. |
brentthorne | 75828bf | 2019-04-07 23:37:15 -0400 | [diff] [blame] | 48 | #' @rdname posterdown_html |
| 49 | #' @export |
| 50 | posterdown_betterland <- function(..., |
| 51 | template = find_resource("posterdown_betterland", "template.html"), |
| 52 | css = NULL) { |
| 53 | pagedown::poster_relaxed(..., css = css, template = template) |
| 54 | } |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 55 | |
| 56 | #' @description The output format `poster_betterport()` mimics the style of the |
brentthorne | 8ee0076 | 2019-04-24 12:57:51 -0400 | [diff] [blame] | 57 | #' BetterPoster movement from twitter. |
Luke W Johnston | 79329cc | 2019-04-24 17:14:04 +0200 | [diff] [blame] | 58 | #' @rdname posterdown_html |
| 59 | #' @export |
| 60 | posterdown_betterport <- function(..., |
| 61 | template = find_resource("posterdown_betterport", "template.html"), |
| 62 | css = NULL) { |
| 63 | pagedown::poster_relaxed(..., css = css, template = template) |
| 64 | } |
Marc Kupietz | cbe8b14 | 2023-06-24 17:48:20 +0200 | [diff] [blame] | 65 | |
| 66 | #' @description Print html code for a linked qr code to the given url |
| 67 | #' @importFrom qrcode add_logo qr_code generate_svg |
| 68 | #' @export |
| 69 | qrlink <- function(url, logo = NULL) { |
| 70 | tmp <- tempfile(fileext = ".svg") |
| 71 | qrcode <- qrcode::qr_code(url, ecl = if(is.null(logo)) "L" else "H") |
| 72 | if(!is.null(logo)) { |
| 73 | qrcode <- qrcode::add_logo(qrcode, logo, ecl = "L") |
| 74 | } |
| 75 | qrcode::generate_svg(qrcode, tmp, show = FALSE) |
| 76 | return(paste0( sprintf('<a class="qrcode" href="%s"><img class="qrcode">', url), |
Marc Kupietz | 2408189 | 2023-06-26 20:51:27 +0200 | [diff] [blame] | 77 | gsub("\r?\n|\r", "", readChar(tmp, 1e7)), |
Marc Kupietz | cbe8b14 | 2023-06-24 17:48:20 +0200 | [diff] [blame] | 78 | '</img></a>' |
| 79 | )) |
| 80 | } |
| 81 | |