From b5c9d523490b681da844de8547283a6dc1265d19 Mon Sep 17 00:00:00 2001 From: Ryan Sheridan Date: Sun, 25 Feb 2024 01:10:22 -0700 Subject: [PATCH] update link icons --- atlases/2021-carpentier-34618370/index.qmd | 2 +- atlases/2021-walsh-33843587/index.qmd | 2 +- atlases/2024-lucas-38194268/index.qmd | 2 +- funs.R | 47 ++++++++++++++++++---- investigators.qmd | 17 +++----- pre-build.R | 6 ++- projects.qmd | 12 ++++-- pubs.qmd | 3 +- theme.scss | 13 +++--- timeline.json | 2 +- 10 files changed, 71 insertions(+), 35 deletions(-) diff --git a/atlases/2021-carpentier-34618370/index.qmd b/atlases/2021-carpentier-34618370/index.qmd index 8774ab0..ab7dbcd 100644 --- a/atlases/2021-carpentier-34618370/index.qmd +++ b/atlases/2021-carpentier-34618370/index.qmd @@ -2,7 +2,7 @@ title: MARCO+ lymphatic endothelial cells sequester arthritogenic alphaviruses to limit viremia and viral dissemination image: /images/2021-carpentier-34618370.jpg -subtitle: '[Atlas](https://morrison-lnsc-browser.s3.amazonaws.com/index.html){.link-box-large}' +subtitle: '[ Atlas](https://morrison-lnsc-browser.s3.amazonaws.com/index.html){.link-box-large}' date: 'November 15, 2021' categories: [Project-1, Project-2, Core-C, Core-D, 2021] about: diff --git a/atlases/2021-walsh-33843587/index.qmd b/atlases/2021-walsh-33843587/index.qmd index 90201ec..781a045 100644 --- a/atlases/2021-walsh-33843587/index.qmd +++ b/atlases/2021-walsh-33843587/index.qmd @@ -2,7 +2,7 @@ title: Molecular tracking devices quantify antigen distribution and archiving in the murine lymph node image: /images/2021-walsh-33843587.jpg -subtitle: '[Atlas](https://d3898ys7yh3545.cloudfront.net/){.link-box-large}' +subtitle: '[ Atlas](https://d3898ys7yh3545.cloudfront.net/){.link-box-large}' date: 'April 12, 2021' categories: [Project-2, Core-C, Core-D, 2021] about: diff --git a/atlases/2024-lucas-38194268/index.qmd b/atlases/2024-lucas-38194268/index.qmd index f607a1d..df112a1 100644 --- a/atlases/2024-lucas-38194268/index.qmd +++ b/atlases/2024-lucas-38194268/index.qmd @@ -1,7 +1,7 @@ --- title: Chikungunya virus infection disrupts lymph node lymphatic endothelial cell composition and function via MARCO -subtitle: '[Atlas](https://morrison-lnsc-browser.s3.amazonaws.com/index.html){.link-box-large}' +subtitle: '[ Atlas](https://morrison-lnsc-browser.s3.amazonaws.com/index.html){.link-box-large}' date: 'January 09, 2024' categories: [Project-1, Project-2, Core-C, Core-D, 2024] about: diff --git a/funs.R b/funs.R index 50aa0f6..f0f2e4e 100644 --- a/funs.R +++ b/funs.R @@ -1,4 +1,4 @@ -#' Create links for a project +#' Create links for a project section #' #' links to atlases, publications, investigators .create_project_links <- function(proj_yml, athr_yml, pub_yml, lnk_cls) { @@ -34,7 +34,8 @@ if (any(pubs)) { lnks <- str_c( - lnks, " [Publications](pubs.qmd#category=", proj_lnk, ")", + lnks, " [ Publications]", + "(pubs.qmd#category=", proj_lnk, ")", lnk_cls ) } @@ -45,7 +46,8 @@ if (any(atlases)) { lnks <- str_c( - lnks, " [Atlases](atlases.qmd#category=", proj_lnk, ")", + lnks, " [ Atlases]", + "(atlases.qmd#category=", proj_lnk, ")", lnk_cls ) } @@ -60,17 +62,45 @@ #' #' links to the project page .create_project_link <- function(proj_title, lnk_name = proj_title, - lnk_cls = "{.link-bold}", max_len = 64) { + lnk_cls = "{.link-bold}", max_len = 40, + return_id = FALSE) { res <- proj_title %>% str_to_lower() %>% str_replace_all("( |, )", "-") %>% str_trunc(max_len, "right", ellipsis = "") %>% - str_remove("-$") %>% + str_remove("-$") + + if (return_id) return(res) + + res <- res %>% str_c("[", lnk_name, "](projects.qmd#", ., ")", lnk_cls) res } +#' Add icon to link +.icon_key <- list( + publications = "bi bi-file-earmark", + atlases = "bi bi-compass", + atlas = "bi bi-compass", + email = "bi bi-envelope", + website = "bi bi-house" + # website = "bi bi-globe" +) + +.add_link_icon <- function(lnk_text, icon_key = .icon_key) { + + icon <- .icon_key[[lnk_text]] + + if (!is.null(icon)) icon <- str_c(" ") + + res <- lnk_text %>% + str_to_title() %>% + str_c("[", icon, ., "]") + + res +} + #' Create publication page #' #' * Check publication information and scrape missing information from pubmed @@ -133,9 +163,10 @@ return(NULL) } - subttl <- links %>% - pluck("atlas") %>% - str_c("[Atlas](", ., "){.link-box-large}") + subttl <- links %>% # use double quotes single subtitle will be wrapped + pluck("atlas") %>% # in single quotes + str_c(.add_link_icon("atlas"), "(", ., "){.link-box-large}") %>% + str_replace_all("'", "\\\"") links <- links[names(links) != "atlas"] } diff --git a/investigators.qmd b/investigators.qmd index bac3cb0..fb91f86 100644 --- a/investigators.qmd +++ b/investigators.qmd @@ -1,6 +1,5 @@ --- title: "Investigators" -toc: true --- ```{r, echo = FALSE, include = FALSE} @@ -29,12 +28,13 @@ proj_lnks <- proj_yml %>% imap(~ .create_project_link(.x$title, str_to_title(.y), "{.link-box-fade}")) # Create page text +# unable to include table of contents and have the image inline with heading text <- athr_yml %>% imap(~ { lnks <- .x$links %>% # links to project pages - imap(~ str_c("[", str_to_title(.y), "](", .x, ")", lnk_cls)) %>% + imap(~ str_c(.add_link_icon(.y), "(", .x, ")", lnk_cls)) %>% str_c(collapse = " ") - + lnks <- proj_lnks[.x$project] %>% str_c(collapse = " ") %>% str_c(lnks, " ", .) @@ -45,8 +45,8 @@ text <- athr_yml %>% res <- str_c( "

