From 5c3c5b7bd7ceeb6a477b5168fef75e5a0b643b83 Mon Sep 17 00:00:00 2001 From: statnmap Date: Sat, 25 Sep 2021 17:35:34 +0200 Subject: [PATCH 1/7] New look with bs4_book --- .gitignore | 1 + .travis.yml | 31 --- 01-big-shiny.Rmd | 2 +- 06-ux-matters.Rmd | 4 +- 14-when_optimize.Rmd | 6 +- CONTRIBUTING.md | 48 ++++ DESCRIPTION | 6 +- _bookdown.yml | 1 + _output.yml | 9 +- before-build.R | 2 +- css/style_gitbook.css | 8 +- gitbook-footer-thinkr.html | 2 +- index.Rmd | 16 +- prep.R | 3 + renv.lock | 445 ++++++++++++++++++++----------------- 15 files changed, 329 insertions(+), 255 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitignore b/.gitignore index 9d7b3510..98c1f4ce 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ _book/* !engineering-production-grade-shiny-apps.Rproj golex/ todoedit +_site/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 281cf0c4..00000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: r -cache: packages -os: linux -dist: bionic - -env: - global: - - MAKEFLAGS="-j 2" - -jobs: - include: - - r: 3.6 - -install: - - Rscript -e 'if(dir.exists("cache")){unlink("cache")}' - - Rscript -e 'install.packages("remotes")' - - Rscript -e "install.packages('tinytex')" - - Rscript -e "tinytex::install_tinytex()" - - Rscript -e 'remotes::install_github("ThinkR-open/golem", ref = "dev")' - - Rscript -e 'remotes::install_local(force = TRUE)' - -script: - - if [ $TRAVIS_BRANCH == "wip" ] ; then make html_wip; fi - - if [ $TRAVIS_BRANCH == "master" ] ; then make html_master; fi - - if [ $TRAVIS_BRANCH == "wip" ] ; then make pdf; fi - -after_success: - - if ([ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_BRANCH == "wip" ]) ; then bash deploy.sh; fi - - if ([ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_BRANCH == "master" ]) ; then bash deploy.sh; fi - - diff --git a/01-big-shiny.Rmd b/01-big-shiny.Rmd index eb249777..74450984 100644 --- a/01-big-shiny.Rmd +++ b/01-big-shiny.Rmd @@ -445,7 +445,7 @@ This package can now be used to assess the dependencies we use in our applicatio To do that, let's create a small function that computes this metric and returns a tibble: ```{r 01-big-shiny-25 } -library() +library(packageMetrics2) # A function to turn the output of the metrics into a data.frame frame_metric <- function(pkg){ metrics <- package_metrics(pkg) diff --git a/06-ux-matters.Rmd b/06-ux-matters.Rmd index a7ec0f1a..f30ef90d 100644 --- a/06-ux-matters.Rmd +++ b/06-ux-matters.Rmd @@ -50,8 +50,8 @@ First of all, users rarely carefully read all the instructions: they **scan** an Navigating the web, users try to optimize their decision, not by making the decision that would be "optimal", but by doing the first action that is sufficiently satisfactory in relevance. They behave like that for a lot of reasons, but notably because they want to be as quick as possible on the web, and because the cost of being wrong is very low most of the time - even if you make the wrong decision on a website, chances are that you are just a "return" or "cancel" button away from canceling your last action. -(ref:scanningcap) How we design a web page versus how a user will really scan it. -From [@stevekrug2014]. +(ref:scanningcap) How we design a web page versus how a user will really scan it. From [@stevekrug2014]. + ```{r 06-ux-matters-1, echo=FALSE, fig.cap="(ref:scanningcap)", out.width="100%"} knitr::include_graphics("img/scanning.png") diff --git a/14-when_optimize.Rmd b/14-when_optimize.Rmd index c44f6170..e36b7a9a 100644 --- a/14-when_optimize.Rmd +++ b/14-when_optimize.Rmd @@ -597,9 +597,11 @@ Here is what it can look like inside a `Dockerfile` (Note that you will need to FROM rocker/shiny-verse:3.6.3 - RUN apt-get -y install curl RUN curl -sL \ + RUN apt-get -y install curl + RUN curl -sL \ \ - | bash - RUN apt-get install -y nodejs + | bash - + RUN apt-get install -y nodejs RUN Rscript -e 'remotes::install_github("colinfay/minifyr")' RUN Rscript -e 'remotes::install_cran("cicerone")' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 447f69a4..f98da4d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,3 +24,51 @@ There are two ways to contribute to the book: + Add your name in the Acknowledgment section in the introduction. + If you want to contribute written content, you might want to open an issue first so that we can discuss the topic first. + +## Building + +### Build the book locally with existing cache + +This requires Docker, Node and multiple dependencies installed using {renv}. +By default, this will use the cache to restore outputs. + +*hexmake* +```sh +docker pull colinfay/hexmake +``` + +*minifyr* +```sh +sudo apt-get -y install curl +sudo apt-get install -y nodejs + +Rscript -e 'remotes::install_github("colinfay/minifyr")' +Rscript -e 'remotes::install_cran("cicerone")' +# Verify it works +Rscript -e 'library(minifyr); + minifyr_npm_install(TRUE); + minify_package_js("cicerone", minifyr_js_uglify)' +``` + +Then you can build it in a Terminal +```sh +Rscript prep.R +Rscript -e 'bookdown::render_book("index.Rmd")' +Rscript -e 'browseURL("_site/index.html")' +``` + +### Update the list of dependencies in DESCRIPTION + +```sh +Rscript -e 'source("before-build.R")' +``` + +### Update versions of packages in {renv} + +```sh +Rscript -e 'renv::snapshot()' +``` + +### Recreate datasets + +Run the content of 'render_all.R' diff --git a/DESCRIPTION b/DESCRIPTION index bccb795f..5e76fc39 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,9 +28,9 @@ Authors@R: Description: Open source book on R for reproducible, robust and maintainable Shiny applications for production. License: MIT + file LICENSE -URL: https://github.com/ThinkR-open/building-shiny-apps-workflow +URL: https://github.com/ThinkR-open/engineering-shiny-book BugReports: - https://github.com/ThinkR-open/building-shiny-apps-workflow/issues + https://github.com/ThinkR-open/engineering-shiny-book/issues Depends: bookdown (>= 0.18) Imports: @@ -39,6 +39,7 @@ Imports: bank (>= 0.0.0.9000), bench (>= 1.1.1), bs4Dash (>= 0.5.0), + bslib, bubble (>= 0.0.0.9003), chromote (>= 0.0.0.9001), cli (>= 2.0.2), @@ -58,6 +59,7 @@ Imports: dichromat (>= 2.0.0), dockerfiler (>= 0.1.3), dockerstats (>= 0.0.0.9000), + downlit, dplyr (>= 1.0.2), DT (>= 0.15), fakir (>= 0.2.0), diff --git a/_bookdown.yml b/_bookdown.yml index c6dc4789..ed2ecbc8 100644 --- a/_bookdown.yml +++ b/_bookdown.yml @@ -1,6 +1,7 @@ book_filename: engineering-production-grade-shiny-apps clean: [packages.bib, bookdown.bbl] delete_merged_file: yes +repo: https://github.com/ThinkR-open/engineering-shiny-book language: label: fig: "FIGURE " diff --git a/_output.yml b/_output.yml index 5e686c45..daec3a34 100644 --- a/_output.yml +++ b/_output.yml @@ -1,5 +1,5 @@ -bookdown::gitbook: - css: [css/style.css, css/thinkr.css, css/style_gitbook.css] +bookdown::bs4_book: + css: [css/style.css, css/style_gitbook.css] toc_depth: 3 config: toc: @@ -17,6 +17,11 @@ bookdown::gitbook: includes: in_header: ga.html after_body: gitbook-footer-thinkr.html + theme: + primary: "#DE633C" + fg: "#2b2121" + bg: "#ffffff" + repo: https://github.com/ThinkR-open/engineering-shiny-book bookdown::pdf_book: includes: in_header: latex/preamble.tex diff --git a/before-build.R b/before-build.R index af89373f..ef1d6486 100644 --- a/before-build.R +++ b/before-build.R @@ -28,7 +28,7 @@ paks <- c( "tidymodules", "shinyjs", "htmlwidgets", "hunspell", "rhub", "spelling", "tufte", "uuid", "attachment", "remotes", "usethis", "namer", "desc", "spelling", "tufte", - "dockerstats", "spelling", "tidymodules", "bank" + "dockerstats", "spelling", "tidymodules", "bank", "downlit", "bslib" ) paks <- unique(paks) diff --git a/css/style_gitbook.css b/css/style_gitbook.css index 1d65af18..48385256 100644 --- a/css/style_gitbook.css +++ b/css/style_gitbook.css @@ -34,7 +34,7 @@ /* Document formatting*/ body { font-family: "Noto Sans", sans-serif; - font-size: 1.5rem; + /* font-size: 1.5rem; */ text-align: justify; } @@ -78,10 +78,11 @@ h3 { text-align: center; } -.book .book-body .page-wrapper .page-inner section.normal a { +#content a, .book .book-body .page-wrapper .page-inner section.normal a { color: #DE633C; } + /* thinkr.css .container-fluid.main-container { margin-top: 80px; @@ -114,6 +115,9 @@ h1 { h2 { color: #15b7d6; } +.sidebar h2 { + color: black; +} /* Footer with logo */ footer { diff --git a/gitbook-footer-thinkr.html b/gitbook-footer-thinkr.html index 2ab998b7..b5ca8efc 100644 --- a/gitbook-footer-thinkr.html +++ b/gitbook-footer-thinkr.html @@ -1,6 +1,6 @@