Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding article with links to old website versions #2190

Merged
merged 7 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
Loading