diff --git a/R/activate.R b/R/activate.R index 2f094b7..65a4a9a 100644 --- a/R/activate.R +++ b/R/activate.R @@ -17,8 +17,8 @@ #' near the end of the file, which tells RStudio to load \code{darkstudio.css}. #' #' daRkStudio creates a directory, "darkstudio", inside the \code{www} folder, -#' which is found at \code{/Applications/RStudio.app/Contents/Resources/www} on -#' macOS, and \code{C:\\Program Files\\RStudio\\www} on Windows. +#' which is found at \code{/Applications/RStudio.app/Contents/Resources/app/www} +#' on macOS, and \code{C:\\Program Files\\RStudio\\app|\www} on Windows. #' #' \code{activate()} will create a backup of \code{index.htm} at #' \code{www/darkstudio/index.htm.pre-ds}. \code{www/darkstudio} is also where @@ -35,11 +35,11 @@ #' activate() #' #' # macOS: -#' path_index <- "/Applications/RStudio.app/Contents/Resources/www/index.htm" +#' path_index <- "/Applications/RStudio.app/Contents/Resources/app/www/index.htm" #' activate(path = path_index, backup = TRUE) #' #' # Windows: -#' path_index <- "C:/Program Files/RStudio/www/index.htm" +#' path_index <- "C:/Program Files/RStudio/app/www/index.htm" #' activate(path = path_index, backup = TRUE) #' } #' diff --git a/R/index.R b/R/index.R index 8e58e4f..44603fa 100644 --- a/R/index.R +++ b/R/index.R @@ -17,7 +17,7 @@ index <- list( Darwin = { paths <- list(system = "/Applications/RStudio.app/", user = "~/Applications/RStudio.app/", - index = "Contents/Resources/www/index.htm") + index = "Contents/Resources/app/www/index.htm") }, Windows = { paths <- list(system = "C:/Program Files/RStudio/", @@ -102,37 +102,14 @@ index <- list( modify = function(file = NULL, .ds_link = NULL) { + if (length(file) == 0) { stop("No index file was given to modify.") } - # Dirty workaround to make sure we add our link in before the closing - # tag - # The goal is to simply add in a handle and modify nothing else. - # For example, the index file (as of 2020-06-27) usually looks something - # like this near the end of the file: - # - # ... - # - # - # - # - # We want to change that to - # ... - # - # - # - # - # - for (line in seq_along(file)) { - line_current <- line - line_next <- line_current + 1 - - if (file[[line_current]] == "") { - # Create a new line, and copy the closing to that new line - file[[line_next]] <- file[[line_current]] - - # Add in the link - file[[line_current]] <- .ds_link + + for(i in (1:length(file))) { + if (grepl("", file[i])) { + file[i] <- paste0(.ds_link, "\n", file[i]) } } diff --git a/R/link.R b/R/link.R index 3a9fdb9..fe960e0 100644 --- a/R/link.R +++ b/R/link.R @@ -4,9 +4,9 @@ #' @keywords internal index_link <- function(href = NULL) { if (length(href) != 0) { - link <- paste0('') + link <- paste0(' ') } else { - link <- '' + link <- ' ' } return(link) }