Skip to content

Commit

Permalink
Merge pull request #940 from rstudio/only-coerce-rmd-for-shinyapps.io
Browse files Browse the repository at this point in the history
only coerce static rmd to shiny for shinyapps.io
  • Loading branch information
mslynch authored Aug 4, 2023
2 parents d556871 + 15b66ed commit 6ae93b2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 27 deletions.
13 changes: 6 additions & 7 deletions R/appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appMetadata <- function(appDir,
appPrimaryDoc = NULL,
quarto = NA,
contentCategory = NULL,
coerceStaticRmd = FALSE,
isShinyappsServer = FALSE,
metadata = list()) {

appFiles <- listDeploymentFiles(appDir, appFiles)
Expand Down Expand Up @@ -38,7 +38,7 @@ appMetadata <- function(appDir,
appMode <- inferAppMode(
file.path(appDir, appFiles),
usesQuarto = quarto,
coerceStaticRmd = coerceStaticRmd
isShinyappsServer = isShinyappsServer
)
}

Expand Down Expand Up @@ -119,7 +119,7 @@ checkAppLayout <- function(appDir, appPrimaryDoc = NULL) {
# infer the mode of the application from files in the root dir
inferAppMode <- function(absoluteAppFiles,
usesQuarto = NA,
coerceStaticRmd = FALSE) {
isShinyappsServer = FALSE) {

matchingNames <- function(paths, pattern) {
idx <- grepl(pattern, basename(paths), ignore.case = TRUE, perl = TRUE)
Expand Down Expand Up @@ -178,10 +178,9 @@ inferAppMode <- function(absoluteAppFiles,
if (usesQuarto) {
return("quarto-static")
} else {
# For Shinyapps and posit.cloud, treat "rmd-static" app mode as "rmd-shiny" so that
# they can be served from a shiny process in Connect until we have better support of
# rmarkdown static content
if (coerceStaticRmd) {
# For shinyapps.io, treat "rmd-static" app mode as "rmd-shiny" so that
# it can be served from a shiny process in Connect
if (isShinyappsServer) {
return("rmd-shiny")
}
return("rmd-static")
Expand Down
9 changes: 0 additions & 9 deletions R/client-cloud.R
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,6 @@ cloudClient <- function(service, authInfo) {
listRequest(service, authInfo, path, query, "invitations")
},

coerceStaticRmd = function(accountId) {
# Posit Cloud will gain support soon for rendering RMD into static content. When support is
# added, true_static_rmd_enabled will be TRUE. In the meantime, RMDs can be deployed by
# using Shiny.
# TODO once Cloud supports this, remove this coercion.
account <- GET(service, authInfo, paste0("/accounts/", accountId))
account$beta$coerce_static_rmd_enabled
},

listTasks = function(accountId, filters = NULL) {
if (is.null(filters)) {
filters <- vector()
Expand Down
4 changes: 0 additions & 4 deletions R/client-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ connectClient <- function(service, authInfo) {
GET(service, authInfo, paste0("/applications/", applicationId))
},

coerceStaticRmd = function(accountId) {
FALSE
},

## Tasks API

listTasks = function() {
Expand Down
4 changes: 0 additions & 4 deletions R/client-shinyapps.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ shinyAppsClient <- function(service, authInfo) {
POST_JSON(service, authInfo, path, json)
},

coerceStaticRmd = function(accountId) {
TRUE
},

listTasks = function(accountId, filters = NULL) {
if (is.null(filters)) {
filters <- vector()
Expand Down
4 changes: 2 additions & 2 deletions R/deployApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ deployApp <- function(appDir = getwd(),
showCookies(serverInfo(accountDetails$server)$url)
}

coerceStaticRmd <- client$coerceStaticRmd(accountDetails$accountId)
isShinyappsServer <- isShinyappsServer(target$server)

logger("Inferring App mode and parameters")
appMetadata <- appMetadata(
Expand All @@ -345,7 +345,7 @@ deployApp <- function(appDir = getwd(),
appPrimaryDoc = appPrimaryDoc,
quarto = quarto,
contentCategory = contentCategory,
coerceStaticRmd = coerceStaticRmd,
isShinyappsServer = isShinyappsServer,
metadata = metadata
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-appMetadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ test_that("can infer mode for static quarto and rmd docs", {
expect_equal(inferAppMode(paths), "rmd-static")
expect_equal(inferAppMode(paths, usesQuarto = TRUE), "quarto-static")
# Static R Markdown treated as rmd-shiny for shinyapps targets
expect_equal(inferAppMode(paths, coerceStaticRmd = TRUE), "rmd-shiny")
expect_equal(inferAppMode(paths, isShinyappsServer = TRUE), "rmd-shiny")
})

test_that("can infer mode for shiny rmd docs", {
Expand Down

0 comments on commit 6ae93b2

Please sign in to comment.