Browse Source

initial commit

master
boB Rudis 5 years ago
parent
commit
f50ad7169a
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 3
      DESCRIPTION
  3. 1
      NAMESPACE
  4. 1
      R/gg-preview.R
  5. 8
      R/htmlwidgets-utils.R
  6. 2
      R/widget-card.R
  7. 1
      R/widgetcard-package.R
  8. 2
      man/card_widget.Rd
  9. 2
      man/gg_preview.Rd

1
.Rbuildignore

@ -4,6 +4,7 @@
^\.Rproj\.user$
^\.travis\.yml$
^README\.*Rmd$
^CONDUCT\.md$
^README\.*html$
^NOTES\.*Rmd$
^NOTES\.*html$

3
DESCRIPTION

@ -27,7 +27,8 @@ Imports:
htmlwidgets,
widgetframe,
ggplot2,
shiny
shiny,
jsonlite
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
VignetteBuilder: knitr

1
NAMESPACE

@ -6,3 +6,4 @@ import(htmltools)
import(htmlwidgets)
import(widgetframe)
importFrom(ggplot2,ggsave)
importFrom(jsonlite,toJSON)

1
R/gg-preview.R

@ -5,6 +5,7 @@
#'
#' @param gg ggplot2 plot object
#' @param width,height width and height of the preview image. See References for guidelines
#' @param dpi see [ggplot2::ggsave()]
#' @return path to the preview image tempfile
#' @references
#' - <https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/player-card.html>

8
R/htmlwidgets-utils.R

@ -2,6 +2,14 @@
.globals <- new.env(parent = emptyenv())
DEFAULT_WIDTH <- 960
DEFAULT_HEIGHT <- 500
DEFAULT_PADDING <- 40
DEFAULT_WIDTH_VIEWER <- 450
DEFAULT_HEIGHT_VIEWER <- 350
DEFAULT_PADDING_VIEWER <- 15
# Copied from shiny 0.14.2
toJSON2 <- function(
x, ..., dataframe = "columns", null = "null", na = "null", auto_unbox = TRUE,

2
R/widget-card.R

@ -48,7 +48,7 @@ card_widget <- function(widget,
preview_img,
html_title = class(widget)[[1]],
card_twitter_handle = "",
card_title = title[[1]],
card_title = html_title[[1]],
card_description = "",
card_image_url_prefix = "",
card_player_url_prefix = "",

1
R/widgetcard-package.R

@ -10,4 +10,5 @@
#' @author Bob Rudis (bob@@rud.is)
#' @import htmltools htmlwidgets widgetframe
#' @importFrom ggplot2 ggsave
#' @importFrom jsonlite toJSON
NULL

2
man/card_widget.Rd

@ -7,7 +7,7 @@
card_widget(widget, output_dir = ulid::ulid_generate(),
name_prefix = "wdgtcrd", preview_img,
html_title = class(widget)[[1]], card_twitter_handle = "",
card_title = title[[1]], card_description = "",
card_title = html_title[[1]], card_description = "",
card_image_url_prefix = "", card_player_url_prefix = "",
card_player_width = 480, card_player_height = 480,
background = "white", bundle_type = c("tgz", "zip"))

2
man/gg_preview.Rd

@ -10,6 +10,8 @@ gg_preview(gg, width = 350/72, height = 196/72, dpi = "retina")
\item{gg}{ggplot2 plot object}
\item{width, height}{width and height of the preview image. See References for guidelines}
\item{dpi}{see \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}}}
}
\value{
path to the preview image tempfile

Loading…
Cancel
Save