From 16fe4818c5f63a20987aa7d770c9ed2a042a1210 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Fri, 22 Nov 2019 14:14:55 -0500 Subject: [PATCH] RC branch (blastula 0.3.0) (#112) * Modify tests so that they work on CRAN * Update README * Update NEWS.md * Remove Appveyor and fix README * Fix docs for `add_cta_button()` * Update version number --- DESCRIPTION | 2 +- NEWS.md | 16 ++++++++-- R/add_cta_button.R | 15 ++++----- README.Rmd | 17 +++++++---- README.md | 22 +++++++++----- appveyor.yml | 52 -------------------------------- man/add_cta_button.Rd | 15 ++++----- tests/testthat/test-html_manip.R | 9 ++++-- 8 files changed, 61 insertions(+), 87 deletions(-) delete mode 100644 appveyor.yml diff --git a/DESCRIPTION b/DESCRIPTION index 4908ca73..d0d18d00 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: blastula Title: Easily Send HTML Email Messages -Version: 0.2.99.9000 +Version: 0.3.0 Authors@R: c( person("Richard", "Iannone", role = c("aut", "cre"), email = "riannone@me.com", comment = c(ORCID = "0000-0003-3925-190X")), diff --git a/NEWS.md b/NEWS.md index 66c36f4a..68439a58 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ -# blastula 0.3.0 (Unreleased) +# blastula 0.3.0 -The blastula package has transitioned to using the **curl** package for SMTP mailing. +The **blastula** package has transitioned to using the **curl** package for SMTP mailing. There are new functions for integrating **blastula** with R Markdown publishing on the RStudio Connect service. And sophisticated email bodies can be generated with *HTML Blocks*. @@ -8,7 +8,13 @@ There are new functions for integrating **blastula** with R Markdown publishing * `send_email_out()` has been removed; the `smtp_send()` function is its replacement for sending email through an SMTP server -* The `create_email_creds_file()` function has been removed in favor of a suite of functions for storing SMTP credentials (`create_smtp_creds_file()`, `create_smtp_creds_key()`); the following credentials helper functions are available for retrieving credentials during sending: `creds_file()`, `creds_key()`, `creds_anonymous()`, and `creds()` +* The revised `smtp_send()` function internally uses `curl::send_mail()` to send RFC2822 email message that **blastula** now independently generates; now, there is no need to download third-party binaries to send via SMTP + +* The `smtp_send()` no longer offers text interpolation in `{ }` (which was provided by `glue::glue()`) since this poses a security risk; email strings can be precomposed using `glue::glue()` independently, or, by using `c()`, `paste()`/`paste0`. + +* If an email message string contains Markdown text or HTML fragments, the `md()` function must be used to perform rendering + +* The `create_email_creds_file()` function has been removed in favor of a suite of functions for storing SMTP configuration info and credentials (`create_smtp_creds_file()`, `create_smtp_creds_key()`); the following credentials helper functions are available for retrieving or directly specifying configuration and credentials during sending: `creds_file()`, `creds_key()`, `creds_anonymous()`, and `creds()` * The `preview_email()` function has been removed as email objects created by `compose_email()` now have a print method @@ -20,6 +26,10 @@ There are new functions for integrating **blastula** with R Markdown publishing * The `compose_email()` function now has a `header` argument, allowing for content to populate the area above the `body` +* Images embedded in email messages by using `add_image()` are now properly encoded as Base64 in the outgoing message; more MIME types are supported thanks to functions provided by the **mime** package + +* The new `add_imgur_image()` function allows us to deploy a local image to Imgur and retrieve the image tag (all in one step); this is useful if you want to use external images in an email message + * We can now build sophisticated email messages with HTML blocks. With these responsive, higher-level components, we can create compose elements within the `header`, `body`, and `footer` components. The functions now available for this system are: `blocks()`, `block_title()`, `block_text()`, `block_spacer()`, `block_articles()`, and `block_social_links()`. Two useful subcomponent functions are `article()` and `social_link()`. ## Notes diff --git a/R/add_cta_button.R b/R/add_cta_button.R index 9a9686f4..9ef2cacd 100644 --- a/R/add_cta_button.R +++ b/R/add_cta_button.R @@ -24,15 +24,16 @@ #' # Include the button in the email #' # message body by using it as part of #' # a vector inside of `md()` -#' compose_email( -#' body = md( -#' c( -#' "Pressing the button will take -#' you to an example website", -#' cta_button +#' email <- +#' compose_email( +#' body = md( +#' c( +#' "Pressing the button will take +#' you to an example website", +#' cta_button +#' ) #' ) #' ) -#' ) #' #' if (interactive()) email #' diff --git a/README.Rmd b/README.Rmd index 1348898d..816c81ec 100644 --- a/README.Rmd +++ b/README.Rmd @@ -21,7 +21,6 @@ library(blastula) [![CRAN status](https://www.r-pkg.org/badges/version/blastula)](https://CRAN.R-project.org/package=blastula) [![Travis-CI Build Status](https://travis-ci.org/rich-iannone/blastula.svg?branch=master)](https://travis-ci.org/rich-iannone/blastula) -[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/rich-iannone/blastula?branch=master&svg=true)](https://ci.appveyor.com/project/rich-iannone/blastula) [![Codecov test coverage](https://codecov.io/gh/rich-iannone/blastula/branch/master/graph/badge.svg)](https://codecov.io/gh/rich-iannone/blastula?branch=master) ## Overview @@ -76,7 +75,7 @@ After creating the email message, we can look at it to ensure that the formattin ```{r preview_email, eval=FALSE} # Preview the email -email_object +email ``` @@ -89,10 +88,10 @@ Having generated a credentials file, we can use the `smtp_send()` function (alon ```{r smtp_send, eval=FALSE} # Sending email by SMTP using a credentials file -email_object %>% +email %>% smtp_send( - to = "a_user@web.net", - from = "personal@email.net", + to = "jane_doe@example.com", + from = "joe_public@example.net", subject = "Testing the `smtp_send()` function", credentials = creds_file("email_creds") ) @@ -100,6 +99,12 @@ email_object %>% ## Installation +The **blastula** package can be installed from CRAN with `install.packages()`. + +```{r install_cran, eval=FALSE} +install.packages("blastula") +``` + You can install the in-development version of **blastula** from **GitHub** using the **devtools** package. ```{r install_github, eval=FALSE} @@ -111,7 +116,7 @@ If you encounter a bug, have usage questions, or want to share ideas to make thi ## Code of Conduct -Please note that the **blastula** project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms. +Please note that the **blastula** project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/1/0/0). By contributing to this project, you agree to abide by its terms. ## License diff --git a/README.md b/README.md index 78842cb7..cf9602cc 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ status](https://www.r-pkg.org/badges/version/blastula)](https://CRAN.R-project.org/package=blastula) [![Travis-CI Build Status](https://travis-ci.org/rich-iannone/blastula.svg?branch=master)](https://travis-ci.org/rich-iannone/blastula) -[![AppVeyor build -status](https://ci.appveyor.com/api/projects/status/github/rich-iannone/blastula?branch=master&svg=true)](https://ci.appveyor.com/project/rich-iannone/blastula) [![Codecov test coverage](https://codecov.io/gh/rich-iannone/blastula/branch/master/graph/badge.svg)](https://codecov.io/gh/rich-iannone/blastula?branch=master) @@ -80,7 +78,7 @@ displayed in the Viewer. ``` r # Preview the email -email_object +email ``` @@ -99,10 +97,10 @@ send the email through an SMTP server. ``` r # Sending email by SMTP using a credentials file -email_object %>% +email %>% smtp_send( - to = "a_user@web.net", - from = "personal@email.net", + to = "jane_doe@example.com", + from = "joe_public@example.net", subject = "Testing the `smtp_send()` function", credentials = creds_file("email_creds") ) @@ -110,6 +108,13 @@ email_object %>% ## Installation +The **blastula** package can be installed from CRAN with +`install.packages()`. + +``` r +install.packages("blastula") +``` + You can install the in-development version of **blastula** from **GitHub** using the **devtools** package. @@ -125,8 +130,9 @@ make this package better, feel free to file an ## Code of Conduct Please note that the **blastula** project is released with a -[Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to -this project, you agree to abide by its terms. +[Contributor Code of +Conduct](https://contributor-covenant.org/version/1/0/0). By +contributing to this project, you agree to abide by its terms. ## License diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 3a75e16a..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,52 +0,0 @@ -# DO NOT CHANGE the "init" and "install" sections below - -# Download script file from GitHub -init: - ps: | - $ErrorActionPreference = "Stop" - Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" - Import-Module '..\appveyor-tool.ps1' - -install: - ps: Bootstrap - -cache: - - C:\RLibrary - -environment: - NOT_CRAN: true - # env vars that may need to be set, at least temporarily, from time to time - # see https://github.com/krlmlr/r-appveyor#readme for details - # USE_RTOOLS: true - # R_REMOTES_STANDALONE: true - -# Adapt as necessary starting from here - -build_script: - - travis-tool.sh install_deps - -test_script: - - travis-tool.sh run_tests - -on_failure: - - 7z a failure.zip *.Rcheck\* - - appveyor PushArtifact failure.zip - -artifacts: - - path: '*.Rcheck\**\*.log' - name: Logs - - - path: '*.Rcheck\**\*.out' - name: Logs - - - path: '*.Rcheck\**\*.fail' - name: Logs - - - path: '*.Rcheck\**\*.Rout' - name: Logs - - - path: '\*_*.tar.gz' - name: Bits - - - path: '\*_*.zip' - name: Bits diff --git a/man/add_cta_button.Rd b/man/add_cta_button.Rd index 11fa4b91..d4ceaa1e 100644 --- a/man/add_cta_button.Rd +++ b/man/add_cta_button.Rd @@ -35,15 +35,16 @@ cta_button <- # Include the button in the email # message body by using it as part of # a vector inside of `md()` -compose_email( - body = md( - c( -"Pressing the button will take -you to an example website", -cta_button +email <- + compose_email( + body = md( + c( + "Pressing the button will take + you to an example website", + cta_button + ) ) ) -) if (interactive()) email diff --git a/tests/testthat/test-html_manip.R b/tests/testthat/test-html_manip.R index 7b517126..40e75c8d 100644 --- a/tests/testthat/test-html_manip.R +++ b/tests/testthat/test-html_manip.R @@ -77,12 +77,15 @@ test_that("src resolution works correctly", { expect_equal(src_to_filepath("/foo%20bar", "/baz"), "/foo bar") expect_equal(src_to_filepath("/foo%20bar", "/baz"), "/foo bar") expect_equal(src_to_filepath("/foo%20bar", "."), "/foo bar") - expect_equal(src_to_filepath("foo%20bar", "."), file.path(getwd(), "foo bar")) - expect_equal(src_to_filepath("../a/b", "/c/d"), "/c/a/b") + # Because of the potential for drive letters to be of + # different cases, we transform the whole string to lower case + expect_equal(tolower(src_to_filepath("foo%20bar", ".")), tolower(file.path(getwd(), "foo bar"))) + expect_equal(tolower(src_to_filepath("foo", "")), tolower(file.path(getwd(), "foo"))) + + expect_equal(src_to_filepath("../a/b", "/c/d"), "/c/a/b") expect_equal(src_to_filepath("C:\\foo\\bar", "/baz"), "C:/foo/bar") # Newer versions of fs capitalize drive letters expect_true(src_to_filepath("foo/bar", "c:\\baz") %in% c("c:/baz/foo/bar", "C:/baz/foo/bar")) expect_true(src_to_filepath("", "c:\\baz") %in% c("c:/baz", "C:/baz")) - expect_equal(src_to_filepath("foo", ""), file.path(getwd(), "foo")) })