|
| 1 | +--- |
| 2 | +title: "Projects" |
| 3 | +description: | |
| 4 | + Ongoing analysis projects from the group |
| 5 | +--- |
| 6 | + |
| 7 | +Ongoing analysis and research projects from the group. For completed work, see our [publications](pubs.qmd). For reusable tools, see our [software](software.qmd). |
| 8 | + |
| 9 | +```{r setup, include=FALSE} |
| 10 | +knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE) |
| 11 | +library(magrittr) |
| 12 | +
|
| 13 | +# Hide projects not updated in this many months (set to NULL to disable) |
| 14 | +stale_months <- 12 |
| 15 | +``` |
| 16 | + |
| 17 | +```{r load-team} |
| 18 | +# Load team members and create lookup by GitHub username |
| 19 | +team <- fs::dir_ls("_data/team", regexp = "\\w+\\-\\w+\\.yml") |> |
| 20 | + purrr::map(yaml::read_yaml) |
| 21 | +
|
| 22 | +team_by_github <- team %>% |
| 23 | + purrr::keep(~ !is.null(.x$github) && .x$github != "") %>% |
| 24 | + purrr::set_names(purrr::map_chr(., "github")) |
| 25 | +``` |
| 26 | + |
| 27 | +```{r, results='asis'} |
| 28 | +projects <- yaml::read_yaml("_data/projects.yml") |
| 29 | +
|
| 30 | +projects %>% |
| 31 | + purrr::map(function(p) { |
| 32 | + # Fetch repo info |
| 33 | + repo_info <- tryCatch( |
| 34 | + gh::gh("/repos/{repo}", repo = p$repo), |
| 35 | + error = function(e) list( |
| 36 | + name = basename(p$repo), |
| 37 | + description = "No description available", |
| 38 | + html_url = paste0("https://github.com/", p$repo), |
| 39 | + language = NA, |
| 40 | + stargazers_count = NA, |
| 41 | + pushed_at = NA |
| 42 | + ) |
| 43 | + ) |
| 44 | +
|
| 45 | + # Fetch contributors |
| 46 | + contributors <- tryCatch( |
| 47 | + gh::gh("/repos/{repo}/contributors", repo = p$repo, per_page = 100), |
| 48 | + error = function(e) list() |
| 49 | + ) |
| 50 | +
|
| 51 | + # Match contributors to team members |
| 52 | + team_contributors <- contributors %>% |
| 53 | + purrr::keep(~ .x$login %in% names(team_by_github)) %>% |
| 54 | + purrr::map(function(c) { |
| 55 | + tm <- team_by_github[[c$login]] |
| 56 | + list( |
| 57 | + name = tm$name, |
| 58 | + github = c$login, |
| 59 | + avatar_url = c$avatar_url, |
| 60 | + contributions = c$contributions |
| 61 | + ) |
| 62 | + }) |
| 63 | +
|
| 64 | + list( |
| 65 | + name = repo_info$name, |
| 66 | + description = p$description %||% repo_info$description %||% "No description available", |
| 67 | + url = p$url %||% repo_info$html_url, |
| 68 | + repo = p$repo, |
| 69 | + language = repo_info$language, |
| 70 | + stars = repo_info$stargazers_count %||% 0, |
| 71 | + updated = if (!is.null(repo_info$pushed_at)) substr(repo_info$pushed_at, 1, 10) else NA, |
| 72 | + team_contributors = team_contributors |
| 73 | + ) |
| 74 | + }) %>% |
| 75 | + # Filter out stale projects |
| 76 | +
|
| 77 | + purrr::keep(~ !is.null(.x)) %>% |
| 78 | + purrr::keep(~ { |
| 79 | + if (is.null(stale_months) || is.na(.x$updated)) return(TRUE) |
| 80 | + as.Date(.x$updated) > Sys.Date() - (stale_months * 30) |
| 81 | + }) %>% |
| 82 | + # Sort by stars descending |
| 83 | + { .[order(purrr::map_dbl(., "stars"), decreasing = TRUE)] } %>% |
| 84 | + purrr::map_chr(function(e) { |
| 85 | + # Format contributors section as raw markdown/HTML |
| 86 | + contributors_section <- "" |
| 87 | + if (length(e$team_contributors) > 0) { |
| 88 | + contributor_items <- purrr::map_chr(e$team_contributors, function(c) { |
| 89 | + sprintf( |
| 90 | + '<a href="https://github.com/%s" title="%s"><img src="%s" alt="%s" width="32" height="32"></a>', |
| 91 | + c$github, c$name, c$avatar_url, c$name |
| 92 | + ) |
| 93 | + }) |
| 94 | + contributors_section <- paste(contributor_items, collapse = " ") |
| 95 | + } |
| 96 | +
|
| 97 | + knitr::knit_expand( |
| 98 | + "_project-item.Rmd", |
| 99 | + name = e$name, |
| 100 | + description = stringr::str_squish(e$description), |
| 101 | + url = e$url, |
| 102 | + repo = e$repo, |
| 103 | + language = e$language %||% "", |
| 104 | + stars = e$stars %||% "", |
| 105 | + updated = e$updated %||% "", |
| 106 | + contributors_section = contributors_section |
| 107 | + ) |
| 108 | + }) %>% |
| 109 | + { knitr::knit_child(text = unlist(.), quiet = TRUE) } %>% |
| 110 | + cat(sep = "\n") |
| 111 | +``` |
0 commit comments