From a853e2f67b4bffeccd3cc9d185e6590d79669f28 Mon Sep 17 00:00:00 2001 From: bms63 Date: Wed, 30 Oct 2024 10:57:27 -0400 Subject: [PATCH] feat: #231 data blog init --- README.md | 3 +- .../zzz_DO_NOT_EDIT_data__packages/appendix.R | 73 +++++++++++++++++++ .../data__packages.qmd | 44 +++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 posts/zzz_DO_NOT_EDIT_data__packages/appendix.R create mode 100644 posts/zzz_DO_NOT_EDIT_data__packages/data__packages.qmd diff --git a/README.md b/README.md index e7739111..ed6f651c 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,8 @@ install.packages(c("jsonlite", "rtables", "teal", "riskmetric", - "tidyCDISC")) + "tidyCDISC", + "mirai")) ``` ## How to Use the `blog` Docker Image for Local Development diff --git a/posts/zzz_DO_NOT_EDIT_data__packages/appendix.R b/posts/zzz_DO_NOT_EDIT_data__packages/appendix.R new file mode 100644 index 00000000..c69926b0 --- /dev/null +++ b/posts/zzz_DO_NOT_EDIT_data__packages/appendix.R @@ -0,0 +1,73 @@ +suppressMessages(library(dplyr)) +# markdown helpers -------------------------------------------------------- + +markdown_appendix <- function(name, content) { + paste(paste("##", name, "{.appendix}"), " ", content, sep = "\n") +} +markdown_link <- function(text, path) { + paste0("[", text, "](", path, ")") +} + + + +# worker functions -------------------------------------------------------- + +insert_source <- function(repo_spec, name, + collection = "posts", + branch = "main", + host = "https://github.com", + text = "Source", + file_name) { + path <- paste( + host, + repo_spec, + "tree", + branch, + collection, + name, + file_name, + sep = "/" + ) + return(markdown_link(text, path)) +} + +insert_timestamp <- function(tzone = Sys.timezone()) { + time <- lubridate::now(tzone = tzone) + stamp <- as.character(time, tz = tzone, usetz = TRUE) + return(stamp) +} + +insert_lockfile <- function(repo_spec, name, + collection = "posts", + branch = "main", + host = "https://github.com", + text = "Session info") { + path <- path <- "https://pharmaverse.github.io/blog/session_info.html" + + return(markdown_link(text, path)) +} + + + +# top level function ------------------------------------------------------ + +insert_appendix <- function(repo_spec, name, collection = "posts", file_name) { + appendices <- paste( + markdown_appendix( + name = "Last updated", + content = insert_timestamp() + ), + " ", + markdown_appendix( + name = "Details", + content = paste( + insert_source(repo_spec, name, collection, file_name = file_name), + # get renv information, + insert_lockfile(repo_spec, name, collection), + sep = ", " + ) + ), + sep = "\n" + ) + knitr::asis_output(appendices) +} diff --git a/posts/zzz_DO_NOT_EDIT_data__packages/data__packages.qmd b/posts/zzz_DO_NOT_EDIT_data__packages/data__packages.qmd new file mode 100644 index 00000000..d6b95212 --- /dev/null +++ b/posts/zzz_DO_NOT_EDIT_data__packages/data__packages.qmd @@ -0,0 +1,44 @@ +--- +title: "Data Packages" +author: + - name: My Name +description: "" +# Note that the date below will be auto-updated when the post is merged. +date: "2024-10-30" +# Please do not use any non-default categories. +# You can find the default categories in the repository README.md +categories: [Metadata, SDTM, ADaM, TLG, Shiny, Community, Conferences, Submissions, Technical] +# Feel free to change the image +image: "pharmaverse.png" + +--- + + + +```{r setup, include=FALSE} +long_slug <- "zzz_DO_NOT_EDIT_data__packages" +# renv::use(lockfile = "renv.lock") +``` + + + +## pharmaversesdtm + +## pharmaverseadam + +## meddatasets + +https://www.linkedin.com/posts/alexander-krannich_meddatasets-ugcPost-7257309409335296000-NHri?utm_source=share&utm_medium=member_ios + + + + +```{r, echo=FALSE} +source("appendix.R") +insert_appendix( + repo_spec = "pharmaverse/blog", + name = long_slug, + # file_name should be the name of your file + file_name = list.files() %>% stringr::str_subset(".qmd") %>% first() +) +```