Skip to content

Commit 67a6110

Browse files
committed
update module repository following example of SLU preprint and hope it doesnt break!
1 parent 8ade5c2 commit 67a6110

File tree

22 files changed

+503
-13
lines changed

22 files changed

+503
-13
lines changed

_img/default_thumbnail.png

872 KB
Loading

_quarto.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,41 @@ project:
22
type: website
33
render:
44
- "index.qmd"
5-
- "*/*/index.qmd"
5+
- "*/index.qmd" # new sport pages
6+
- "*/*/index.qmd" # module pages
67
- "preprints.qmd"
78
- "by-statsds-topic.qmd"
9+
10+
metadata-files:
11+
- sidebar-sports.yml
812

913
website:
1014
title: "SCORE Module Repository"
11-
page-footer: "Maintained by [Ron Yurko](https://www.stat.cmu.edu/~ryurko/)"
12-
cookie-consent: true
1315
google-analytics: "G-D8W3NNYGGP"
16+
cookie-consent:
17+
type: implied
18+
prefs-text: "Manage cookies"
19+
page-footer:
20+
center:
21+
Maintained by [Ron Yurko](https://www.stat.cmu.edu/~ryurko/)
22+
23+
We use cookies to track usage statistics
24+
to help measure impact of the materials
25+
for authors. Please consider allowing
26+
tracking cookies.
1427
navbar:
1528
left:
1629
- href: index.qmd
1730
text: Home
18-
- by-statsds-topic.qmd
31+
# - by-statsds-topic.qmd
1932
- preprints.qmd
2033
- href: https://data.scorenetwork.org/
2134
text: Data Repository
2235
- href: https://scorenetwork.org/index.html
2336
text: SCORE Network
2437
right:
25-
- icon: twitter
26-
href: https://twitter.com/scorenetworkorg
38+
# - icon: twitter
39+
# href: https://twitter.com/scorenetworkorg
2740
- icon: linkedin
2841
href: https://www.linkedin.com/company/scorenetworkorg/
2942
sidebar:
@@ -35,7 +48,7 @@ website:
3548
format:
3649
html:
3750
theme:
38-
- cosmo
51+
- flatly
3952
- score.scss
4053
toc: true
4154

baseball/index.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Baseball"
3+
listing:
4+
contents:
5+
- "./*/index.qmd"
6+
sort: date desc
7+
image-placeholder: "../_img/default_thumbnail.png"
8+
fields: [image, title, author, date, categories, description]
9+
---
10+
11+
These modules use **baseball** data to teach topics in statistics and data science.

build_sidebar_yaml.R

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library(fs)
2+
library(stringr)
3+
library(glue)
4+
5+
# Step 1: Find top-level directories (sports)
6+
top_dirs <- dir_ls(path = ".", type = "directory", recurse = FALSE)
7+
8+
# Step 2: Filter out undesired folders (e.g., system folders, early drafts, .git, etc.)
9+
valid_sports <- top_dirs[
10+
!str_detect(top_dirs, regex("(^|/)early[_\\-\\s]?drafts(/|$)", ignore_case = TRUE)) &
11+
!basename(top_dirs) %in% c("_freeze","docs", ".git", ".quarto", "_site", "_extensions", "sports")
12+
]
13+
14+
# Step 3: Extract folder names and sort
15+
sport_names <- sort(basename(valid_sports))
16+
17+
# Step 4: Build YAML block
18+
yaml_lines <- c("sidebar:",
19+
' - section: "By Sport"',
20+
' contents:')
21+
22+
for (sport in sport_names) {
23+
# text_label <- str_to_title(str_replace_all(sport, "-", " "))
24+
text_label <- str_to_title(str_replace_all(sport, "[-_]", " "))
25+
href_path <- glue("{sport}/index.html")
26+
yaml_lines <- c(yaml_lines, glue(' - text: "{text_label}"'),
27+
glue(' href: {href_path}'))
28+
}
29+
30+
# Step 5: Write to sidebar-sports.yml
31+
writeLines(yaml_lines, "sidebar-sports.yml")
32+
cat("✓ sidebar-sports.yml created\n")

build_sport_pages.R

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# build_sport_pages.R
2+
3+
library(fs)
4+
library(stringr)
5+
library(glue)
6+
7+
# make pretty titles
8+
title_case_smart <- function(x) {
9+
words <- str_split(str_replace_all(x, "[-_]", " "), " ")[[1]]
10+
small_words <- c("and", "or", "of", "the", "in", "with", "for", "a", "an")
11+
words <- ifelse(tolower(words) %in% small_words, tolower(words), str_to_title(words))
12+
words[1] <- str_to_title(words[1]) # Always capitalize the first word
13+
paste(words, collapse = " ")
14+
}
15+
16+
# Step 1: Find all index.qmd files in subfolders like Sport/Module/index.qmd
17+
module_files <- dir_ls(path = ".", recurse = TRUE, glob = "*/*/index.qmd")
18+
module_files <- module_files[!str_detect(
19+
module_files,
20+
regex("(^|/)early[_\\-\\s]?drafts(/|$)", ignore_case = TRUE)
21+
)]
22+
23+
# Step 2: Extract the sport name from the top-level folder
24+
file_df <- data.frame(
25+
file = module_files,
26+
# sport = str_match(module_files, "^.*/(.*?)/.*/index\\.qmd$")[,2],
27+
sport = str_match(module_files, "^([^/]+)/[^/]+/index\\.qmd$")[,2],
28+
stringsAsFactors = FALSE
29+
)
30+
31+
# Step 3: Keep only valid entries
32+
file_df <- file_df[!is.na(file_df$sport), ]
33+
34+
35+
# Step 4: Generate one index.qmd file inside each sport folder
36+
for (sport in unique(file_df$sport)) {
37+
file_path <- glue("{sport}/index.qmd")
38+
39+
pretty_title <- title_case_smart(sport)
40+
41+
page_content <- glue(
42+
'---
43+
title: "{pretty_title}"
44+
listing:
45+
contents:
46+
- "./*/index.qmd"
47+
sort: date desc
48+
image-placeholder: "../_img/default_thumbnail.png"
49+
fields: [image, title, author, date, categories, description]
50+
---
51+
52+
These modules use **{sport}** data to teach topics in statistics and data science.
53+
'
54+
)
55+
56+
writeLines(page_content, file_path)
57+
cat(glue("✓ Created {file_path}\n"))
58+
}

by-statsds-topic.qmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
2-
title: Modules By Topic
2+
title: "📊 Modules by Statistics and Data Science Topic"
33
listing:
44
categories: true
5+
sort: "date desc"
6+
image-placeholder: "_img/default_thumbnail.png"
57
contents:
6-
- "*/*.qmd"
8+
- "*/*/index.qmd"
9+
fields: [image, title, author, date, categories, description]
710
---

esports/index.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Esports"
3+
listing:
4+
contents:
5+
- "./*/index.qmd"
6+
sort: date desc
7+
image-placeholder: "../_img/default_thumbnail.png"
8+
fields: [image, title, author, date, categories, description]
9+
---
10+
11+
These modules use **esports** data to teach topics in statistics and data science.

football/index.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Football"
3+
listing:
4+
contents:
5+
- "./*/index.qmd"
6+
sort: date desc
7+
image-placeholder: "../_img/default_thumbnail.png"
8+
fields: [image, title, author, date, categories, description]
9+
---
10+
11+
These modules use **football** data to teach topics in statistics and data science.

games/index.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Games"
3+
listing:
4+
contents:
5+
- "./*/index.qmd"
6+
sort: date desc
7+
image-placeholder: "../_img/default_thumbnail.png"
8+
fields: [image, title, author, date, categories, description]
9+
---
10+
11+
These modules use **games** data to teach topics in statistics and data science.

hockey/index.qmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Hockey"
3+
listing:
4+
contents:
5+
- "./*/index.qmd"
6+
sort: date desc
7+
image-placeholder: "../_img/default_thumbnail.png"
8+
fields: [image, title, author, date, categories, description]
9+
---
10+
11+
These modules use **hockey** data to teach topics in statistics and data science.

0 commit comments

Comments
 (0)