Skip to content

Commit

Permalink
Delete manuscript folder
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 7, 2024
1 parent 9712c19 commit fcfcc9c
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 45 deletions.
87 changes: 87 additions & 0 deletions make_screenshots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env Rscript
# Written by Candace Savonen Jan 2022

if (!('devtools' %in% installed.packages())) {
# install.packages("remotes", repos = "http://cran.us.r-project.org")
}

if (!('optparse' %in% installed.packages())) {
# install.packages("optparse", repos = "http://cran.us.r-project.org")
}

# Find .git root directory
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))


Sys.setenv("CHROMOTE_CHROME" = "/usr/bin/vivaldi")

library(optparse)
library(magrittr)

option_list <- list(
optparse::make_option(
c("--repo"),
type = "character",
default = NULL,
help = "GitHub repository name, e.g. jhudsl/OTTR_Template",
),
optparse::make_option(
c("--git_pat"),
type = "character",
default = NULL,
help = "GitHub personal access token",
),
optparse::make_option(
c("--output_dir"),
type = "character",
default = "resources/chapt_screen_images",
help = "Output directory where the chapter's screen images should be stored",
),
optparse::make_option(
c("--base_url"),
type = "character",
default = NULL,
help = "Output directory where the chapter's screen images should be stored",
)
)

# Read the arguments passed
opt_parser <- optparse::OptionParser(option_list = option_list)
opt <- optparse::parse_args(opt_parser)

output_folder <- file.path(opt$output_dir)
if (!dir.exists(output_folder)) {
dir.create(output_folder, recursive = TRUE)
}

if (is.null(opt$base_url)) {
base_url <- cow::get_pages_url(repo_name = opt$repo, git_pat = opt$git_pat)
base_url <- gsub("/$", "", base_url)
}

# Collect all the chapter pages for the url given
chapt_df <- ottrpal::get_chapters(html_page = file.path(root_dir, "docs", "index.html"),
base_url = base_url)

# Now take screenshots for each
file_names <- lapply(chapt_df$url, function(url) {
file_name <- gsub(".html", ".png", file.path(output_folder, basename(url)))

# Get rid of special characters because leanpub no like
file_name <- gsub(":|?|!|\\'", "", file_name)

# Take the screenshot
webshot2::webshot(url, file = file_name)

return(file_name)

})

# Save file of chapter urls and file_names
chapt_df <- chapt_df %>%
dplyr::mutate(img_path = unlist(file_names))

chapt_df %>%
readr::write_tsv(file.path(output_folder, "chapter_urls.tsv"))

message(paste("Image Chapter key written to: ", file.path(output_folder, "chapter_urls.tsv")))
7 changes: 0 additions & 7 deletions manuscript/1-Introduction.md

This file was deleted.

7 changes: 0 additions & 7 deletions manuscript/2-A-new-chapter.md

This file was deleted.

7 changes: 0 additions & 7 deletions manuscript/3-References.md

This file was deleted.

7 changes: 0 additions & 7 deletions manuscript/About-the-Authors.md

This file was deleted.

7 changes: 0 additions & 7 deletions manuscript/About-this-Course.md

This file was deleted.

5 changes: 0 additions & 5 deletions manuscript/Book.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file removed manuscript/resources/chapt_screen_images/index.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified resources/chapt_screen_images/a-new-chapter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/chapt_screen_images/about-the-authors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions resources/chapt_screen_images/chapter_urls.tsv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
url chapt_title img_path
https://jhudatascience.org/OTTR_Template/no_toc/index.html About this Course resources/chapt_screen_images/index.png
https://jhudatascience.org/OTTR_Template/no_toc/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png
https://jhudatascience.org/OTTR_Template/no_toc/a-new-chapter.html 2 A new chapter resources/chapt_screen_images/a-new-chapter.png
https://jhudatascience.org/OTTR_Template/no_toc/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png
https://jhudatascience.org/OTTR_Template/no_toc/references.html 3 References resources/chapt_screen_images/references.png
https://jhudatascience.org/OTTR_Template/index.html About this Course resources/chapt_screen_images/index.png
https://jhudatascience.org/OTTR_Template/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png
https://jhudatascience.org/OTTR_Template/a-new-chapter.html 2 A new chapter resources/chapt_screen_images/a-new-chapter.png
https://jhudatascience.org/OTTR_Template/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png
https://jhudatascience.org/OTTR_Template/references.html 3 References resources/chapt_screen_images/references.png
Binary file modified resources/chapt_screen_images/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/chapt_screen_images/introduction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/chapt_screen_images/references.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fcfcc9c

Please sign in to comment.