diff --git a/make_screenshots.R b/make_screenshots.R new file mode 100644 index 0000000..1555e48 --- /dev/null +++ b/make_screenshots.R @@ -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"))) diff --git a/manuscript/1-Introduction.md b/manuscript/1-Introduction.md deleted file mode 100644 index fc292bb..0000000 --- a/manuscript/1-Introduction.md +++ /dev/null @@ -1,7 +0,0 @@ -# 1 Introduction - -{type: iframe, title:1 Introduction, width:800, height:600, poster:resources/chapt_screen_images/introduction.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/introduction.html) - - - diff --git a/manuscript/2-Scientific-software-development-best-practices.md b/manuscript/2-Scientific-software-development-best-practices.md deleted file mode 100644 index b0af788..0000000 --- a/manuscript/2-Scientific-software-development-best-practices.md +++ /dev/null @@ -1,7 +0,0 @@ -# 2 Scientific software development best practices - -{type: iframe, title:2 Scientific software development best practices, width:800, height:600, poster:resources/chapt_screen_images/scientific-software-development-best-practices.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/scientific-software-development-best-practices.html) - - - diff --git a/manuscript/3-Why-Automation.md b/manuscript/3-Why-Automation.md deleted file mode 100644 index 3f92dac..0000000 --- a/manuscript/3-Why-Automation.md +++ /dev/null @@ -1,7 +0,0 @@ -# 3 Why Automation - -{type: iframe, title:3 Why Automation, width:800, height:600, poster:resources/chapt_screen_images/why-automation.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/why-automation.html) - - - diff --git a/manuscript/4-GitHub-Actions-Fundamentals.md b/manuscript/4-GitHub-Actions-Fundamentals.md deleted file mode 100644 index cf1d6a5..0000000 --- a/manuscript/4-GitHub-Actions-Fundamentals.md +++ /dev/null @@ -1,7 +0,0 @@ -# 4 GitHub Actions Fundamentals - -{type: iframe, title:4 GitHub Actions Fundamentals, width:800, height:600, poster:resources/chapt_screen_images/github-actions-fundamentals.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/github-actions-fundamentals.html) - - - diff --git a/manuscript/5-Automating-Re-running-Analyses.md b/manuscript/5-Automating-Re-running-Analyses.md deleted file mode 100644 index 1c0f147..0000000 --- a/manuscript/5-Automating-Re-running-Analyses.md +++ /dev/null @@ -1,7 +0,0 @@ -# 5 Automating Re-running Analyses - -{type: iframe, title:5 Automating Re-running Analyses, width:800, height:600, poster:resources/chapt_screen_images/automating-re-running-analyses.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/automating-re-running-analyses.html) - - - diff --git a/manuscript/6-GitHub-Action-Variables.md b/manuscript/6-GitHub-Action-Variables.md deleted file mode 100644 index 85de658..0000000 --- a/manuscript/6-GitHub-Action-Variables.md +++ /dev/null @@ -1,7 +0,0 @@ -# 6 GitHub Action Variables - -{type: iframe, title:6 GitHub Action Variables, width:800, height:600, poster:resources/chapt_screen_images/github-action-variables.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/github-action-variables.html) - - - diff --git a/manuscript/7-Troubleshooting-GitHub-Actions.md b/manuscript/7-Troubleshooting-GitHub-Actions.md deleted file mode 100644 index 79683d2..0000000 --- a/manuscript/7-Troubleshooting-GitHub-Actions.md +++ /dev/null @@ -1,7 +0,0 @@ -# 7 Troubleshooting GitHub Actions - -{type: iframe, title:7 Troubleshooting GitHub Actions, width:800, height:600, poster:resources/chapt_screen_images/troubleshooting-github-actions.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/troubleshooting-github-actions.html) - - - diff --git a/manuscript/8-Applying-GitHub-Actions-Examples.md b/manuscript/8-Applying-GitHub-Actions-Examples.md deleted file mode 100644 index 9fc809f..0000000 --- a/manuscript/8-Applying-GitHub-Actions-Examples.md +++ /dev/null @@ -1,7 +0,0 @@ -# 8 Applying GitHub Actions Examples - -{type: iframe, title:8 Applying GitHub Actions Examples, width:800, height:600, poster:resources/chapt_screen_images/applying-github-actions-examples.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/applying-github-actions-examples.html) - - - diff --git a/manuscript/9-References.md b/manuscript/9-References.md deleted file mode 100644 index 202e868..0000000 --- a/manuscript/9-References.md +++ /dev/null @@ -1,7 +0,0 @@ -# 9 References - -{type: iframe, title:9 References, width:800, height:600, poster:resources/chapt_screen_images/references.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/references.html) - - - diff --git a/manuscript/About-the-Authors.md b/manuscript/About-the-Authors.md deleted file mode 100644 index 82890d4..0000000 --- a/manuscript/About-the-Authors.md +++ /dev/null @@ -1,7 +0,0 @@ -# About the Authors - -{type: iframe, title:About the Authors, width:800, height:600, poster:resources/chapt_screen_images/about-the-authors.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/about-the-authors.html) - - - diff --git a/manuscript/About-this-Course.md b/manuscript/About-this-Course.md deleted file mode 100644 index e95e63d..0000000 --- a/manuscript/About-this-Course.md +++ /dev/null @@ -1,7 +0,0 @@ -# About this Course - -{type: iframe, title:About this Course, width:800, height:600, poster:resources/chapt_screen_images/index.png} -![](https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/index.html) - - - diff --git a/manuscript/Book.txt b/manuscript/Book.txt deleted file mode 100644 index ac93bab..0000000 --- a/manuscript/Book.txt +++ /dev/null @@ -1,11 +0,0 @@ -1-Introduction.md -2-Scientific-software-development-best-practices.md -3-Why-Automation.md -4-GitHub-Actions-Fundamentals.md -5-Automating-Re-running-Analyses.md -6-GitHub-Action-Variables.md -7-Troubleshooting-GitHub-Actions.md -8-Applying-GitHub-Actions-Examples.md -9-References.md -About-this-Course.md -About-the-Authors.md diff --git a/manuscript/resources/chapt_screen_images/about-the-authors.png b/manuscript/resources/chapt_screen_images/about-the-authors.png deleted file mode 100644 index c1c9349..0000000 Binary files a/manuscript/resources/chapt_screen_images/about-the-authors.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/applying-github-actions-examples.png b/manuscript/resources/chapt_screen_images/applying-github-actions-examples.png deleted file mode 100644 index 256310c..0000000 Binary files a/manuscript/resources/chapt_screen_images/applying-github-actions-examples.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/automating-re-running-analyses.png b/manuscript/resources/chapt_screen_images/automating-re-running-analyses.png deleted file mode 100644 index c0b688e..0000000 Binary files a/manuscript/resources/chapt_screen_images/automating-re-running-analyses.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/github-action-variables.png b/manuscript/resources/chapt_screen_images/github-action-variables.png deleted file mode 100644 index 49af9fe..0000000 Binary files a/manuscript/resources/chapt_screen_images/github-action-variables.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/github-actions-fundamentals.png b/manuscript/resources/chapt_screen_images/github-actions-fundamentals.png deleted file mode 100644 index c23958e..0000000 Binary files a/manuscript/resources/chapt_screen_images/github-actions-fundamentals.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/index.png b/manuscript/resources/chapt_screen_images/index.png deleted file mode 100644 index f7c6cad..0000000 Binary files a/manuscript/resources/chapt_screen_images/index.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/introduction.png b/manuscript/resources/chapt_screen_images/introduction.png deleted file mode 100644 index 7fe36f0..0000000 Binary files a/manuscript/resources/chapt_screen_images/introduction.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/references.png b/manuscript/resources/chapt_screen_images/references.png deleted file mode 100644 index d3d1dd6..0000000 Binary files a/manuscript/resources/chapt_screen_images/references.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/scientific-software-development-best-practices.png b/manuscript/resources/chapt_screen_images/scientific-software-development-best-practices.png deleted file mode 100644 index c83be75..0000000 Binary files a/manuscript/resources/chapt_screen_images/scientific-software-development-best-practices.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/troubleshooting-github-actions.png b/manuscript/resources/chapt_screen_images/troubleshooting-github-actions.png deleted file mode 100644 index 4d3efdb..0000000 Binary files a/manuscript/resources/chapt_screen_images/troubleshooting-github-actions.png and /dev/null differ diff --git a/manuscript/resources/chapt_screen_images/why-automation.png b/manuscript/resources/chapt_screen_images/why-automation.png deleted file mode 100644 index f6b8191..0000000 Binary files a/manuscript/resources/chapt_screen_images/why-automation.png and /dev/null differ diff --git a/resources/chapt_screen_images/about-the-authors.png b/resources/chapt_screen_images/about-the-authors.png index c1c9349..45dbbe1 100644 Binary files a/resources/chapt_screen_images/about-the-authors.png and b/resources/chapt_screen_images/about-the-authors.png differ diff --git a/resources/chapt_screen_images/applying-github-actions-examples.png b/resources/chapt_screen_images/applying-github-actions-examples.png index 256310c..acfd916 100644 Binary files a/resources/chapt_screen_images/applying-github-actions-examples.png and b/resources/chapt_screen_images/applying-github-actions-examples.png differ diff --git a/resources/chapt_screen_images/automating-re-running-analyses.png b/resources/chapt_screen_images/automating-re-running-analyses.png index c0b688e..4377ade 100644 Binary files a/resources/chapt_screen_images/automating-re-running-analyses.png and b/resources/chapt_screen_images/automating-re-running-analyses.png differ diff --git a/resources/chapt_screen_images/chapter_urls.tsv b/resources/chapt_screen_images/chapter_urls.tsv index 8d4a3e7..ddd7313 100644 --- a/resources/chapt_screen_images/chapter_urls.tsv +++ b/resources/chapt_screen_images/chapter_urls.tsv @@ -1,12 +1,12 @@ url chapt_title img_path -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/index.html About this Course resources/chapt_screen_images/index.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/scientific-software-development-best-practices.html 2 Scientific software development best practices resources/chapt_screen_images/scientific-software-development-best-practices.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/why-automation.html 3 Why Automation resources/chapt_screen_images/why-automation.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/github-actions-fundamentals.html 4 GitHub Actions Fundamentals resources/chapt_screen_images/github-actions-fundamentals.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/automating-re-running-analyses.html 5 Automating Re-running Analyses resources/chapt_screen_images/automating-re-running-analyses.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/github-action-variables.html 6 GitHub Action Variables resources/chapt_screen_images/github-action-variables.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/troubleshooting-github-actions.html 7 Troubleshooting GitHub Actions resources/chapt_screen_images/troubleshooting-github-actions.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/applying-github-actions-examples.html 8 Applying GitHub Actions Examples resources/chapt_screen_images/applying-github-actions-examples.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png -https://hutchdatascience.org/GitHub_Automation_for_Scientists/no_toc/references.html 9 References resources/chapt_screen_images/references.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/index.html About this Course resources/chapt_screen_images/index.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/scientific-software-development-best-practices.html 2 Scientific software development best practices resources/chapt_screen_images/scientific-software-development-best-practices.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/why-automation.html 3 Why Automation resources/chapt_screen_images/why-automation.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/github-actions-fundamentals.html 4 GitHub Actions Fundamentals resources/chapt_screen_images/github-actions-fundamentals.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/automating-re-running-analyses.html 5 Automating Re-running Analyses resources/chapt_screen_images/automating-re-running-analyses.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/github-action-variables.html 6 GitHub Action Variables resources/chapt_screen_images/github-action-variables.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/troubleshooting-github-actions.html 7 Troubleshooting GitHub Actions resources/chapt_screen_images/troubleshooting-github-actions.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/applying-github-actions-examples.html 8 Applying GitHub Actions Examples resources/chapt_screen_images/applying-github-actions-examples.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png +https://hutchdatascience.org/GitHub_Automation_for_Scientists/references.html 9 References resources/chapt_screen_images/references.png diff --git a/resources/chapt_screen_images/github-action-variables.png b/resources/chapt_screen_images/github-action-variables.png index 49af9fe..2d3659b 100644 Binary files a/resources/chapt_screen_images/github-action-variables.png and b/resources/chapt_screen_images/github-action-variables.png differ diff --git a/resources/chapt_screen_images/github-actions-fundamentals.png b/resources/chapt_screen_images/github-actions-fundamentals.png index c23958e..4f81f04 100644 Binary files a/resources/chapt_screen_images/github-actions-fundamentals.png and b/resources/chapt_screen_images/github-actions-fundamentals.png differ diff --git a/resources/chapt_screen_images/index.png b/resources/chapt_screen_images/index.png index f7c6cad..df610dd 100644 Binary files a/resources/chapt_screen_images/index.png and b/resources/chapt_screen_images/index.png differ diff --git a/resources/chapt_screen_images/introduction.png b/resources/chapt_screen_images/introduction.png index 7fe36f0..d7e2baa 100644 Binary files a/resources/chapt_screen_images/introduction.png and b/resources/chapt_screen_images/introduction.png differ diff --git a/resources/chapt_screen_images/references.png b/resources/chapt_screen_images/references.png index d3d1dd6..cb0484d 100644 Binary files a/resources/chapt_screen_images/references.png and b/resources/chapt_screen_images/references.png differ diff --git a/resources/chapt_screen_images/scientific-software-development-best-practices.png b/resources/chapt_screen_images/scientific-software-development-best-practices.png index c83be75..73f417f 100644 Binary files a/resources/chapt_screen_images/scientific-software-development-best-practices.png and b/resources/chapt_screen_images/scientific-software-development-best-practices.png differ diff --git a/resources/chapt_screen_images/troubleshooting-github-actions.png b/resources/chapt_screen_images/troubleshooting-github-actions.png index 4d3efdb..6bc3f2a 100644 Binary files a/resources/chapt_screen_images/troubleshooting-github-actions.png and b/resources/chapt_screen_images/troubleshooting-github-actions.png differ diff --git a/resources/chapt_screen_images/why-automation.png b/resources/chapt_screen_images/why-automation.png index f6b8191..0d729ef 100644 Binary files a/resources/chapt_screen_images/why-automation.png and b/resources/chapt_screen_images/why-automation.png differ