Skip to content

Commit

Permalink
Add cleanup and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy committed Dec 12, 2024
1 parent 3f7a1ff commit 29743e6
Show file tree
Hide file tree
Showing 18 changed files with 269 additions and 317 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(check_quizzes)
export(clean_up)
export(convert_coursera_quizzes)
export(convert_quiz)
export(course_path)
export(course_to_book_txt)
export(extract_meta)
export(extract_object_id)
Expand Down Expand Up @@ -42,7 +43,6 @@ export(pptx_notes)
export(pptx_slide_note_df)
export(pptx_slide_text_df)
export(render_without_toc)
export(set_up_leanpub)
export(setup_ottr_template)
export(unzip_pptx)
export(website_to_embed_leanpub)
Expand Down
1 change: 0 additions & 1 deletion R/auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ app_set_up <- function() {

return(list(app = app, endpoint = endpoint))
}

18 changes: 10 additions & 8 deletions R/get_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ setup_ottr_template <- function(dir = "inst/extdata", type) {
}
if (type == "quarto") {
quarto::quarto_render(output_dir,
metadata = list(sidebar = F, toc = F),
quarto_args = c('--output-dir', 'docs/no_toc/'),
as_job = FALSE)
metadata = list(sidebar = F, toc = F),
quarto_args = c("--output-dir", "docs/no_toc/"),
as_job = FALSE
)
}
return(output_dir)
}
Expand All @@ -65,11 +66,12 @@ setup_ottr_template <- function(dir = "inst/extdata", type) {
#' @return Looks for dangling zips and directories downloaded for testing and removes them
#' @export
clean_up <- function() {

dirs <- c("OTTR_Template-main",
"OTTR_Quarto-main",
"OTTR_Template_Website-main",
"OTTR_Quarto_Website-main")
dirs <- c(
"OTTR_Template-main",
"OTTR_Quarto-main",
"OTTR_Template_Website-main",
"OTTR_Quarto_Website-main"
)

zips <- paste0(dirs, ".zip")

Expand Down
6 changes: 2 additions & 4 deletions R/github_handling.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ check_git_repo <- function(repo_name,
# If git_pat is supplied, use it
test_repo <- report(
try(system(paste0("git ls-remote https://", git_pat, "@github.com/", repo_name),
intern = TRUE, ignore.stderr = TRUE
intern = TRUE, ignore.stderr = TRUE
))
)
} else {
# Try to git ls-remote the repo_name given
test_repo <- report
try(system(paste0("git ls-remote https://github.com/", repo_name),
intern = TRUE, ignore.stderr = TRUE
intern = TRUE, ignore.stderr = TRUE
))
}
# If 128 is returned as a status attribute it means it failed
Expand Down Expand Up @@ -244,12 +244,10 @@ get_git_auth <- function(git_pat = NULL, git_username = "PersonalAccessToken", q

# If git pat is not provided, try to get credentials with gitcreds
if (is.null(git_pat)) {

# Try getting credentials
auth_arg <- try(gitcreds::gitcreds_get(), silent = TRUE)

if (grepl("Could not find any credentials", auth_arg[1])) {

# Only if we're running this interactively
if (interactive()) {
# Set credentials if null
Expand Down
9 changes: 5 additions & 4 deletions R/google_slides.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ get_slide_page <- function(url) {
#' @param output_dir path to output png
#' @param overwrite should the slide PNG be overwritten?
gs_png_download <- function(url, output_dir = ".", overwrite = TRUE) {

id <- get_slide_id(url)
slide_id <- get_slide_page(url)
url <- gs_png_url(url)
Expand Down Expand Up @@ -185,7 +186,7 @@ get_image_from_slide <- function(file) {
is.Token <- function(token) {
inherits(token, "Token") ||
(inherits(token, "request") &&
inherits(token$auth_token, "Token"))
inherits(token$auth_token, "Token"))
}

png_url <- function(id, page_id) {
Expand All @@ -208,7 +209,7 @@ download_png_urls <- function(urls) {
ctype <- strsplit(ctype, " ")[[1]]
ctype <- sub(";$", "", ctype)
if (any(ctype == "text/html") &&
!any(grepl("png", ctype))) {
!any(grepl("png", ctype))) {
stop("Output is not a PNG!")
}
tfile
Expand All @@ -223,7 +224,7 @@ add_footer <- function(rmd_path, footer_text = NULL) {
}
footer_text <- paste0("\n", footer_text, collapse = "\n")
write(as.character(footer_text),
file = rmd_path,
append = TRUE
file = rmd_path,
append = TRUE
)
}
Loading

0 comments on commit 29743e6

Please sign in to comment.