Skip to content

Commit 9f53e24

Browse files
authored
Merge pull request #174 from cmu-delphi/release
12/14 Release
2 parents edc994a + c03c81d commit 9f53e24

File tree

247 files changed

+20540
-17455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+20540
-17455
lines changed

.gitattributes

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# These settings are for any web project
2+
3+
# Handle line endings automatically for files detected as text
4+
# and leave all files detected as binary untouched.
5+
* text=auto eol=lf
6+
7+
#
8+
# The above will handle all files NOT found below
9+
#
10+
11+
#
12+
## These files are text and should be normalized (Convert crlf => lf)
13+
#
14+
15+
# source code
16+
*.php text
17+
*.css text
18+
*.sass text
19+
*.scss text
20+
*.less text
21+
*.styl text
22+
*.js text
23+
*.ts text
24+
*.coffee text
25+
*.json text
26+
*.htm text
27+
*.html text
28+
*.xml text
29+
*.txt text
30+
*.ini text
31+
*.inc text
32+
*.pl text
33+
*.rb text
34+
*.py text
35+
*.scm text
36+
*.sql text
37+
*.sh text eof=LF
38+
*.bat text
39+
*.R text
40+
41+
# templates
42+
*.hbt text
43+
*.jade text
44+
*.haml text
45+
*.hbs text
46+
*.dot text
47+
*.tmpl text
48+
*.phtml text
49+
50+
# server config
51+
.htaccess text
52+
53+
# git config
54+
.gitattributes text
55+
.gitignore text
56+
57+
# code analysis config
58+
.jshintrc text
59+
.jscsrc text
60+
.jshintignore text
61+
.csslintrc text
62+
63+
# misc config
64+
*.yaml text
65+
*.yml text
66+
*.editorconfig text
67+
*.toml text
68+
69+
# build config
70+
*.npmignore text
71+
*.bowerrc text
72+
*.prettierignore text
73+
Dockerfile text eof=LF
74+
75+
# Heroku
76+
Procfile text
77+
.slugignore text
78+
79+
# Documentation
80+
*.md text
81+
LICENSE text
82+
AUTHORS text
83+
84+
85+
#
86+
## These files are binary and should be left untouched
87+
#
88+
89+
# (binary is a macro for -text -diff)
90+
*.png binary
91+
*.jpg binary
92+
*.jpeg binary
93+
*.gif binary
94+
*.ico binary
95+
*.mov binary
96+
*.mp4 binary
97+
*.mp3 binary
98+
*.flv binary
99+
*.fla binary
100+
*.swf binary
101+
*.gz binary
102+
*.zip binary
103+
*.7z binary
104+
*.ttf binary
105+
*.pyc binary
106+
*.pdf binary
107+
108+
# Source files
109+
# ============
110+
*.pxd text
111+
*.py text
112+
*.py3 text
113+
*.pyw text
114+
*.pyx text
115+
*.sh text eol=lf
116+
*.json text
117+
118+
# Binary files
119+
# ============
120+
*.db binary
121+
*.p binary
122+
*.pkl binary
123+
*.pyc binary
124+
*.pyd binary
125+
*.pyo binary
126+
127+
# Note: .db, .p, and .pkl files are associated
128+
# with the python modules ``pickle``, ``dbm.*``,
129+
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
130+
# (among others).
131+
*.rda binary

.github/workflows/ci.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
on:
22
push:
33
paths: # run only when an Rmd file changes
4-
- '**.Rmd'
5-
- 'environment.yml'
6-
- '.github/workflows/ci.yaml'
4+
- "**.Rmd"
5+
- "environment.yml"
6+
- ".github/workflows/ci.yaml"
77

88
name: ci
99

