Skip to content

Instantly share code, notes, and snippets.

@pat-s
Created April 19, 2020 08:34
Show Gist options
  • Save pat-s/13da845e3c3e29c111b4fa91d4849b44 to your computer and use it in GitHub Desktop.
Save pat-s/13da845e3c3e29c111b4fa91d4849b44 to your computer and use it in GitHub Desktop.
browse_news <- function(package = NULL) {
# check for pkgdown url
field_url <- desc::desc_get_urls(file = system.file("DESCRIPTION", package = package))[1]
# check if a news site exists for the given url
has_pkgdown <- httr::status_code(httr::GET(paste0(field_url, "/news"))) == 200
if (has_pkgdown) {
view_url((paste0(field_url, "/news")))
return(invisible())
}
# check for plain NEWS file
url <- paste0(cran_home(package), "/NEWS")
if (httr::status_code(httr::GET(url)) == 404) {
# try HTML NEWS file as last option
url <- paste0(cran_home(package), "/news/news.html")
}
view_url(url)
}
# https://git.io/JfUn5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment