2024-02-27 12:43:54 +01:00
|
|
|
utils::globalVariables(c("server"))
|
2024-02-26 09:34:05 +01:00
|
|
|
#' Shiny server factory
|
|
|
|
#'
|
|
|
|
#' @return shiny server
|
|
|
|
#' @export
|
|
|
|
server_factory <- function() {
|
2024-02-26 20:32:26 +01:00
|
|
|
source(here::here("app/server.R"))
|
|
|
|
server
|
2024-02-26 09:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#' UI factory for shiny app
|
|
|
|
#'
|
|
|
|
#' @return shiny ui
|
|
|
|
#' @export
|
|
|
|
ui_factory <- function() {
|
|
|
|
# require(ggplot2)
|
2024-02-27 13:20:21 +01:00
|
|
|
source(here::here("app/ui.R"))
|
2024-02-26 09:34:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#' Launch the included Shiny-app for database casting and upload
|
|
|
|
#'
|
|
|
|
#' @return shiny app
|
|
|
|
#' @export
|
|
|
|
#'
|
|
|
|
#' @examples
|
|
|
|
#' # shiny_cast()
|
|
|
|
#'
|
|
|
|
shiny_cast <- function() {
|
|
|
|
# shiny::runApp(appDir = here::here("app/"), launch.browser = TRUE)
|
|
|
|
|
|
|
|
shiny::shinyApp(
|
|
|
|
ui_factory(),
|
|
|
|
server_factory()
|
|
|
|
)
|
|
|
|
}
|
2024-02-26 15:07:54 +01:00
|
|
|
|
2024-03-14 09:26:22 +01:00
|
|
|
#' Deploy the Shiny app with rsconnect to shinyapps.io
|
|
|
|
#'
|
|
|
|
#' @description
|
|
|
|
#' This is really just a simple wrapper
|
2024-02-26 20:32:26 +01:00
|
|
|
#'
|
2024-02-27 12:43:54 +01:00
|
|
|
#' @param path app folder path
|
|
|
|
#' @param name.app name of deployed app
|
2024-03-14 09:26:22 +01:00
|
|
|
#' @param name.token stored name of token
|
|
|
|
#' @param name.secret stored name of secret
|
2024-02-27 12:43:54 +01:00
|
|
|
#'
|
2024-02-26 20:32:26 +01:00
|
|
|
#' @return deploy
|
|
|
|
#' @export
|
|
|
|
#'
|
|
|
|
#' @examples
|
2024-03-14 09:26:22 +01:00
|
|
|
#' # deploy_shiny()
|
2024-02-26 20:32:26 +01:00
|
|
|
#'
|
2024-03-14 09:26:22 +01:00
|
|
|
deploy_shiny <- function(path = here::here("app/"),
|
|
|
|
account.name,
|
|
|
|
name.app = "shiny_cast",
|
|
|
|
name.token,
|
|
|
|
name.secret) {
|
2024-02-26 20:32:26 +01:00
|
|
|
# Connecting
|
|
|
|
rsconnect::setAccountInfo(
|
2024-03-14 09:26:22 +01:00
|
|
|
name = account.name,
|
|
|
|
token = keyring::key_get(service = name.token),
|
|
|
|
secret = keyring::key_get(service = name.secret)
|
2024-02-26 20:32:26 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Deploying
|
2024-02-27 13:20:21 +01:00
|
|
|
rsconnect::deployApp(appDir = path, lint = TRUE, appName = name.app, )
|
2024-02-26 20:32:26 +01:00
|
|
|
}
|