", .y, sfx, "

\n\n", - lnks, "\n\n", - .x$bio, "\n\n" + lnks, "\n\n", + .x$bio, "\n\n" ) # Add image for each investigator @@ -58,12 +58,7 @@ text <- athr_yml %>% " \n" ) - html_foot <- "" - - res <- str_c( - html_head, res, - html_foot, "\n\n" - ) + res <- str_c(html_head, res, "\n\n") } res diff --git a/pre-build.R b/pre-build.R index 702a8df..bd7acaf 100644 --- a/pre-build.R +++ b/pre-build.R @@ -124,9 +124,13 @@ tl_dat <- tl_dat %>% mutate( pmid = str_remove(pmid, "/$"), pmid = str_c("PMID", pmid), - lab = str_c(proj, "\n", pmid), year = as.character(year(date)), url = file.path(pub_dir, key) + ) %>% + pivot_longer(c(proj, pmid), values_to = "lab") %>% + mutate( + style = ifelse(name == "pmid", "bold", "normal"), + style = map(style, ~ list(`font-weight` = .x)) ) # Save as json file diff --git a/projects.qmd b/projects.qmd index 2fe6d1b..86af2e7 100644 --- a/projects.qmd +++ b/projects.qmd @@ -6,7 +6,6 @@ toc: true library(yaml) library(tidyverse) library(here) - source(here("funs.R")) # Read yamls @@ -39,10 +38,15 @@ text <- proj_yml %>% # Conditional add hypothesis hyp <- .x$hypothesis - if (!is.null(hyp)) hyp <- str_c("*", hyp, "*\n\n") + if (!is.null(hyp)) hyp <- str_c("", hyp, "\n\n") + + # Set heading IDs + # need this since the first h2 heading ID after h1 gets mixed up during + # rendering + id <- .create_project_link(.x$title, return_id = TRUE) res <- str_c( - "

