From e920b3e514e717fc05ed524267d3b53e272fec51 Mon Sep 17 00:00:00 2001 From: Naeem Model Date: Mon, 6 Jan 2025 23:55:43 +0000 Subject: Update web app entry point - Rename 'app' -> 'web' - Return shiny app object in entry point function --- R/app.R | 39 --------------------------------------- R/web.R | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 39 deletions(-) delete mode 100644 R/app.R create mode 100644 R/web.R (limited to 'R') diff --git a/R/app.R b/R/app.R deleted file mode 100644 index 23e32ab..0000000 --- a/R/app.R +++ /dev/null @@ -1,39 +0,0 @@ -#' Launch the Rnaught Web Application -#' -#' @importFrom utils install.packages -#' -#' @export -app <- function() { - missing_pkgs <- c() - # Check for any missing, required packages. - if (!requireNamespace("bslib", quietly = TRUE)) { - missing_pkgs <- c(missing_pkgs, "bslib") - } - if (!requireNamespace("shiny", quietly = TRUE)) { - missing_pkgs <- c(missing_pkgs, "shiny") - } - if (!requireNamespace("DT", quietly = TRUE)) { - missing_pkgs <- c(missing_pkgs, "DT") - } - if (!requireNamespace("plotly", quietly = TRUE)) { - missing_pkgs <- c(missing_pkgs, "plotly") - } - - # If any of the required packages are missing, - # prompt the user to install them. - if (length(missing_pkgs) > 0) { - cat("The following packages must be installed to run the", - "Rnaught web application:\n" - ) - writeLines(missing_pkgs) - answer <- readline("Begin installation? [Y/n] ") - - if (answer == "Y" || answer == "y") { - install.packages(missing_pkgs) - } else { - stop("Aborting due to missing, required packages.", call. = FALSE) - } - } - - shiny::runApp(appDir = system.file("app", package = "Rnaught")) -} diff --git a/R/web.R b/R/web.R new file mode 100644 index 0000000..ecfd501 --- /dev/null +++ b/R/web.R @@ -0,0 +1,57 @@ +#' Launch the Rnaught Web Application +#' +#' This is the entry point of the Rnaught web application, which creates and +#' returns a Shiny app object. When invoked directly, the web application is +#' launched. +#' +#' The following dependencies are required to run the application: +#' * [shiny](https://shiny.posit.co) +#' * [bslib](https://rstudio.github.io/bslib) +#' * [DT](https://rstudio.github.io/DT) +#' * [plotly](https://plotly-r.com) +#' +#' If any of the above packages are missing during launch, a prompt will appear +#' to install them. +#' +#' To configure settings such as the port, host or default browser, set Shiny's +#' global options (see [shiny::runApp()]). +#' +#' @return A Shiny app object for the Rnaught web application. +#' +#' @importFrom utils install.packages +#' +#' @export +web <- function() { + missing_pkgs <- c() + # Check for any missing, required packages. + if (!requireNamespace("shiny", quietly = TRUE)) { + missing_pkgs <- c(missing_pkgs, "shiny") + } + if (!requireNamespace("bslib", quietly = TRUE)) { + missing_pkgs <- c(missing_pkgs, "bslib") + } + if (!requireNamespace("DT", quietly = TRUE)) { + missing_pkgs <- c(missing_pkgs, "DT") + } + if (!requireNamespace("plotly", quietly = TRUE)) { + missing_pkgs <- c(missing_pkgs, "plotly") + } + + # If any of the required packages are missing, + # prompt the user to install them. + if (length(missing_pkgs) > 0) { + cat("The following packages must be installed to run the", + "Rnaught web application:\n" + ) + writeLines(missing_pkgs) + answer <- readline("Begin installation? [Y/n] ") + + if (answer == "Y" || answer == "y") { + install.packages(missing_pkgs) + } else { + stop("Aborting due to missing, required packages.", call. = FALSE) + } + } + + shiny::shinyAppDir(appDir = system.file("web", package = "Rnaught")) +} -- cgit v1.2.3