diff --git a/R/publish.R b/R/publish.R index 82257044c..3e5d6edf9 100644 --- a/R/publish.R +++ b/R/publish.R @@ -2,43 +2,41 @@ #' #' Publish a book to a Connect Server. By default, you should render the book #' locally before publishing. +#' +#' @inheritParams rsconnect::deploySite +#' #' @param name Name of the book (this will be used in the URL path of the #' published book). Defaults to the \code{book_filename} in #' \code{_bookdown.yml} if not specified. #' @param account Account name to publish to. Will default to any previously #' published to account or any single account already associated with #' \code{server}. -#' @param server Server to publish to (by default connect.posit.cloud, but any -#' Posit Connect server can be published to). -#' @param ... Other arguments to be passed to [rsconnect::deploySite()]. -#' @note Previously the default server was bookdown.org, which will be sunset. -#' You are no longer recommended to publish to bookdown.org. +#' @param server Server to publish to (by default connect.posit.cloud, but +#' any Posit Connect server can be published to). +#' #' @export -publish_book = function(name = NULL, account = NULL, server = "connect.posit.cloud", ...) { - # delete local records of bookdown.org - accounts = rsconnect::accounts() - x1 = 'bookdown.org' %in% accounts$server - x2 = 'bookdown.org' %in% rsconnect::servers()$name - if (x1 || x2) { - warning( - 'bookdown.org will be sunset on January 31, 2026. Please consider ', - 'publishing to https://connect.posit.cloud instead.' - ) - if (readline('Do you want to remove the bookdown.org server now? Your book will _not_ be removed. (y/n) ') == 'y') { - if (x1) rsconnect::removeAccount(server = 'bookdown.org') - if (x2) rsconnect::removeServer('bookdown.org') - } - if (readline('Do you want to delete local records of the Connect deployment? Your book will _not_ be deleted (y/n) ') == 'y') { - rsconnect::forgetDeployment() - } - } - # if there are no Connect accounts setup on this machine, offer to add one - # for connect.posit.cloud - if (!'connect.posit.cloud' %in% accounts$server) { - if (readline('Do you want to connect to connect.posit.cloud? (y/n)') == 'y') - rsconnect::connectCloudUser() +publish_book = function( + name = NULL, account = NULL, server = NULL, render = c("none", "local", "server") +) { + + # if there are no Connect accounts setup on this machine + # then offer to add one for connect.posit.cloud + accounts <- rsconnect::accounts() + accounts <- subset(accounts, server != "shinyapps.io") + if (is.null(accounts) || nrow(accounts) == 0) { + # see if they want to configure an account (bail if they don't) + message('You do not currently have a publishing account ', + 'configured on this system.') + result = readline('Would you like to configure one now? [Y/n]: ') + if (tolower(result) == 'n') return(invisible()) + + # configure the account + rsconnect::connectCloudUser() } # deploy the book - rsconnect::deploySite(siteDir = getwd(), siteName = name, account = account, server = server, ...) + rsconnect::deploySite( + siteDir = getwd(), siteName = name, account = account, server = server, + render = render, logLevel = 'normal' + ) } diff --git a/man/publish_book.Rd b/man/publish_book.Rd index 3339ff75c..30ed9422e 100644 --- a/man/publish_book.Rd +++ b/man/publish_book.Rd @@ -4,7 +4,12 @@ \alias{publish_book} \title{Publish a book to a Posit Connect server} \usage{ -publish_book(name = NULL, account = NULL, server = "connect.posit.cloud", ...) +publish_book( + name = NULL, + account = NULL, + server = NULL, + render = c("none", "local", "server") +) } \arguments{ \item{name}{Name of the book (this will be used in the URL path of the @@ -15,16 +20,21 @@ published book). Defaults to the \code{book_filename} in published to account or any single account already associated with \code{server}.} -\item{server}{Server to publish to (by default connect.posit.cloud, but any -Posit Connect server can be published to).} +\item{server}{Server to publish to (by default connect.posit.cloud, but +any Posit Connect server can be published to).} -\item{...}{Other arguments to be passed to [rsconnect::deploySite()].} +\item{render}{Rendering behavior for site: +\itemize{ +\item \code{"none"} uploads a static version of the current contents of +the site directory. +\item \code{"local"} renders the site locally then uploads it. +\item \code{"server"} uploads the source of the site to render on the server. +} + +Note that for \code{"none"} and \code{"local"} source files (e.g. \code{.R}, \code{.Rmd} and +\code{.md}) will not be uploaded to the server.} } \description{ Publish a book to a Connect Server. By default, you should render the book locally before publishing. } -\note{ -Previously the default server was bookdown.org, which will be sunset. - You are no longer recommended to publish to bookdown.org. -} diff --git a/man/render_book.Rd b/man/render_book.Rd index 2ec06a855..d69ef3ff6 100644 --- a/man/render_book.Rd +++ b/man/render_book.Rd @@ -70,12 +70,12 @@ new R session (\code{new_session = TRUE}). } \examples{ # see https://bookdown.org/yihui/bookdown for the full documentation -if (file.exists("index.Rmd")) bookdown::render_book("index.Rmd") +if (file.exists('index.Rmd')) bookdown::render_book('index.Rmd') \dontrun{ # will use the default format defined in index.Rmd or _output.yml bookdown::render_book("index.Rmd") # will use the options for format defined in YAML metadata -bookdown::render_book("index.Rmd", "bookdown::pdf_book") +bookdown::render_book("index.Rmd", "bookdown::pdf_book") # If you pass an output format object, it must have all the options set bookdown::render_book("index.Rmd", bookdown::pdf_book(toc = FALSE)) diff --git a/man/resolve_refs_html.Rd b/man/resolve_refs_html.Rd index a7438b338..3689c917f 100644 --- a/man/resolve_refs_html.Rd +++ b/man/resolve_refs_html.Rd @@ -25,7 +25,12 @@ the R Markdown source document. } \examples{ library(bookdown) -resolve_refs_html(c("(#tab:foo) A nice table.", - "

See Table @ref(tab:foo).

"), global = TRUE) +resolve_refs_html( + c( + '(#tab:foo) A nice table.', + '

See Table @ref(tab:foo).

' + ), + global = TRUE +) } \keyword{internal}