Provide a preview image and a widget, plus Twitter Player card metadata and get pack a packaged up, ready-to-deploy archive to deploy and used on Twitter.

card_widget(widget, output_dir = ulid::ulid_generate(),
  name_prefix = "wdgtcrd", preview_img,
  html_title = class(widget)[[1]], card_twitter_handle = "",
  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"))

Arguments

widget

an htmlwidget

output_dir

the path to save the card-able widget to. If the directory does not exist it will be created for you (recursively). The value will be path.expand()ed.

name_prefix

the name-prefix for the widget's .html file and preview_img file.

preview_img

the path to the local preview image for the card-able widget. This file must exist and will be copied over to the deployable directory and renamed (see name_prefix above). Follow the guidelines here regarding image sizes.

html_title

the title for the htmlwidget HTML file's <title> tag.

card_twitter_handle

Your twitter handle including the @.

card_title, card_description

The title and description that will be displayed in the tweet

card_image_url_prefix

Prefix URL for where you will be copying the preview image to. Generally, this wil be the same as card_player_url_prefix but you can specify another URL prefix if storing images on a separate server or separate directory.

card_player_url_prefix

Prefix URL for where you will be copying the htmlwidget HTML and supporting javascript libraries to. Generally, this wil be the same as card_image_url_prefix but you can specify another URL prefix if storing images on a separate server or separate directory.

card_player_width, card_player_height

the width and height for the player window in-tweet. These default to 480x480 and you should review the References section for links to guidelines for Twitter preferred image sizes.

background

htmlwidget background coloe. Defaults to white. Can be a hashed-prefixed hex value (if so, will be converted to rgba() spec)

bundle_type

either tgz for a gzip'd/tar archive or zip for a ZIP archive. The directory named name_prefix will be placed into the archive.

Value

the path.expand()ed path to the bundle_type. The archive name will be name_prefix plus the bundle_type extension.

Details

You can use Twitter's Validator to ensure your creation is usable before trying it in a tweet.

Note

You can and should use Twitter's Validator to ensure your creation is usable before trying it in a tweet.

References