Skip to content

Commit 4691129

Browse files
committed
use shinyOption() to set/get app filename
1 parent e5dcd5e commit 4691129

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

R/app.R

Lines changed: 3 additions & 0 deletions
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+
shinyOptions(appFile = "server.R")
124125
shinyAppDir_serverR(appDir, options = options)
125126
} else if (file.exists.ci(appDir, "app.R")) {
127+
shinyOptions(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.")
@@ -136,6 +138,7 @@ shinyAppFile <- function(appFile, options=list()) {
136138
appFile <- normalizePath(appFile, mustWork = TRUE)
137139
appDir <- dirname(appFile)
138140

141+
shinyOptions(appFile = basename(appFile))
139142
shinyAppDir_appR(basename(appFile), appDir, options = options)
140143
}
141144

R/showcase.R

Lines changed: 2 additions & 3 deletions
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")) "active" else "",
84+
li(class=if (identical(file, getShinyOption("appFile"))) "active" else "",
8585
a(href=paste0("#", gsub("\\.|\\s+", "_", file), "_code"),
8686
"data-toggle"="tab", paste0(prefix, file)))
8787
)
@@ -106,8 +106,7 @@ tabContentHelper <- function(files, path, language) {
106106
lapply(files, function(file) {
107107
with(tags,
108108
div(class=paste0("tab-pane",
109-
# TODO: what if the app filename is something else?
110-
if (tolower(file) %in% c("app.r", "server.r")) " active"
109+
if (identical(file, getShinyOption("appFile"))) " active"
111110
else ""),
112111
id=paste0(gsub("\\.|\\s+", "_", file), "_code"),
113112
pre(class="shiny-code",

0 commit comments

Comments
 (0)