-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.qmd
100 lines (69 loc) · 4.65 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
format: gfm
---
<!-- README.md is generated from README.qmd. Please edit that file -->
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.retina = 3
)
withr::with_dir(here::here(), {
targets::tar_load(workflow_graph)
})
```
# Comparative Public Administration <a href='https://compasp23.classes.andrewheiss.com/'><img src='files/favicon-512.png' align="right" height="139" /></a>
[PMAP 8441 • Spring 2023](https://compasp23.classes.andrewheiss.com/)
[Andrew Heiss](https://www.andrewheiss.com/) • Andrew Young School of Policy Studies • Georgia State University
---
**[Quarto](https://quarto.org/) + [{targets}](https://docs.ropensci.org/targets/) + [{renv}](https://rstudio.github.io/renv/) = magic! `r emoji::emoji("magic")`**
---
## How to build the site
1. Install [RStudio](https://www.rstudio.com/products/rstudio/download/#download) version 2022.07.1 or later since it has a [Quarto](https://quarto.org/) installation embedded in it. Otherwise, download and install [Quarto](https://quarto.org/) separately.
2. Open `compasp23.Rproj` to open an [RStudio Project](https://r4ds.had.co.nz/workflow-projects.html).
3. If it's not installed already, R *should* try to install the [{renv} package](https://rstudio.github.io/renv/) when you open the RStudio Project for the first time. If you don't see a message about package installation, install it yourself by running `install.packages("renv")` in the R console.
4. Run `renv::restore()` in the R console to install all the required packages for this project.
5. Run `targets::tar_make()` in the R console to build everything.
6. `r emoji::emoji("tada")` All done! `r emoji::emoji("tada")` The complete website will be in a folder named `_site/`.
## {targets} pipeline
I use the [{targets} package](https://docs.ropensci.org/targets/) to build this site and all its supporting files. The complete pipeline is defined in [`_targets.R`](_targets.R) and can be run in the R console with:
```{r eval=FALSE}
targets::tar_make()
```
The pipeline does several major tasks:
- **Build Quarto website**: This project is a [Quarto website](https://quarto.org/docs/websites/), which compiles and stitches together all the `.qmd` files in this project based on the settings in [`_quarto.yml`](_quarto.yml). See the [Quarto website documentation](https://quarto.org/docs/websites/) for more details.
- **Upload resulting `_site/` folder to my remote server**: Quarto places the compiled website in a folder named `/_site/`. The pipeline uses `rsync` to upload this folder to my personal remote server. This target will only run if the `UPLOAD_WEBSITES` environment variable is set to `TRUE`, and it will only work if you have an SSH key set up on my personal server, which only I do.
The complete pipeline looks like this:
<small>(This uses [`mermaid.js` syntax](https://mermaid-js.github.io/mermaid/) and should display as a graph on GitHub. You can also view it by pasting the code into <https://mermaid.live>.)</small>
```{r echo=FALSE, results="asis"}
# Make sure there are newlines between the code block boundaries and the output
# from `workflow`, which also needs to be separated by newlines
cat("``` mermaid\n")
cat(workflow_graph, sep = "\n")
cat("\n```")
```
## Fonts and colors
The font used throughout the site is [Public Sans](https://public-sans.digital.gov/), an open source font developed as part of the General Services Administration's [USWDS](https://designsystem.digital.gov/) (US Web Design System) for making accessible federal government websites.
The colors for the site and hex logo come from the [Tam palette](https://github.com/BlakeRMills/MetBrewer#tam) in [MetBrewer](https://github.com/BlakeRMills/MetBrewer) (`MetBrewer::met.brewer("Tam")`):
```{r show-tam, fig.width=8, fig.height=1, echo=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
library(MetBrewer)
pal <- met.brewer("Tam")
tibble(x = 1:length(pal),
color = pal) %>%
mutate(x_nice = glue::glue("[{x}]")) %>%
mutate(across(c(color, x_nice), ~fct_inorder(.))) %>%
ggplot(aes(x = color, y = 1, fill = color)) +
geom_tile() +
scale_x_discrete(expand = c(0, 0)) +
scale_fill_identity() +
facet_wrap(vars(x_nice), scales = "free_x", nrow = 1) +
theme_void(base_family = "Inconsolata") +
theme(panel.spacing.x = unit(-1, units = "pt"),
panel.spacing.y = unit(-0.5, units = "lines"),
strip.text = element_blank()) +
theme(axis.text.x = element_text(margin = margin(b = 5)))
```
## Licenses
**Text and figures:** All prose and images are licensed under Creative Commons ([CC-BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/))
**Code:** All code is licensed under the [MIT License](LICENSE.md).