diff --git a/R/gs_png.R b/R/gs_png.R index dffa819..07d90b2 100644 --- a/R/gs_png.R +++ b/R/gs_png.R @@ -100,6 +100,14 @@ gs_png_download <- function(url, output_dir = ".", overwrite = TRUE) { include_slide <- function(url, output_dir = knitr::opts_chunk$get("fig.path"), overwrite = TRUE, ...) { + # Get speaker notes for ALL slides + all_speaker_notes <- get_object_id_notes(url) + + # Get slide speaker notes + slide_id <- get_slide_id(url) + slide_speaker_notes <- all_speaker_notes[all_speaker_notes$id == slide_id, "notes"] + + alt_text <<- slide_speaker_notes outfile <- gs_png_download(url, output_dir, overwrite = overwrite) knitr::include_graphics(outfile, ...) } diff --git a/R/notes_to_fig_alt.R b/R/notes_to_fig_alt.R index a1f31f7..348bb85 100644 --- a/R/notes_to_fig_alt.R +++ b/R/notes_to_fig_alt.R @@ -48,53 +48,6 @@ get_gs_pptx <- function(id) { pptx_file } - -# WIP: get_gs_slide_pptx() -get_gs_slide_pptx <- function(link) { - link <- as.character(link) - presentation_id <- get_presentation_id(link) - slide_id <- get_slide_id(link) - url <- export_url(presentation_id = presentation_id, slide_id = slide_id) - - pptx_file <- file.path(paste0(presentation_id, slide_id, ".pptx")) - - # Only download it if it isn't yet present - if (!file.exists(pptx_file)) { - result <- httr::GET(url, httr::write_disk(pptx_file)) - warn_them <- FALSE - fr_header <- result$headers$`x-frame-options` - if (!is.null(fr_header)) { - if (all(fr_header == "DENY")) { - warn_them <- TRUE - } - } - if (httr::status_code(result) >= 300) { - warn_them <- TRUE - } - # don't write something if not really a pptx - ctype <- result$headers$`content-type` - if (httr::status_code(result) >= 400 && - !is.null(ctype) && grepl("html", ctype)) { - file.remove(pptx_file) - } - if (grepl("ServiceLogin", result$url)) { - warn_them <- TRUE - } - if (warn_them) { - warning( - paste0( - "This presentation may not be available, ", - "did you turn link sharing on?" - ) - ) - } - } - pptx_file -} - - - - export_url <- function(presentation_id, slide_id = NULL, type = "pptx") { url = paste0( "https://docs.google.com/presentation/d/",