@@ -17,7 +17,7 @@ jobs:
1717
fetch-depth: 3
1818
- name: Cache Conda
1919
uses: actions/cache@v1
20-
with:
20+
with:
2121
path: ~/conda_pkgs_dir
2222
key: ${{ runner.os }}-conda6-${{ hashFiles('environment.yml') }}
2323
restore-keys: |
@@ -50,20 +50,22 @@ jobs:
5050
restore-keys: |
5151
${{ runner.os }}-blogdown2-
5252
- name: Build site
53-
shell: bash -l {0}
53+
shell: bash -l {0}
5454
run: |
5555
npm run build:blog
56-
56+
5757
- uses: actions/setup-node@v1
5858
with:
59-
node-version: '12'
59+
node-version: "12"
6060
- uses: actions/cache@v2
6161
with:
6262
path: ~/.npm
6363
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
6464
restore-keys: |
6565
${{ runner.os }}-node-
6666
- run: npm ci
67+
- name: Lint
68+
run: npm run lint
6769
- name: Build
6870
run: npm run build
6971

.github/workflows/ci_fast.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
on:
22
push:
33
paths-ignore: # don't run the fast version when an Rmd file changes
4-
- '**.Rmd'
5-
- 'environment.yml'
6-
- '.github/workflows/ci.yaml'
4+
- "**.Rmd"
5+
- "environment.yml"
6+
- ".github/workflows/ci.yaml"
77

88
name: ci_fast
99

@@ -14,18 +14,20 @@ jobs:
1414
- uses: actions/checkout@v2
1515
with:
1616
# submodules: true # Fetch Hugo themes (true OR recursive)
17-
fetch-depth: 3 # Fetch all history for .GitInfo and .Lastmod
18-
17+
fetch-depth: 3 # Fetch all history for .GitInfo and .Lastmod
18+
1919
- uses: actions/setup-node@v1
2020
with:
21-
node-version: '12'
21+
node-version: "12"
2222
- uses: actions/cache@v2
2323
with:
2424
path: ~/.npm
2525
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
2626
restore-keys: |
2727
${{ runner.os }}-node-
2828
- run: npm ci
29+
- name: Lint
30+
run: npm run lint
2931
- name: Build
3032
run: npm run build
3133

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/public
22
/resources/_gen
33
*.exe
4-
/.vscode
54
/blogdown
65
/.Rhistory
76
*_cache

.prettierignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
*.toml
2+
*.jpg
3+
*.png
4+
*.rda
5+
*.rdx
6+
*.RData
7+
*.svg
8+
/blogdown
9+
/.htaccess
10+
/.Rhistory
11+
.gitignore
12+
.prettierignore
13+
/.gitattributes
14+
/LICENSE
15+
/package-lock.json
16+
/content/blog/**/*.html
17+
/static
18+
/public
19+
/Dockerfile
20+
/resources
21+
/assets
22+
*.woff
23+
*.ttf
24+
*.woff2
25+
*.R
26+
*.xml
27+
*.Rmd
28+
*.md
29+
*.jpeg
30+
*.ico

.prettierrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
printWidth: 120,
3+
semi: true,
4+
trailingComma: "es5",
5+
6+
overrides: [
7+
{
8+
files: ["*.html"],
9+
options: {
10+
parser: "go-template",
11+
},
12+
},
13+
],
14+
};

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode"]
3+
}

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.formatOnPaste": true,
4+
"editor.formatOnSaveMode": "modifications",
5+
"[scss]": {
6+
"files.trimTrailingWhitespace": true,
7+
"editor.formatOnSave": true,
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[js]": {
11+
"files.trimTrailingWhitespace": true,
12+
"editor.formatOnSave": true,
13+
"editor.defaultFormatter": "esbenp.prettier-vscode"
14+
},
15+
"[html]": {
16+
"files.trimTrailingWhitespace": true,
17+
"editor.formatOnSave": true,
18+
"editor.defaultFormatter": "esbenp.prettier-vscode"
19+
}
20+
}

README.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,54 @@
22

33
Delphi's homepage at https://cmu-delphi-main.netlify.app/
44

