Created
April 19, 2020 08:34
-
-
Save pat-s/13da845e3c3e29c111b4fa91d4849b44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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