Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed Dec 18, 2024
1 parent 9319fbe commit 0f091a5
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 9 deletions.
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ Imports:
stringr,
webshot2,
xml2,
yaml
yaml,
getPass,
googledrive,
googlesheets4,
withr,
Suggests:
testthat (>= 3.0.0),
tibble,
Expand Down
17 changes: 17 additions & 0 deletions R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @importFrom utils menu installed.packages browseURL
#' @importFrom httr oauth_app oauth_endpoints oauth2.0_token
#' @importFrom stringr str_to_title
#' @importFrom utils browseURL
#' @export
#' @examples \dontrun{
#'
Expand Down Expand Up @@ -236,3 +237,19 @@ app_set_up <- function(app_name = "google") {
return(list(app = app, endpoint = endpoint_url))
}


find_scopes <- function(app_name) {
### Declare all the scopes
scopes <- list(
google = c(
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/presentations",
"https://www.googleapis.com/auth/presentations.readonly"
),
github = c("repo")
)

return(scopes[app_name])
}
14 changes: 11 additions & 3 deletions R/book_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,19 @@ course_to_book_txt <- function(path = ".",
#' @export
#'
qrmd_files <- function(path = ".") {
spec <- get_yaml_spec(file.path(path))

rmd_files <- spec$rmd_files
qmd_files <- grep(".qmd", unlist(spec$book$chapters), value = TRUE)
yaml <- list.files(path = path, pattern ="_bookdown.yml|_quarto.yml", full.names = TRUE)

spec <- yaml::read_yaml(yaml)

rmd_files <- qmd_files <- NULL

if (basename(yaml) == "_bookdown.yml") {
rmd_files <- spec$rmd_files
}
if (basename(yaml) == "_quarto.yml") {
qmd_files <- grep(".qmd", unlist(spec$book$chapters), value = TRUE)
}
if (length(rmd_files) > 0 && length(qmd_files) > 0) stop("Both qmd and rmd files are found. Not sure what format to expect")

# Make files whichever ones exist here
Expand Down
5 changes: 3 additions & 2 deletions R/github_handling.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,12 @@ get_repo_info <- function(repo_name,
#'
#' @export
#'
#' @examples
#' @examples \dontrun {
#'
#' authorize("github")
#' check_git_repo("jhudsl/OTTR_Template")
#'
#'
#'}
check_git_repo <- function(repo_name,
token = NULL,
silent = TRUE,
Expand Down
1 change: 1 addition & 0 deletions R/leanpub.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' Column names `url`, `chapt_title`, and `img_path` must be used.
#' If no chapter title column supplied, the basename of the url will be used,
#' If no image column supplied, default image used.
#' @param clean_up Should the previous docs and manuscript folder be cleaned up?
#' @param html_page The file path of the rendered index.html file
#' @param base_url The base url of where the chapters are published -- the url to provide to the iframe in Leanpub
#' e.g. https://jhudatascience.org/OTTR_Template/coursera
Expand Down
3 changes: 2 additions & 1 deletion R/render_without_toc.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' Create a version of the course that does not have a TOC and has quizzes in the Coursera yaml format.
#' This is only needed to be used on Bookdown courses. Quarto has a simple command for this.
#'
#' @param path path to the bookdown or quarto course repository, must have a `_bookdown.yml` or `_quarto.yml` file
#' @param output_dir A folder (existing or not) that the TOC-less Bookdown for Coursera files should be saved. By default is file.path("docs", "coursera")
#' @param output_yaml A output.yml file to be provided to bookdown. By default is "_output.yml"
#' @param convert_quizzes TRUE/FALSE whether or not to convert quizzes. Default is TRUE
Expand All @@ -18,7 +19,7 @@
#'
#' @importFrom utils download.file
#'
render_without_toc <- function(course_path = ".",
render_without_toc <- function(path = ".",
output_dir = file.path("docs", "no_toc"),
output_yaml = "_output.yml",
convert_quizzes = FALSE,
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ test_that("Example Test", {

# get_slide_id() Get Slide ID from URL

# get_yaml_spec() Load in yaml specifications from _bookdown.yml or _quarto.yml

# gs_id_from_slide() get_image_link_from_slide() get_image_from_slide() Google Slides Helper Functions

# gs_png_url() get_slide_page() gs_png_download() include_slide() Get Google Slide PNG URL
Expand Down

0 comments on commit 0f091a5

Please sign in to comment.