Skip to content

Commit

Permalink
Adding article with links to old website versions (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg authored Oct 30, 2023
1 parent ee3e5b1 commit 8e5ef2d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
^staged_dependencies.yaml$
^inst/dev_dependencies.R$
^\.devcontainer$
^vignettes/articles$
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ Suggests:
tibble
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/Needs/website: gert
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
68 changes: 68 additions & 0 deletions vignettes/articles/website-versions.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: "Previous Versions of Website"
---

```{r, include = FALSE}
# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE
# Config/Needs/website: gert
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup, include=FALSE}
base_url <-
"https://pharmaverse.github.io/admiral/" # include the trailing backslash!
# get list of all files in the `gh-pages` branch
df_all_files <- gert::git_ls(ref = "gh-pages")
# extract all folders in the root of the branch
all_folders <-
sub("/.*", "", df_all_files$path)[grepl(
x = df_all_files$path,
pattern = "/",
fixed = TRUE
)] |>
unique()
# subset to all version folders
all_version_folders <- all_folders[grep("^v[0-9]+", x = all_folders)]
# release dates of prior tags
df_tags <- gert::git_tag_list()
df_tags <- df_tags[df_tags$name %in% all_version_folders, ]
df_tags$date <-
lapply(
df_tags$commit,
FUN = function(x) {
tryCatch(
gert::git_commit_info(ref = x)$time |> as.Date() |> as.character(),
error = function(x) NA
)
}
) |>
unlist()
df_tags <- df_tags[!is.na(df_tags$date), ]
df_tags
lst_tag_dates <-
paste0(" (", df_tags$date, ")") |>
as.list() |>
setNames(df_tags$name)
# string with all markdown links
str_website_links <-
lapply(
X = all_version_folders |> rev(),
FUN = function(x) {
paste0("[", x, lst_tag_dates[[x]], "](", paste0(base_url, x), ")")
}
) |>
unlist() |>
paste(collapse = "\n\n")
```

`r str_website_links`

0 comments on commit 8e5ef2d

Please sign in to comment.