Skip to content

Commit

Permalink
copy animint.js etc to out.dir before, to avoid incomplete/error
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhock committed Nov 16, 2023
1 parent 8ae4a19 commit 32c5035
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions R/z_animint.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,25 @@ animint2dir <- function(plot.list, out.dir = NULL,
meta$selector.types <- plot.list$selector.types
dir.create(out.dir,showWarnings=FALSE)
meta$out.dir <- out.dir
## First, copy html/js/json files to out.dir.
src.dir <- system.file("htmljs",package="animint2")
to.copy <- Sys.glob(file.path(src.dir, "*"))
if(file.exists(paste0(out.dir, "styles.css")) | css.file != "default.file"){
to.copy <- to.copy[!grepl("styles.css", to.copy, fixed=TRUE)]
}
if(css.file!=""){
# if css filename is provided, copy that file to the out directory as "styles.css"
to.copy <- to.copy[!grepl("styles.css", to.copy, fixed=TRUE)]
if(!file.exists(css.file)){
stop(paste("css.file", css.file, "does not exist. Please check that the file name and path are specified correctly."))
} else {
file.copy(css.file, file.path(out.dir, "styles.css"), overwrite=TRUE)
}
} else {
style.file <- system.file("htmljs", "styles.css", package = "animint2")
file.copy(style.file, file.path(out.dir, "styles.css"), overwrite=TRUE)
}
file.copy(to.copy, out.dir, overwrite=TRUE, recursive=TRUE)

## Store the animation information (time, var, ms) in a separate list
AnimationInfo <- list()
Expand Down Expand Up @@ -620,25 +639,6 @@ animint2dir <- function(plot.list, out.dir = NULL,
meta$plots <- AllPlotsInfo
meta$time <- AnimationInfo$time
meta$timeValues <- AnimationInfo$timeValues
## Finally, copy html/js/json files to out.dir.
src.dir <- system.file("htmljs",package="animint2")
to.copy <- Sys.glob(file.path(src.dir, "*"))
if(file.exists(paste0(out.dir, "styles.css")) | css.file != "default.file"){
to.copy <- to.copy[!grepl("styles.css", to.copy, fixed=TRUE)]
}
if(css.file!=""){
# if css filename is provided, copy that file to the out directory as "styles.css"
to.copy <- to.copy[!grepl("styles.css", to.copy, fixed=TRUE)]
if(!file.exists(css.file)){
stop(paste("css.file", css.file, "does not exist. Please check that the file name and path are specified correctly."))
} else {
file.copy(css.file, file.path(out.dir, "styles.css"), overwrite=TRUE)
}
} else {
style.file <- system.file("htmljs", "styles.css", package = "animint2")
file.copy(style.file, file.path(out.dir, "styles.css"), overwrite=TRUE)
}
file.copy(to.copy, out.dir, overwrite=TRUE, recursive=TRUE)
export.names <- c(
"geoms", "time", "duration", "selectors", "plots", "title", "source")
export.data <- list()
Expand Down

0 comments on commit 32c5035

Please sign in to comment.