diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..5a61662 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,9 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^data-raw$ +dev_history.R +^dev$ +$run_dev.* +^LICENSE\.md$ +^README\.Rmd$ +^CODE_OF_CONDUCT\.md$ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d387fe3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.Rhistory +.RData +.Rproj.user diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0343527 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,25 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, we pledge to respect all people who +contribute through reporting issues, posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for +everyone, regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. + +Examples of unacceptable behavior by participants include the use of sexual language or +imagery, derogatory comments or personal attacks, trolling, public or private harassment, +insults, or other unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, +commits, code, wiki edits, issues, and other contributions that are not aligned to this +Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed +from the project team. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by +opening an issue or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the Contributor Covenant +(https://www.contributor-covenant.org), version 1.0.0, available at +https://contributor-covenant.org/version/1/0/0/. diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..cf16675 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,13 @@ +Package: MODifieRWeb +Title: Web MODifieR +Version: 0.0.0.9000 +Authors@R: person('AUTHOR_FIRST', 'AUTHOR_LAST', email = 'AUTHOR@MAIL.COM', role = c('cre', 'aut')) +Description: Shint interface to MODifieR. +License: MIT + file LICENSE +Imports: + config, + golem, + shiny +Encoding: UTF-8 +LazyData: true +RoxygenNote: 6.1.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9f9c244 --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2020 +COPYRIGHT HOLDER: Golem User diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9722571 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2020 Golem User + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MODifieRWeb.Rproj b/MODifieRWeb.Rproj new file mode 100644 index 0000000..21a4da0 --- /dev/null +++ b/MODifieRWeb.Rproj @@ -0,0 +1,17 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..1e667bc --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,11 @@ +# Generated by roxygen2: do not edit by hand + +export(run_app) +import(shiny) +importFrom(config,get) +importFrom(golem,activate_js) +importFrom(golem,add_resource_path) +importFrom(golem,bundle_resources) +importFrom(golem,favicon) +importFrom(golem,with_golem_options) +importFrom(shiny,shinyApp) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..72865a7 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# MODifieRWeb 0.0.0.9000 + +* Added a `NEWS.md` file to track changes to the package. diff --git a/R/app_config.R b/R/app_config.R new file mode 100644 index 0000000..d4d4cf8 --- /dev/null +++ b/R/app_config.R @@ -0,0 +1,34 @@ +#' Access files in the current app +#' +#' @param ... Character vector specifying directory and or file to +#' point to inside the current package. +#' +#' @noRd +app_sys <- function(...){ + system.file(..., package = "MODifieRWeb") +} + + +#' Read App Config +#' +#' @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. +#' +#' @importFrom config get +#' +#' @noRd +get_golem_config <- function( + value, + config = 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 + ) +} + diff --git a/R/app_server.R b/R/app_server.R new file mode 100644 index 0000000..20d69cb --- /dev/null +++ b/R/app_server.R @@ -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 ) { + # List the first level callModules here + +} diff --git a/R/app_ui.R b/R/app_ui.R new file mode 100644 index 0000000..612d2aa --- /dev/null +++ b/R/app_ui.R @@ -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(), + # List the first level UI elements here + fluidPage( + h1("MODifieRWeb") + ) + ) +} + +#' 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 = 'MODifieRWeb' + ) + # Add here other external resources + # for example, you can add shinyalert::useShinyalert() + ) +} + diff --git a/R/run_app.R b/R/run_app.R new file mode 100644 index 0000000..dd6ae78 --- /dev/null +++ b/R/run_app.R @@ -0,0 +1,18 @@ +#' Run the Shiny 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(...) + ) +} diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..249d5a4 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,55 @@ +--- +output: github_document +--- + + + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + fig.path = "man/figures/README-", + out.width = "100%" +) +``` + +# MODifieRWeb + + +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) + + +The goal of MODifieRWeb is to ... + +## Installation + +You can install the released version of MODifieRWeb from [CRAN](https://CRAN.R-project.org) with: + +``` r +install.packages("MODifieRWeb") +``` + +## Example + +This is a basic example which shows you how to solve a common problem: + +```{r example} +library(MODifieRWeb) +## basic example code +``` + +What is special about using `README.Rmd` instead of just `README.md`? You can include R chunks like so: + +```{r cars} +summary(cars) +``` + +You'll still need to render `README.Rmd` regularly, to keep `README.md` up-to-date. + +You can also embed plots, for example: + +```{r pressure, echo = FALSE} +plot(pressure) +``` + +In that case, don't forget to commit and push the resulting figure files, so they display on GitHub! diff --git a/dev/01_start.R b/dev/01_start.R new file mode 100644 index 0000000..7f7ae36 --- /dev/null +++ b/dev/01_start.R @@ -0,0 +1,60 @@ +# Building a Prod-Ready, Robust Shiny Application. +# +# README: each step of the dev files is optional, and you don't have to +# fill every dev scripts before getting started. +# 01_start.R should be filled at start. +# 02_dev.R should be used to keep track of your development during the project. +# 03_deploy.R should be used once you need to deploy your app. +# +# +######################################## +#### CURRENT FILE: ON START SCRIPT ##### +######################################## + +## Fill the DESCRIPTION ---- +## Add meta data about your application +golem::fill_desc( + pkg_name = "MODifieRWeb", # The Name of the package containing the App + pkg_title = "Web MODifieR", # The Title of the package containing the App + pkg_description = "Shint interface to MODifieR.", # The Description of the package containing the App + author_first_name = "AUTHOR_FIRST", # Your First Name + author_last_name = "AUTHOR_LAST", # Your Last Name + author_email = "AUTHOR@MAIL.COM", # Your Email + repo_url = NULL # The URL of the GitHub Repo (optional) +) + +## Set {golem} options ---- +golem::set_golem_options() + +## Create Common Files ---- +## See ?usethis for more information +usethis::use_mit_license( name = "Golem User" ) # You can set another license here +usethis::use_readme_rmd( open = FALSE ) +usethis::use_code_of_conduct() +usethis::use_lifecycle_badge( "Experimental" ) +usethis::use_news_md( open = FALSE ) + +## Use git ---- +usethis::use_git() + +## Init Testing Infrastructure ---- +## Create a template for tests +golem::use_recommended_tests() + +## Use Recommended Packages ---- +golem::use_recommended_deps() + +## Favicon ---- +# If you want to change the favicon (default is golem's one) +golem::remove_favicon() +golem::use_favicon() # path = "path/to/ico". Can be an online file. + +## Add helper functions ---- +golem::use_utils_ui() +golem::use_utils_server() + +# You're now set! ---- + +# go to dev/02_dev.R +rstudioapi::navigateToFile( "dev/02_dev.R" ) + diff --git a/dev/02_dev.R b/dev/02_dev.R new file mode 100644 index 0000000..0fcce27 --- /dev/null +++ b/dev/02_dev.R @@ -0,0 +1,59 @@ +# Building a Prod-Ready, Robust Shiny Application. +# +# README: each step of the dev files is optional, and you don't have to +# fill every dev scripts before getting started. +# 01_start.R should be filled at start. +# 02_dev.R should be used to keep track of your development during the project. +# 03_deploy.R should be used once you need to deploy your app. +# +# +################################### +#### CURRENT FILE: DEV SCRIPT ##### +################################### + +# Engineering + +## Dependencies ---- +## Add one line by package you want to add as dependency +usethis::use_package( "thinkr" ) + +## Add modules ---- +## Create a module infrastructure in R/ +golem::add_module( name = "name_of_module1" ) # Name of the module +golem::add_module( name = "name_of_module2" ) # Name of the module + +## Add helper functions ---- +## Creates ftc_* and utils_* +golem::add_fct( "helpers" ) +golem::add_utils( "helpers" ) + +## External resources +## Creates .js and .css files at inst/app/www +golem::add_js_file( "script" ) +golem::add_js_handler( "handlers" ) +golem::add_css_file( "custom" ) + +## Add internal datasets ---- +## If you have data in your package +usethis::use_data_raw( name = "my_dataset", open = FALSE ) + +## Tests ---- +## Add one line by test you want to create +usethis::use_test( "app" ) + +# Documentation + +## Vignette ---- +usethis::use_vignette("MODifieRWeb") +devtools::build_vignettes() + +## Code coverage ---- +## (You'll need GitHub there) +usethis::use_github() +usethis::use_travis() +usethis::use_appveyor() + +# You're now set! ---- +# go to dev/03_deploy.R +rstudioapi::navigateToFile("dev/03_deploy.R") + diff --git a/dev/03_deploy.R b/dev/03_deploy.R new file mode 100644 index 0000000..4e36df6 --- /dev/null +++ b/dev/03_deploy.R @@ -0,0 +1,37 @@ +# Building a Prod-Ready, Robust Shiny Application. +# +# README: each step of the dev files is optional, and you don't have to +# fill every dev scripts before getting started. +# 01_start.R should be filled at start. +# 02_dev.R should be used to keep track of your development during the project. +# 03_deploy.R should be used once you need to deploy your app. +# +# +###################################### +#### CURRENT FILE: DEPLOY SCRIPT ##### +###################################### + +# Test your app + +## Run checks ---- +## Check the package before sending to prod +devtools::check() +rhub::check_for_cran() + +# Deploy + +## RStudio ---- +## If you want to deploy on RStudio related platforms +golem::add_rstudioconnect_file() +golem::add_shinyappsio_file() +golem::add_shinyserver_file() + +## Docker ---- +## If you want to deploy via a generic Dockerfile +golem::add_dockerfile() + +## If you want to deploy to ShinyProxy +golem::add_dockerfile_shinyproxy() + +## If you want to deploy to Heroku +golem::add_dockerfile_heroku() diff --git a/dev/run_dev.R b/dev/run_dev.R new file mode 100644 index 0000000..6729c32 --- /dev/null +++ b/dev/run_dev.R @@ -0,0 +1,12 @@ +# Set options here +options(golem.app.prod = FALSE) # TRUE = production mode, FALSE = development mode + +# Detach all loaded packages and clean your environment +golem::detach_all_attached() +# rm(list=ls(all.names = TRUE)) + +# Document and reload your package +golem::document_and_reload() + +# Run the application +run_app() diff --git a/inst/app/www/favicon.ico b/inst/app/www/favicon.ico new file mode 100644 index 0000000..4c0982c Binary files /dev/null and b/inst/app/www/favicon.ico differ diff --git a/inst/golem-config.yml b/inst/golem-config.yml new file mode 100644 index 0000000..8910aea --- /dev/null +++ b/inst/golem-config.yml @@ -0,0 +1,8 @@ +default: + golem_name: MODifieRWeb + golem_version: 0.0.0.9000 + app_prod: no +production: + app_prod: yes +dev: + golem_wd: !expr here::here() diff --git a/man/run_app.Rd b/man/run_app.Rd new file mode 100644 index 0000000..db9dd85 --- /dev/null +++ b/man/run_app.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/run_app.R +\name{run_app} +\alias{run_app} +\title{Run the Shiny Application} +\usage{ +run_app(...) +} +\arguments{ +\item{...}{A series of options to be used inside the app.} +} +\description{ +Run the Shiny Application +}