Skip to content

Commit

Permalink
set publication date when uploading a bookdown to Zenodo
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed May 28, 2024
1 parent 01e1ee2 commit d5e05ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/citation_bookdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ citation_bookdown <- function(meta) {
ifelse(has_name(yaml, "subtitle"), paste0(". ", yaml$subtitle, "."), ".")
)
cit_meta$meta$upload_type <- "publication"
if (has_name(yaml, "publication_date")) {
cit_meta$meta$publication_date <- string2date(yaml$publication_date) |>
format("%Y-%m-%d")
}
if (has_name(yaml, "embargo")) {
cit_meta$meta$embargo_date <- string2date(yaml$embargo) |>
format("%Y-%m-%d")
cit_meta$meta$access_right <- "embargoed"
if (!has_name(yaml, "publication_date")) {
cit_meta$meta$publication_date <- cit_meta$meta$embargo_date
}
} else {
cit_meta$meta$access_right <- "open"
}
Expand Down
3 changes: 3 additions & 0 deletions R/upload_zenodo.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ upload_zenodo <- function(path, token, sandbox = TRUE, logger = NULL) {
if (has_name(cit_meta, "version")) {
zen_rec$setVersion(cit_meta$version)
}
zen_rec$setPublicationDate(
first_non_null(cit_meta$publication_date, Sys.Date())
)

zen_rec <- zen_upload(zenodo, zen_rec, path)
return(invisible(zen_rec))
Expand Down

0 comments on commit d5e05ca

Please sign in to comment.