Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
marton-balazs-kovacs committed Apr 19, 2020
0 parents commit e94ef0a
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
^data-raw$
dev_history.R
^dev$
$run_dev.*
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
12 changes: 12 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Package: tenzing
Title: An Amazing Shiny App
Version: 0.0.0.9000
Authors@R: person("firstname", "lastname", email = "[email protected]", role = c("aut", "cre"))
Description: What the package does (one paragraph).
License: What license is it under?
Encoding: UTF-8
LazyData: true
Imports:
shiny,
golem
RoxygenNote: 6.1.0
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(run_app)
import(shiny)
importFrom(shiny,addResourcePath)
importFrom(shiny,runApp)
4 changes: 4 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#' @import shiny
app_server <- function(input, output,session) {
# List the first level callModules here
}
28 changes: 28 additions & 0 deletions R/app_ui.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' @import shiny
app_ui <- function() {
tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
# List the first level UI elements here
fluidPage(
h1("tenzing")
)
)
}

#' @import shiny
golem_add_external_resources <- function(){

addResourcePath(
'www', system.file('app/www', package = 'tenzing')
)

tags$head(
golem::activate_js(),
golem::favicon()
# Add here all the external resources
# If you have a custom.css in the inst/app/www
# Or for example, you can add shinyalert::useShinyalert() here
#tags$link(rel="stylesheet", type="text/css", href="www/custom.css")
)
}
11 changes: 11 additions & 0 deletions R/run_app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' Run the Shiny Application
#'
#' @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(...)
)
}
65 changes: 65 additions & 0 deletions dev/01_start.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Building a Prod-Ready, Robust Shiny Application.
#
# Each step is optional.
#
# 1 - On init
#
## 1.1 - Fill the descripion & set options
##
## Add information about the package that will contain your app

golem::fill_desc(
pkg_name = "tenzing", # The Name of the package containing the App
pkg_title = "PKG_TITLE", # The Title of the package containing the App
pkg_description = "PKG_DESC.", # 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 = "[email protected]", # Your Email
repo_url = NULL # The (optional) URL of the GitHub Repo
)

## Use this desc to set {golem} options

golem::set_golem_options()

## 1.2 - Set common Files
##
## If you want to use the MIT licence, README, code of conduct, lifecycle badge, and news

usethis::use_mit_license( name = "Golem User" ) # You can set another licence here
usethis::use_readme_rmd( open = FALSE )
usethis::use_code_of_conduct()
usethis::use_lifecycle_badge( "Experimental" )

usethis::use_news_md( open = FALSE )
usethis::use_git()

## 1.3 - Add a data-raw folder
##
## If you have data in your package
usethis::use_data_raw( name = "my_dataset", open = FALSE ) # Change "my_dataset"

## 1.4 - Init Tests
##
## Create a template for tests

golem::use_recommended_tests()

## 1.5 : Use Recommended Package

golem::use_recommended_deps()

## 1.6 Add various tools

# 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" )

45 changes: 45 additions & 0 deletions dev/02_dev.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Building a Prod-Ready, Robust Shiny Application.
#
# Each step is optional.
#

# 2. All along your project

## 2.1 Add modules
##
golem::add_module( name = "my_first_module" ) # Name of the module
golem::add_module( name = "my_other_module" ) # Name of the module

## 2.2 Add dependencies

usethis::use_package( "thinkr" ) # To call each time you need a new package

## 2.3 Add tests

usethis::use_test( "app" )

## 2.4 Add a browser button

golem::browser_button()

## 2.5 Add external files

golem::add_js_file( "script" )
golem::add_js_handler( "handlers" )
golem::add_css_file( "custom" )

# 3. Documentation

## 3.1 Vignette
usethis::use_vignette("tenzing")
devtools::build_vignettes()

## 3.2 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")
22 changes: 22 additions & 0 deletions dev/03_deploy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Deploy a Prod-Ready, Robust Shiny Application.
#
# 4. Test my package

devtools::test()
rhub::check_for_cran()

# 5. Deployment elements

## 5.1 If you want to deploy on RStudio related platforms
golem::add_rstudioconnect_file()
golem::add_shinyappsio_file()
golem::add_shinyserver_file()

## 5.2 If you want to deploy via a generic Dockerfile
golem::add_dockerfile()

## 5.2 If you want to deploy to ShinyProxy
golem::add_dockerfile_shinyproxy()

## 5.2 If you want to deploy to Heroku
golem::add_dockerfile_heroku()
12 changes: 12 additions & 0 deletions dev/run_dev.R
Original file line number Diff line number Diff line change
@@ -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
tenzing::run_app()
Binary file added inst/app/www/favicon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions man/run_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tenzing.Rproj
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e94ef0a

Please sign in to comment.