Skip to content

Commit

Permalink
Undo coursera.R changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed May 16, 2024
1 parent a8a0b81 commit f2cbcf0
Showing 1 changed file with 23 additions and 38 deletions.
61 changes: 23 additions & 38 deletions R/coursera.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,14 @@ convert_coursera_quizzes <- function(input_quiz_dir = "quizzes",
#' @importFrom utils download.file
#' @import bookdown_path
#'
# TODO: add a quarto/rmd argument here
render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
render_type = "rmd"
output_yaml = "_output.yml",
convert_quizzes = FALSE,
input_quiz_dir = "quizzes",
output_quiz_dir = "coursera_quizzes",
verbose = TRUE) {

# TODO: Look for a _quarto.yml OR a _bookdown.yml file for the root_dir
# TODO: declare in render_type whether this is an Rmd or quarto

# TODO: root directory will be where _quarto.yml OR a _bookdown.yml is found
root_dir <- list.file(pattern = "")
# Find root directory by finding `_bookdown.yml` file
root_dir <- bookdown_path()

# Output files:
output_dir <- file.path(root_dir, output_dir)
Expand All @@ -241,8 +235,20 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
}

###### Declare all the file paths relative to root directory ######
# Input files:
toc_close_css <- file.path(root_dir, "assets", "toc_close.css")

if (!file.exists(toc_close_css)) {
download.file("https://raw.githubusercontent.com/jhudsl/ottrpal/master/inst/extdata/toc_close.css",
destfile = toc_close_css
)
}
output_yaml_file <- file.path(root_dir, output_yaml)

# Make sure we have that file
if (!file.exists(toc_close_css)) {
stop(paste0("Could not find: ", toc_close_css))
}
# Make sure we know where the output yaml is
if (!file.exists(output_yaml_file)) {
stop(paste0("Could not find: ", output_yaml_file))
Expand Down Expand Up @@ -274,29 +280,15 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
fs::dir_copy(needed_dir, file.path(output_dir, needed_dir), overwrite = TRUE)
}
})

if (render_type == "rmd") {
# Input files:
toc_close_css <- file.path(root_dir, "assets", "toc_close.css")

if (!file.exists(toc_close_css)) {
download.file("https://raw.githubusercontent.com/jhudsl/ottrpal/master/inst/extdata/toc_close.css",
destfile = toc_close_css
)
}
# Make sure we have that file
if (!file.exists(toc_close_css)) {
stop(paste0("Could not find: ", toc_close_css))
}

# Slightly different path for the libs folder
libs_path <- file.path("docs", "libs")
if (!dir.exists(file.path(output_dir, "libs"))) {
if (verbose) {
message(file.path("docs", "libs"))
}
fs::dir_copy(libs_path, file.path(output_dir, "libs"), overwrite = TRUE)
}

# Slightly different path for the libs folder
libs_path <- file.path("docs", "libs")
if (!dir.exists(file.path(output_dir, "libs"))) {
if (verbose) {
message(file.path("docs", "libs"))
}
fs::dir_copy(libs_path, file.path(output_dir, "libs"), overwrite = TRUE)
}

###### Copy over CSS file ######
# Retrieve yaml file specs
Expand Down Expand Up @@ -347,13 +339,6 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),

# Write to "style.css"
writeLines(append(full_css, toc_close_css_lines), css_file)
}

if (render_type == "quarto") {

# TODO: Put code here about how to get rid of TOC

}

# Only convert the quizzes if set to TRUE
if (convert_quizzes) {
Expand Down

0 comments on commit f2cbcf0

Please sign in to comment.