", .x$title, "

\n\n", + "

", .x$title, "

\n\n", links[[.y]], "\n\n", hyp ) @@ -65,7 +69,7 @@ text <- proj_yml %>% body <- str_c( "
\n", " \n", - body, "\n\n", + body, "\n", "
" ) } diff --git a/pubs.qmd b/pubs.qmd index 62b8bb2..caefdf2 100644 --- a/pubs.qmd +++ b/pubs.qmd @@ -39,7 +39,8 @@ file.copy("timeline.json", "_site") .mapping({ 'timestamp': 'year', 'text': 'lab', - 'url': 'url' + 'url': 'url', + 'textStyle': 'style' }) .parseTime('%Y') .aggregateBy('year') diff --git a/theme.scss b/theme.scss index 6d6c315..ed0959a 100644 --- a/theme.scss +++ b/theme.scss @@ -55,12 +55,12 @@ div.sidebar-item-container .active, div.sidebar-item-container .show>.nav-link, } .link-box-large { - display: inline-block; // Ensures the box wraps the content - text-decoration: none; // Removes the underline from the link + display: inline-block; // Ensures the box wraps the content + text-decoration: none; // Removes the underline from the link color: $link-color; border: 1px solid $link-color; - border-radius: 5px; // Rounded corners; adjust radius as needed - padding: 0px 8px; // Padding inside box around the text + border-radius: 7px; // Rounded corners; adjust radius as needed + padding: 0.125rem 0.25rem; // Padding inside box around the text margin: 1.5px; margin-top: 5px; margin-bottom: 5px; @@ -74,6 +74,7 @@ div.sidebar-item-container .active, div.sidebar-item-container .show>.nav-link, .link-box { @extend .link-box-large; font-size: 0.8rem; + border-radius: 0.25rem; } .link-box-fade { @@ -153,7 +154,7 @@ p.subtitle { // Timeline #timeline { - margin-right: 80px; + margin-right: 100px; margin-bottom: 50px; } @@ -180,5 +181,5 @@ p.subtitle { .milestones-label.milestones-link-label { @extend .link-bw; - font-size: 0.75rem !important; + font-size: 0.65rem !important; } diff --git a/timeline.json b/timeline.json index 485199a..a3036e5 100644 --- a/timeline.json +++ b/timeline.json @@ -1 +1 @@ -[{"key":"2021-walsh-33843587","date":"2021-01-01","proj":"Project-2, Core-C, Core-D","authors":"Sheridan, Hesselberth, Tamburini","pmid":"PMID33843587","lab":"Project-2, Core-C, Core-D\nPMID33843587","year":"2021","url":"pubs/2021-walsh-33843587"},{"key":"2017-kedl-29229919","date":"2017-01-01","proj":"Project-2","authors":"Tamburini","pmid":"PMID29229919","lab":"Project-2\nPMID29229919","year":"2017","url":"pubs/2017-kedl-29229919"},{"key":"2021-carpentier-34618370","date":"2021-01-01","proj":"Project-1, Project-2, Core-C, Core-D","authors":"Sheridan, Tamburini, Hesselberth, Morrison","pmid":"PMID34618370","lab":"Project-1, Project-2, Core-C, Core-D\nPMID34618370","year":"2021","url":"pubs/2021-carpentier-34618370"},{"key":"2022-doan-35505125","date":"2022-01-01","proj":"Project-2","authors":"Tamburini","pmid":"PMID35505125","lab":"Project-2\nPMID35505125","year":"2022","url":"pubs/2022-doan-35505125"},{"key":"2024-lucas-38194268","date":"2024-01-01","proj":"Project-1, Project-2, Core-C, Core-D","authors":"Sheridan, Hesselberth, Tamburini, Morrison","pmid":"PMID38194268","lab":"Project-1, Project-2, Core-C, Core-D\nPMID38194268","year":"2024","url":"pubs/2024-lucas-38194268"},{"key":"2018-mccarthy-29997290","date":"2018-01-01","proj":"Project-1, Project-2","authors":"Tamburini, Morrison","pmid":"PMID29997290","lab":"Project-1, Project-2\nPMID29997290","year":"2018","url":"pubs/2018-mccarthy-29997290"},{"key":"2018-lucas-30045970","date":"2018-01-01","proj":"Project-1, Project-2","authors":"Morrison, Tamburini","pmid":"PMID30045970","lab":"Project-1, Project-2\nPMID30045970","year":"2018","url":"pubs/2018-lucas-30045970"},{"key":"2019-tamburini-31156626","date":"2019-01-01","proj":"Project-2, Core-C, Core-D","authors":"Tamburini, Hesselberth","pmid":"PMID31156626","lab":"Project-2, Core-C, Core-D\nPMID31156626","year":"2019","url":"pubs/2019-tamburini-31156626"},{"key":"2020-lucas-33053342","date":"2020-01-01","proj":"Project-2, Core-B","authors":"Matsuda, Tamburini","pmid":"PMID33053342","lab":"Project-2, Core-B\nPMID33053342","year":"2020","url":"pubs/2020-lucas-33053342"},{"key":"2023-tamburini-37841845","date":"2023-01-01","proj":"Project-1, Project-2, Core-C, Core-D","authors":"Tamburini, Hesselberth, Morrison","pmid":"PMID37841845","lab":"Project-1, Project-2, Core-C, Core-D\nPMID37841845","year":"2023","url":"pubs/2023-tamburini-37841845"},{"key":"2024-kim-38307020","date":"2024-01-01","proj":"Project-1, Core-B","authors":"Morrison, Matsuda","pmid":"PMID38307020","lab":"Project-1, Core-B\nPMID38307020","year":"2024","url":"pubs/2024-kim-38307020"},{"key":"2014-tamburini-24905362","date":"2014-01-01","proj":"Project-2","authors":"Tamburini","pmid":"PMID24905362","lab":"Project-2\nPMID24905362","year":"2014","url":"pubs/2014-tamburini-24905362"}] +[{"key":"2021-walsh-33843587","date":"2021-01-01","authors":"Sheridan, Hesselberth, Tamburini","year":"2021","url":"pubs/2021-walsh-33843587","name":"proj","lab":"Project-2, Core-C, Core-D","style":{"font-weight":["normal"]}},{"key":"2021-walsh-33843587","date":"2021-01-01","authors":"Sheridan, Hesselberth, Tamburini","year":"2021","url":"pubs/2021-walsh-33843587","name":"pmid","lab":"PMID33843587","style":{"font-weight":["bold"]}},{"key":"2017-kedl-29229919","date":"2017-01-01","authors":"Tamburini","year":"2017","url":"pubs/2017-kedl-29229919","name":"proj","lab":"Project-2","style":{"font-weight":["normal"]}},{"key":"2017-kedl-29229919","date":"2017-01-01","authors":"Tamburini","year":"2017","url":"pubs/2017-kedl-29229919","name":"pmid","lab":"PMID29229919","style":{"font-weight":["bold"]}},{"key":"2021-carpentier-34618370","date":"2021-01-01","authors":"Sheridan, Tamburini, Hesselberth, Morrison","year":"2021","url":"pubs/2021-carpentier-34618370","name":"proj","lab":"Project-1, Project-2, Core-C, Core-D","style":{"font-weight":["normal"]}},{"key":"2021-carpentier-34618370","date":"2021-01-01","authors":"Sheridan, Tamburini, Hesselberth, Morrison","year":"2021","url":"pubs/2021-carpentier-34618370","name":"pmid","lab":"PMID34618370","style":{"font-weight":["bold"]}},{"key":"2022-doan-35505125","date":"2022-01-01","authors":"Tamburini","year":"2022","url":"pubs/2022-doan-35505125","name":"proj","lab":"Project-2","style":{"font-weight":["normal"]}},{"key":"2022-doan-35505125","date":"2022-01-01","authors":"Tamburini","year":"2022","url":"pubs/2022-doan-35505125","name":"pmid","lab":"PMID35505125","style":{"font-weight":["bold"]}},{"key":"2024-lucas-38194268","date":"2024-01-01","authors":"Sheridan, Hesselberth, Tamburini, Morrison","year":"2024","url":"pubs/2024-lucas-38194268","name":"proj","lab":"Project-1, Project-2, Core-C, Core-D","style":{"font-weight":["normal"]}},{"key":"2024-lucas-38194268","date":"2024-01-01","authors":"Sheridan, Hesselberth, Tamburini, Morrison","year":"2024","url":"pubs/2024-lucas-38194268","name":"pmid","lab":"PMID38194268","style":{"font-weight":["bold"]}},{"key":"2018-mccarthy-29997290","date":"2018-01-01","authors":"Tamburini, Morrison","year":"2018","url":"pubs/2018-mccarthy-29997290","name":"proj","lab":"Project-1, Project-2","style":{"font-weight":["normal"]}},{"key":"2018-mccarthy-29997290","date":"2018-01-01","authors":"Tamburini, Morrison","year":"2018","url":"pubs/2018-mccarthy-29997290","name":"pmid","lab":"PMID29997290","style":{"font-weight":["bold"]}},{"key":"2018-lucas-30045970","date":"2018-01-01","authors":"Morrison, Tamburini","year":"2018","url":"pubs/2018-lucas-30045970","name":"proj","lab":"Project-1, Project-2","style":{"font-weight":["normal"]}},{"key":"2018-lucas-30045970","date":"2018-01-01","authors":"Morrison, Tamburini","year":"2018","url":"pubs/2018-lucas-30045970","name":"pmid","lab":"PMID30045970","style":{"font-weight":["bold"]}},{"key":"2019-tamburini-31156626","date":"2019-01-01","authors":"Tamburini, Hesselberth","year":"2019","url":"pubs/2019-tamburini-31156626","name":"proj","lab":"Project-2, Core-C, Core-D","style":{"font-weight":["normal"]}},{"key":"2019-tamburini-31156626","date":"2019-01-01","authors":"Tamburini, Hesselberth","year":"2019","url":"pubs/2019-tamburini-31156626","name":"pmid","lab":"PMID31156626","style":{"font-weight":["bold"]}},{"key":"2020-lucas-33053342","date":"2020-01-01","authors":"Matsuda, Tamburini","year":"2020","url":"pubs/2020-lucas-33053342","name":"proj","lab":"Project-2, Core-B","style":{"font-weight":["normal"]}},{"key":"2020-lucas-33053342","date":"2020-01-01","authors":"Matsuda, Tamburini","year":"2020","url":"pubs/2020-lucas-33053342","name":"pmid","lab":"PMID33053342","style":{"font-weight":["bold"]}},{"key":"2023-tamburini-37841845","date":"2023-01-01","authors":"Tamburini, Hesselberth, Morrison","year":"2023","url":"pubs/2023-tamburini-37841845","name":"proj","lab":"Project-1, Project-2, Core-C, Core-D","style":{"font-weight":["normal"]}},{"key":"2023-tamburini-37841845","date":"2023-01-01","authors":"Tamburini, Hesselberth, Morrison","year":"2023","url":"pubs/2023-tamburini-37841845","name":"pmid","lab":"PMID37841845","style":{"font-weight":["bold"]}},{"key":"2024-kim-38307020","date":"2024-01-01","authors":"Morrison, Matsuda","year":"2024","url":"pubs/2024-kim-38307020","name":"proj","lab":"Project-1, Core-B","style":{"font-weight":["normal"]}},{"key":"2024-kim-38307020","date":"2024-01-01","authors":"Morrison, Matsuda","year":"2024","url":"pubs/2024-kim-38307020","name":"pmid","lab":"PMID38307020","style":{"font-weight":["bold"]}},{"key":"2014-tamburini-24905362","date":"2014-01-01","authors":"Tamburini","year":"2014","url":"pubs/2014-tamburini-24905362","name":"proj","lab":"Project-2","style":{"font-weight":["normal"]}},{"key":"2014-tamburini-24905362","date":"2014-01-01","authors":"Tamburini","year":"2014","url":"pubs/2014-tamburini-24905362","name":"pmid","lab":"PMID24905362","style":{"font-weight":["bold"]}}]