diff --git a/R/app.R b/R/app.R index b1d8f17d7a..676db7c217 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")) { + shinyOption(appFile = "server.R") shinyAppDir_serverR(appDir, options = options) } else if (file.exists.ci(appDir, "app.R")) { + shinyOption(appFile = "app.R") shinyAppDir_appR("app.R", appDir, options = options) } else { stop("App dir must contain either app.R or server.R.") @@ -136,6 +138,7 @@ shinyAppFile <- function(appFile, options=list()) { appFile <- normalizePath(appFile, mustWork = TRUE) appDir <- dirname(appFile) + shinyOption(appFile = basename(appFile)) shinyAppDir_appR(basename(appFile), appDir, options = options) } diff --git a/R/showcase.R b/R/showcase.R index c500287450..930482cd04 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")) "active" else "", + li(class=if (identical(file, getShinyOption("appFile"))) "active" else "", a(href=paste0("#", gsub("\\.|\\s+", "_", file), "_code"), "data-toggle"="tab", paste0(prefix, file))) ) @@ -106,8 +106,7 @@ tabContentHelper <- function(files, path, language) { lapply(files, function(file) { with(tags, div(class=paste0("tab-pane", - # TODO: what if the app filename is something else? - if (tolower(file) %in% c("app.r", "server.r")) " active" + if (identical(file, getShinyOption("appFile"))) " active" else ""), id=paste0(gsub("\\.|\\s+", "_", file), "_code"), pre(class="shiny-code",