Skip to content

Commit

Permalink
Add history section and article for previous versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cicdguy committed Nov 9, 2023
1 parent cff98e2 commit ad61a8f
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ concurrency:

env:
R_VERSION: "4.1"

jobs:
get_r_version:
name: Get R version
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
# Whether to skip multiversion docs
# Note that if you have multiple versions of docs,
# your URL links are likely to break due to path changes
skip-multiversion-docs: false
skip-multiversion-docs: true
linter:
name: Lint
uses: pharmaverse/admiralci/.github/workflows/lintr.yml@main
Expand Down
12 changes: 10 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ repo:
source: https://github.com/pharmaverse/admiralophtha/blob/main/
issue: https://github.com/pharmaverse/admiralophtha/issues/
user: https://github.com/

development:
mode: auto

news:
cran_dates: false
reference:
Expand Down Expand Up @@ -90,8 +94,8 @@ reference:

navbar:
structure:
left: [getstarted, reference, articles, news]
right: [search, slack, newissue, github]
left: [getstarted, reference, articles, news, versions]
right: [search, slack, history, newissue, github]
components:
getstarted:
text: Get Started
Expand All @@ -110,6 +114,10 @@ navbar:
href: articles/adbcva.html
- text: Creating ADVFQ
href: articles/advfq.html
history:
icon: fa-history
href: articles/website-versions.html
aria-label: Previous Release Websites
slack:
icon: fa-slack
href: https://app.slack.com/client/T028PB489D3/C02M8KN8269
Expand Down
82 changes: 82 additions & 0 deletions vignettes/articles/website-versions.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: "Previous Versions of Website"
---

```{r, include = FALSE}
# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE
# Config/Needs/website: gert
# Make sure to copy the gh-pages branch to your local git
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 <- tryCatch(gert::git_ls(ref = "gh-pages"), error = function(x) FALSE)
# if a local user (not on CI) does not have a copy of the `gh-pages` branch, exit silently
if (!isTRUE(as.logical(Sys.getenv("CI"))) && isFALSE(df_all_files)) {
knitr::knit_exit()
}
```

```{r include=FALSE}
# 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]+|dev", x = all_folders)] |>
rev()
# more dev first if it appears
if ("dev" %in% all_version_folders) {
all_version_folders <- c("dev", all_version_folders) |> unique()
}
# 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), ]
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,
FUN = function(x) {
x_label <- ifelse(x %in% "dev", "Development Site", x)
paste0("[", x_label, lst_tag_dates[[x]], "](", paste0(base_url, x), ")")
}
) |>
unlist() |>
paste(collapse = "\n\n")
```

`r str_website_links`

0 comments on commit ad61a8f

Please sign in to comment.