Initial
This commit is contained in:
43
opportunityscoring/R/app_config.R
Normal file
43
opportunityscoring/R/app_config.R
Normal file
@@ -0,0 +1,43 @@
|
||||
#' Access files in the current app
|
||||
#'
|
||||
#' NOTE: If you manually change your package name in the DESCRIPTION,
|
||||
#' don't forget to change it here too, and in the config file.
|
||||
#' For a safer name change mechanism, use the `golem::set_golem_name()` function.
|
||||
#'
|
||||
#' @param ... character vectors, specifying subdirectory and file(s)
|
||||
#' within your package. The default, none, returns the root of the app.
|
||||
#'
|
||||
#' @noRd
|
||||
app_sys <- function(...){
|
||||
system.file(..., package = "opportunityscoring")
|
||||
}
|
||||
|
||||
|
||||
#' Read App Config
|
||||
#'
|
||||
#' @param value Value to retrieve from the config file.
|
||||
#' @param config GOLEM_CONFIG_ACTIVE value. If unset, R_CONFIG_ACTIVE.
|
||||
#' If unset, "default".
|
||||
#' @param use_parent Logical, scan the parent directory for config file.
|
||||
#'
|
||||
#' @noRd
|
||||
get_golem_config <- function(
|
||||
value,
|
||||
config = Sys.getenv(
|
||||
"GOLEM_CONFIG_ACTIVE",
|
||||
Sys.getenv(
|
||||
"R_CONFIG_ACTIVE",
|
||||
"default"
|
||||
)
|
||||
),
|
||||
use_parent = TRUE
|
||||
){
|
||||
config::get(
|
||||
value = value,
|
||||
config = config,
|
||||
# Modify this if your config file is somewhere else:
|
||||
file = app_sys("golem-config.yml"),
|
||||
use_parent = use_parent
|
||||
)
|
||||
}
|
||||
|
||||
10
opportunityscoring/R/app_server.R
Normal file
10
opportunityscoring/R/app_server.R
Normal file
@@ -0,0 +1,10 @@
|
||||
#' The application server-side
|
||||
#'
|
||||
#' @param input,output,session Internal parameters for {shiny}.
|
||||
#' DO NOT REMOVE.
|
||||
#' @import shiny
|
||||
#' @noRd
|
||||
app_server <- function( input, output, session ) {
|
||||
# Your application server logic
|
||||
|
||||
}
|
||||
42
opportunityscoring/R/app_ui.R
Normal file
42
opportunityscoring/R/app_ui.R
Normal file
@@ -0,0 +1,42 @@
|
||||
#' The application User-Interface
|
||||
#'
|
||||
#' @param request Internal parameter for `{shiny}`.
|
||||
#' DO NOT REMOVE.
|
||||
#' @import shiny
|
||||
#' @noRd
|
||||
app_ui <- function(request) {
|
||||
tagList(
|
||||
# Leave this function for adding external resources
|
||||
golem_add_external_resources(),
|
||||
# Your application UI logic
|
||||
fluidPage(
|
||||
h1("opportunityscoring")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
#' Add external Resources to the Application
|
||||
#'
|
||||
#' This function is internally used to add external
|
||||
#' resources inside the Shiny application.
|
||||
#'
|
||||
#' @import shiny
|
||||
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
|
||||
#' @noRd
|
||||
golem_add_external_resources <- function(){
|
||||
|
||||
add_resource_path(
|
||||
'www', app_sys('app/www')
|
||||
)
|
||||
|
||||
tags$head(
|
||||
favicon(),
|
||||
bundle_resources(
|
||||
path = app_sys('app/www'),
|
||||
app_title = 'opportunityscoring'
|
||||
)
|
||||
# Add here other external resources
|
||||
# for example, you can add shinyalert::useShinyalert()
|
||||
)
|
||||
}
|
||||
|
||||
28
opportunityscoring/R/run_app.R
Normal file
28
opportunityscoring/R/run_app.R
Normal file
@@ -0,0 +1,28 @@
|
||||
#' Run the Shiny Application
|
||||
#'
|
||||
#' @param ... arguments to pass to golem_opts.
|
||||
#' See `?golem::get_golem_options` for more details.
|
||||
#' @inheritParams shiny::shinyApp
|
||||
#'
|
||||
#' @export
|
||||
#' @importFrom shiny shinyApp
|
||||
#' @importFrom golem with_golem_options
|
||||
run_app <- function(
|
||||
onStart = NULL,
|
||||
options = list(),
|
||||
enableBookmarking = NULL,
|
||||
uiPattern = "/",
|
||||
...
|
||||
) {
|
||||
with_golem_options(
|
||||
app = shinyApp(
|
||||
ui = app_ui,
|
||||
server = app_server,
|
||||
onStart = onStart,
|
||||
options = options,
|
||||
enableBookmarking = enableBookmarking,
|
||||
uiPattern = uiPattern
|
||||
),
|
||||
golem_opts = list(...)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user