From 4b2e6fc38604f85760290aaf4fb3417d1f966dee Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 10 Sep 2019 10:53:48 -0500 Subject: [PATCH] Have shinyAppDir() populate appFile global so we don't have to guess what file should be active --- R/app.R | 2 ++ R/showcase.R | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/app.R b/R/app.R index f84e02bad3..3b6109554c 100644 --- a/R/app.R +++ b/R/app.R @@ -121,8 +121,10 @@ shinyAppDir <- function(appDir, options=list()) { appDir <- normalizePath(appDir, mustWork = TRUE) if (file.exists.ci(appDir, "server.R")) { + .globals$appFile <- "server.R" shinyAppDir_serverR(appDir, options = options) } else if (file.exists.ci(appDir, "app.R")) { + .globals$appFile <- "app.R" shinyAppDir_appR("app.R", appDir, options = options) } else { stop("App dir must contain either app.R or server.R.") diff --git a/R/showcase.R b/R/showcase.R index c31c43a28a..676e4d7dc9 100644 --- a/R/showcase.R +++ b/R/showcase.R @@ -81,7 +81,7 @@ appMetadata <- function(desc) { navTabsHelper <- function(files, prefix = "") { lapply(files, function(file) { with(tags, - li(class=if (tolower(file) %in% c("app.r", "server.r", tolower(.globals$appFile))) "active" else "", + li(class=if (file %in% .globals$appFile) "active" else "", a(href=paste0("#", gsub("\\.|\\s+", "_", file), "_code"), "data-toggle"="tab", paste0(prefix, file))) ) @@ -106,7 +106,7 @@ tabContentHelper <- function(files, path, language) { lapply(files, function(file) { with(tags, div(class=paste0("tab-pane", - if (tolower(file) %in% c("app.r", "server.r", tolower(.globals$appFile))) " active" + if (file %in% .globals$appFile) " active" else ""), id=paste0(gsub("\\.|\\s+", "_", file), "_code"), pre(class="shiny-code",