Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions R/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
#' }
#'
Expand Down
35 changes: 6 additions & 29 deletions R/index.R
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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
# </html> tag
# The goal is to simply add in a <link> 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:
#
# ...
# </body>
#
# </html>
#
# We want to change that to
# ...
# </body>
#
# <link rel="stylesheet" href="darkstudio/darkstudio.css" type="text/css"/>
# </html>
#
for (line in seq_along(file)) {
line_current <- line
line_next <- line_current + 1

if (file[[line_current]] == "</html>") {
# Create a new line, and copy the closing </html> 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("</head>", file[i])) {
file[i] <- paste0(.ds_link, "\n", file[i])
}
}

Expand Down
4 changes: 2 additions & 2 deletions R/link.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#' @keywords internal
index_link <- function(href = NULL) {
if (length(href) != 0) {
link <- paste0('<link rel="stylesheet" href="', href,'" type="text/css"/>')
link <- paste0(' <link rel="stylesheet" href="', href,'" type="text/css"/>')
} else {
link <- '<link rel="stylesheet" href="darkstudio/darkstudio.css" type="text/css"/>'
link <- ' <link rel="stylesheet" href="darkstudio/darkstudio.css" type="text/css"/>'
}
return(link)
}