Skip to content

Commit

Permalink
Merge pull request #308 from ThinkR-open/bs4_book
Browse files Browse the repository at this point in the history
New look with bs4_book
  • Loading branch information
ColinFay authored Sep 29, 2021
2 parents ac5eda7 + 9c86853 commit 8871d38
Show file tree
Hide file tree
Showing 17 changed files with 389 additions and 257 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build_bookdown_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
pull_request:
branches:
- master

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

name: renderbookpr

jobs:
bookdown:

name: Render-Book

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- uses: r-lib/actions/setup-r@v1
with:
crayon.enabled: 'FALSE'
r-version: '3.6.1'

- uses: actions/cache@v1
with:
path: ~/.local/share/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- uses: r-lib/actions/setup-pandoc@v1

- name: Install tinytex
uses: r-lib/actions/setup-tinytex@master

- name: Install sysreq
run: sudo apt update && sudo apt install -y gdal-bin git-core libcairo2-dev libgdal-dev libgeos-dev libgeos++-dev libgit2-dev libpng-dev libssh2-1-dev libssl-dev libudunits2-dev libxml2-dev make pandoc pandoc-citeproc zlib1g-dev libmagick++-dev libssl-dev libsasl2-dev

- name: Pulling hexmake
run: docker pull colinfay/hexmake

- uses: nanasess/setup-chromedriver@master

- name: Install rmarkdown, bookdown and sysfonts
run: Rscript -e 'install.packages(c("sysfonts", "rmarkdown","bookdown"), Ncpus = 4)'

- name: Before build
run: Rscript prep.R

- name: Render Book
run: Rscript -e 'bookdown::render_book("index.Rmd")'

- uses: actions/upload-artifact@v2
with:
name: _site
path: _site/
5 changes: 4 additions & 1 deletion .github/workflows/deploy_bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
branches:
- master

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

name: renderbook

jobs:
Expand Down Expand Up @@ -53,7 +56,7 @@ jobs:
run: Rscript prep.R

- name: Render Book
run: docker pull colinfay/hexmake && Rscript -e 'bookdown::render_book("index.Rmd")'
run: Rscript -e 'bookdown::render_book("index.Rmd")'

- name: Build redirect
run: Rscript redirect.R
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ _book/*
!engineering-production-grade-shiny-apps.Rproj
golex/
todoedit
_site/
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion 01-big-shiny.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions 06-ux-matters.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions 14-when_optimize.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
<https://deb.nodesource.com/setup_14.x> \
| 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")'
Expand Down
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -39,6 +39,7 @@ Imports:
bank (>= 0.0.0.9000),
bench (>= 1.1.1),
bs4Dash (>= 0.5.0),
bslib (>= 0.2.5.1),
bubble (>= 0.0.0.9003),
chromote (>= 0.0.0.9001),
cli (>= 2.0.2),
Expand All @@ -58,6 +59,7 @@ Imports:
dichromat (>= 2.0.0),
dockerfiler (>= 0.1.3),
dockerstats (>= 0.0.0.9000),
downlit (>= 0.2.1),
dplyr (>= 1.0.2),
DT (>= 0.15),
fakir (>= 0.2.0),
Expand Down
1 change: 1 addition & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
@@ -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 "
Expand Down
9 changes: 7 additions & 2 deletions _output.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion before-build.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions css/style_gitbook.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* Document formatting*/
body {
font-family: "Noto Sans", sans-serif;
font-size: 1.5rem;
/* font-size: 1.5rem; */
text-align: justify;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -114,6 +115,9 @@ h1 {
h2 {
color: #15b7d6;
}
.sidebar h2 {
color: black;
}

/* Footer with logo */
footer {
Expand Down
2 changes: 1 addition & 1 deletion gitbook-footer-thinkr.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<hr/>
<footer>
<a href="rtask.thinkr.fr"><img src="img/logo400_129.png" alt="ThinkR Website"/></a>
<a href="https://rtask.thinkr.fr"><img src="img/logo400_129.png" alt="ThinkR Website"/></a>
<!--https://yihui.org/en/2018/09/target-blank/-->
<script>
(function() {
Expand Down
16 changes: 5 additions & 11 deletions index.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Engineering Production-Grade Shiny Apps"
author: "Colin Fay, Sébastien Rochette, Vincent Guyader, Cervan Girard"
author: ["Colin Fay", "Sébastien Rochette", "Vincent Guyader", "Cervan Girard"]
date: "`r Sys.Date()`"
documentclass: krantz
lof: yes
Expand All @@ -13,7 +13,7 @@ colorlinks: yes
site: bookdown::bookdown_site
description: "A book about engineering shiny application that will later be sent to production. This book cover project management, structuring your project, building a solid testing suite, and optimizing your codebase. We describe in this book a specific workflow: design, prototype, build, strengthen and deploy."
favicon: img/favicon.ico
github-repo: ThinkR-open/building-shiny-apps-workflow
github-repo: ThinkR-open/engineering-shiny-book
graphics: yes
nocite: '@*'
cover-image: https://raw.githubusercontent.com/ThinkR-open/engineering-shiny-book/master/img/engineering-shiny.jpg
Expand Down Expand Up @@ -59,14 +59,8 @@ options(width = 55)

# Introduction {-}

<style>
img.left {
float: left;
margin-right: 1em;
}
</style>
<img src="img/engineering-shiny.jpg" width="300" align="right" alt="" class="cover" /> Welcome to "Engineering Production-Grade Shiny Apps" by [Colin Fay](https://colinfay.me/), [Sébastien Rochette](statnmap.com), [Vincent Guyader](https://rtask.thinkr.fr/consultants-r-experts/vincent-guyader/) and [Cervan Girard](https://rtask.thinkr.fr/consultants-r-experts/cervan-girard).

<img src="img/engineering-shiny.jpg" class = "left" width = "300px">

`r if (knitr::is_html_output()) '
This book will soon be available in print, published in the [R Series](https://www.crcpress.com/go/the-r-series) by Chapman & Hall.
Expand Down Expand Up @@ -225,7 +219,7 @@ means that the package will be installed from GitHub, and that you can use the `
## Want to help? {-}

Any feedback on the book is very welcome.
Feel free to [open an issue](https://github.com/ThinkR-open/building-shiny-apps-workflow/issues), or to make a Pull Request if you spot a typo.
Feel free to [open an issue](https://github.com/ThinkR-open/engineering-shiny-book/issues), or to make a Pull Request if you spot a typo.


## Other resources {-}
Expand All @@ -247,7 +241,7 @@ You can also find more resources in the bibliography.
+ [Shiny in production: Principles, practices, and tools](https://resources.rstudio.com/rstudio-conf-2019/shiny-in-production-principles-practices-and-tools-joe-cheng)
+ [Shiny in Production](https://kellobri.github.io/shiny-prod-book/)

Feel free to [suggest a resource](https://github.com/ThinkR-open/building-shiny-apps-workflow/issues)!
Feel free to [suggest a resource](https://github.com/ThinkR-open/engineering-shiny-book/issues)!

## Acknowledgments {-}

Expand Down
2 changes: 1 addition & 1 deletion prep.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To do locally on Colin's computer, thanks
options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/latest"))
renv::restore()
remotes::install_local(Ncpus = 4, upgrade = "never", force = TRUE)
# remotes::install_local(Ncpus = 4, upgrade = "never", force = TRUE)
if (!file.exists("packages.bib")){
knitr::write_bib(c(
desc::desc_get_deps()$package
Expand Down
Loading

0 comments on commit 8871d38

Please sign in to comment.