Skip to content

Commit

Permalink
refactor: renamed env var to GOLEM_MAINTENANCE_ACTIVE
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinFay committed Nov 7, 2022
1 parent 3267323 commit f32f753
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
30 changes: 18 additions & 12 deletions R/with_opt.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
#' launch.
#'
#' @param app the app object.
#' @param golem_opts A list of Options to be added to the app
#' @param maintenance_page an html_document or a shiny tag list. By default is golem page
#' @param golem_opts A list of options to be added to the app
#' @param maintenance_page an html_document or a shiny tag list. Default is golem template.
#' @param print Whether or not to print the app. Default is to `FALSE`, which
#' should be what you need 99.99% of the time In case you need to
#' actively print the app object, you can set it to `TRUE`.
#' should be what you need 99.99% of the time. In case you need to
#' actively print() the app object, you can set it to `TRUE`.
#'
#' @return a shiny.appObj object
#' @export
with_golem_options <- function(app,
golem_opts,
maintenance_page = golem::maintenance_page,
print = FALSE) {
with_golem_options <- function(
app,
golem_opts,
maintenance_page = golem::maintenance_page,
print = FALSE
) {

# Check if app is in maintenance
if (Sys.getenv("GOLEM_SET_MAINTENANCE_ACTIVE") == "TRUE") {
if (Sys.getenv("GOLEM_MAINTENANCE_ACTIVE", "FALSE") == "TRUE") {
app <- shiny::shinyApp(
ui = maintenance_page,
server = function(input, output, session) {}
Expand Down Expand Up @@ -49,9 +51,9 @@ with_golem_options <- function(app,
print <- FALSE
}

# Almost all cases will be ok with explicitely printing the
# Almost all cases will be ok with not explicitely printing the
# application object, but for corner cases like direct shinyApp
# object manipulation, this feature can be turned off
# object manipulation, this feature can be turned on
if (print) {
print(app)
} else {
Expand Down Expand Up @@ -125,6 +127,10 @@ get_golem_options <- function(which = NULL) {
#' @export
maintenance_page <- function() {
shiny::htmlTemplate(
filename = system.file("app", "maintenance.html", package = "golem")
filename = system.file(
"app",
"maintenance.html",
package = "golem"
)
)
}
8 changes: 4 additions & 4 deletions man/with_golem_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f32f753

Please sign in to comment.