Skip to content

Commit

Permalink
Merge pull request #382 from lindsaycarr/landing-page-date
Browse files Browse the repository at this point in the history
Fixes what is on dev & brings Harvey/Irma back
  • Loading branch information
ldecicco-USGS authored Jun 14, 2018
2 parents 3af41ef + 9145996 commit 20bf560
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
7 changes: 4 additions & 3 deletions R/publish.R
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,13 @@ publish.header <- function(viz) {
#' @rdname publish
#' @export
publish.landing <- function(viz){

repos <- setdiff(getRepoNames(viz[['org']]), c('vizlab', 'D3Learners', 'viz-scratch')) # we know some aren't vizzies
viz_info <- lapply(setNames(nm=repos), function(repo) {
tryCatch(getVizInfo(repo, org=viz[['org']], viz[['dev']]),
error=function(e) message(paste0("in getVizInfo(", repo, "): ", e$message), appendLF=TRUE),
warning=function(w) if(grepl("\\. is not a real", w$message)) return() else warning(w))
error=function(e) message(paste0("in getVizInfo(", repo, "): ", e$message), appendLF=TRUE)
# warning=function(w) if(grepl("\\. is not a real", w$message)) return() else warning(w)
)
})
# rm null
viz_info <- viz_info[!sapply(viz_info, is.null)]
Expand Down
25 changes: 13 additions & 12 deletions R/publishLandingPage.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,24 @@ getVizInfo <- function(org, repo, dev){
viz.yaml <- yaml.load_file(url(viz.yaml_url))

has_publish_date <- !is.null(viz.yaml$info$`publish-date`)
if(!dev){
if(has_publish_date){
publish_date <- as.Date(viz.yaml$info$`publish-date`)
if(has_publish_date) {
publish_date <- as.Date(viz.yaml$info$`publish-date`)
if(!dev){
# for prod, verify that the publish date is today or already past
is_published <- publish_date <= Sys.Date()
if(!is_published){
return()
}
} else {
return()
# for dev, publish anything that actually has a date in the field
is_published <- TRUE
}
} else {
publish_date <- as.Date(viz.yaml$info$`publish-date`)
is_published <- TRUE
if(is.null(publish_date) | is.na(publish_date)){
publish_date <- Sys.Date()
}
is_published <- FALSE
}

if(!is_published){
# if it is not going to be published, jump out of this function
return()
}

viz_info <- viz.yaml$info

viz_url <- viz_info$url
Expand Down

0 comments on commit 20bf560

Please sign in to comment.