Skip to content

Commit 4b2e6fc

Browse files
committed
Have shinyAppDir() populate appFile global so we don't have to guess what file should be active
1 parent e569deb commit 4b2e6fc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

R/app.R

+2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ shinyAppDir <- function(appDir, options=list()) {
121121
appDir <- normalizePath(appDir, mustWork = TRUE)
122122

123123
if (file.exists.ci(appDir, "server.R")) {
124+
.globals$appFile <- "server.R"
124125
shinyAppDir_serverR(appDir, options = options)
125126
} else if (file.exists.ci(appDir, "app.R")) {
127+
.globals$appFile <- "app.R"
126128
shinyAppDir_appR("app.R", appDir, options = options)
127129
} else {
128130
stop("App dir must contain either app.R or server.R.")

R/showcase.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ appMetadata <- function(desc) {
8181
navTabsHelper <- function(files, prefix = "") {
8282
lapply(files, function(file) {
8383
with(tags,
84-
li(class=if (tolower(file) %in% c("app.r", "server.r", tolower(.globals$appFile))) "active" else "",
84+
li(class=if (file %in% .globals$appFile) "active" else "",
8585
a(href=paste0("#", gsub("\\.|\\s+", "_", file), "_code"),
8686
"data-toggle"="tab", paste0(prefix, file)))
8787
)
@@ -106,7 +106,7 @@ tabContentHelper <- function(files, path, language) {
106106
lapply(files, function(file) {
107107
with(tags,
108108
div(class=paste0("tab-pane",
109-
if (tolower(file) %in% c("app.r", "server.r", tolower(.globals$appFile))) " active"
109+
if (file %in% .globals$appFile) " active"
110110
else ""),
111111
id=paste0(gsub("\\.|\\s+", "_", file), "_code"),
112112
pre(class="shiny-code",

0 commit comments

Comments
 (0)