5-
This site is based on [Hugo](https://gohugo.io).
5+
This site is based on [Hugo](https://gohugo.io) and uses [Prettier](https://prettier.io) for formatting.
6+
7+
## Structure
8+
9+
The main content is in the `/content` directory written in Markdown or RMarkdown for blog posts.
10+
In addition to the Markdown content frontmatter with YAML syntax is used at the beginning of the file to customize and describe the content. Common fields include `title` and `description`.
11+
However, depending on the file it can have additional fields. For example for blog posts additional fields are used to list the authors, hero images, summaries, tags, and so on.
12+
13+
### Linking
14+
15+
Hugo uses so called shortcodes for embedding logic into Markdown files. A good example is linking to other pages.
16+
17+
A relative reference to another page can be created using the `relref` shortcode. The argument is the filename with an optional `#` anchor to jump to a specific section.
18+
19+
**Examples**
20+
21+
```
22+
national daily survey]({{< relref "surveys">}})
23+
[syndromic COVID-19 indicator based on doctor visits]({{< relref "2020-10-14-dv-signal" >}})
24+
[self-reported symptoms]({{< relref "2020-08-26-fb-survey#whats-in-the-survey" >}})
25+
```
26+
27+
Instead of a direct link to the API reference there is the `apiref` shortcode. The advantage is that it is easy to later change the API base URL without changing each appearance. The argument is the path segment to point to.
28+
29+
**Examples**
30+
31+
```
32+
[public API]({{< apiref "api/covidcast.html" >}})
33+
[Epidata API]({{< apiref "/" >}})
34+
```
35+
36+
In RMarkdown things are slightly more different since the R Markdown parser is used before Hugo takes over. Blogdown has a special function for handling shortcodes: `blogdown::shortcode_html`.
37+
38+
**Examples**
39+
40+
```
41+
[Facebook](`r blogdown::shortcode_html("ref", "2020-08-26-fb-survey")`)
42+
[previous exploratory investigations](`r blogdown::shortcode_html("ref", "2020-08-26-fb-survey#some-interesting-examples")`)
43+
[public API](`r blogdown::shortcode_html("apiref", "api/covidcast.html")`)
44+
45+
```
46+
47+
### Data
48+
49+
In addition, there in the `/data` directory there are the following listings in YAML syntax
50+
51+
- `authors.yaml` list of blog authors referenced in the `authors` field in blog posts. This list is used to generated the author information at the end of a blog post
52+
- `supporters.yaml` list of supporters/collaborators
653

754
## Development Environment
855

@@ -13,8 +60,9 @@ This site is based on [Hugo](https://gohugo.io).
1360

1461
#### Commands
1562

16-
1. run `npm start` to create a development Hugo server
17-
1. run `npm build` to build a minified build in `/public`
63+
1. run `npm start` to create a development Hugo server running at http://localhost:1313
64+
1. run `npm run format` to run prettier and format files
65+
1. run `npm run build` to build a minified build in `/public`
1866

1967
### Blog Editor
2068

@@ -38,10 +86,15 @@ In order to convert the Rmd files to HTML files for Hugo you also need to:
3886
- `local=TRUE` similar to `-D` to process draft files
3987
- `run_hugo=FALSE` to manually run hugo
4088
- `build_rmd=TRUE` force a (re)build of the Rmd pages
89+
1. Alternatively, run `npm run build:blog`
4190
1. Run Hugo server as usual
4291

43-
blogdown also has an integrated server `blogdown::serve_site()` which will render RMarkdown files on the fly and does a similar thing as `hugo server -D`
92+
blogdown also has an integrated server `blogdown::serve_site()` which will render RMarkdown files on the fly and does a similar thing as `hugo server -D`.
93+
A shortcut is available through `npm run start:blog`.
4494

4595
#### Adding a new blog post
4696

4797
In case you use new dependencies don't forget to either edit `environment.yml` or `dependencies.R`.
98+
A Github action should runs when Rmd files changes so it will verify that the blog post can be built.
99+
However, the converted HTML file along with all generated images are committed to the repository.
100+
This simplifies the deployment and ensures that we have a blog post even when the API or data changes.

_output.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
blogdown::html_page:
22
# force svglite device, since cairo is a mess
3-
dev: "svglite"
3+
dev: svglite

0 commit comments

Comments
 (0)