inst/template/app.R

#' @title
#' Shiny Application
#'
#' @description
#' The shiny application is developed using the golem framework.
#'
#' @name app
NULL

#' @describeIn app Application User Interface
#' @param request Internal parameter for `{shiny}`.
#' @import shiny
app_ui <- function(request) {
    tagList(
        app_resources(),
        fluidPage()
    )
}

#' @describeIn app Application Server Logic
#' @param input,output,session Internal parameters for {shiny}.
#' @import shiny
app_server <- function(input, output, session) {
    # List the first level callModules here
}

#' @describeIn app Application Configuration
#' @param value Value to retrieve from the config file.
#' @param config R_CONFIG_ACTIVE value.
#' @param use_parent Logical, scan the parent directory for config file.
app_config <- function(value,
                       config = Sys.getenv("R_CONFIG_ACTIVE", "default"),
                       use_parent = TRUE) {
    config::get(
        value = value,
        config = config,
        file = dev_pkg_inst("golem-config.yml"),
        use_parent = use_parent
    )
}

#' @describeIn app Application Resources
#' @import shiny
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
app_resources <- function() {
    add_resource_path("www", dev_pkg_inst("app/www"))

    tags$head(
        favicon(ext = "png"),
        bundle_resources(
            path = dev_pkg_inst("app/www"),
            app_title = "Application Title"
        )
    )
}

#' @describeIn app Run the Application
#' @param ... A series of options to be used inside the app.
#' @export
#' @importFrom shiny shinyApp
#' @importFrom golem with_golem_options
run_app <- function(...) {
    with_golem_options(
        app = shinyApp(
            ui = app_ui,
            server = app_server
        ),
        golem_opts = list(...)
    )
}
tjpalanca/tjutils documentation built on Jan. 20, 2021, 2:01 p.m.