generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e30ad8
commit 004076a
Showing
45 changed files
with
101 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"))) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file removed
BIN
-74.9 KB
...ipt/resources/chapt_screen_images/creating-a-smooth-getting-started-section.png
Binary file not shown.
Binary file removed
BIN
-69.4 KB
manuscript/resources/chapt_screen_images/creating-clarifying-code-comments.png
Binary file not shown.
Binary file removed
BIN
-75 KB
manuscript/resources/chapt_screen_images/creating-handy-reference-guides.png
Binary file not shown.
Binary file removed
BIN
-73.2 KB
manuscript/resources/chapt_screen_images/creating-helpful-how-to-examples.png
Binary file not shown.
Binary file removed
BIN
-80.9 KB
...script/resources/chapt_screen_images/documentation-why-its-worth-the-effort.png
Binary file not shown.
Binary file removed
BIN
-71.5 KB
...ipt/resources/chapt_screen_images/how-to-keep-your-documentation-up-to-date.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-81.1 KB
.../resources/chapt_screen_images/lessons-we-should-borrow-from-user-designers.png
Binary file not shown.
Binary file removed
BIN
-70.8 KB
manuscript/resources/chapt_screen_images/obtaining-user-feedback.png
Binary file not shown.
Binary file removed
BIN
-70.2 KB
manuscript/resources/chapt_screen_images/other-helpful-features.png
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-77.5 KB
...script/resources/chapt_screen_images/what-does-good-documentation-look-like.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
url chapt_title img_path | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/index.html About this course resources/chapt_screen_images/index.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/documentation-why-its-worth-the-effort.html 2 Documentation: Why it’s worth the effort! resources/chapt_screen_images/documentation-why-its-worth-the-effort.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/lessons-we-should-borrow-from-user-designers.html 3 Lessons we should borrow from user designers resources/chapt_screen_images/lessons-we-should-borrow-from-user-designers.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/what-does-good-documentation-look-like.html 4 What does good documentation look like? resources/chapt_screen_images/what-does-good-documentation-look-like.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/creating-a-smooth-getting-started-section.html 5 Creating a smooth getting started section resources/chapt_screen_images/creating-a-smooth-getting-started-section.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/creating-helpful-how-to-examples.html 6 Creating helpful how-to examples resources/chapt_screen_images/creating-helpful-how-to-examples.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/creating-handy-reference-guides.html 7 Creating handy reference guides resources/chapt_screen_images/creating-handy-reference-guides.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/creating-clarifying-code-comments.html 8 Creating clarifying code comments resources/chapt_screen_images/creating-clarifying-code-comments.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/obtaining-user-feedback.html 9 Obtaining user feedback resources/chapt_screen_images/obtaining-user-feedback.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/other-helpful-features.html 10 Other helpful features resources/chapt_screen_images/other-helpful-features.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/how-to-keep-your-documentation-up-to-date.html 11 How to keep your documentation up to date resources/chapt_screen_images/how-to-keep-your-documentation-up-to-date.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png | ||
https://jhudatascience.org/Documentation_and_Usability/no_toc/references.html References resources/chapt_screen_images/references.png | ||
https://jhudatascience.org/Documentation_and_Usability/index.html About this course resources/chapt_screen_images/index.png | ||
https://jhudatascience.org/Documentation_and_Usability/introduction.html 1 Introduction resources/chapt_screen_images/introduction.png | ||
https://jhudatascience.org/Documentation_and_Usability/documentation-why-its-worth-the-effort.html 2 Documentation: Why it’s worth the effort! resources/chapt_screen_images/documentation-why-its-worth-the-effort.png | ||
https://jhudatascience.org/Documentation_and_Usability/lessons-we-should-borrow-from-user-designers.html 3 Lessons we should borrow from user designers resources/chapt_screen_images/lessons-we-should-borrow-from-user-designers.png | ||
https://jhudatascience.org/Documentation_and_Usability/what-does-good-documentation-look-like.html 4 What does good documentation look like? resources/chapt_screen_images/what-does-good-documentation-look-like.png | ||
https://jhudatascience.org/Documentation_and_Usability/creating-a-smooth-getting-started-section.html 5 Creating a smooth getting started section resources/chapt_screen_images/creating-a-smooth-getting-started-section.png | ||
https://jhudatascience.org/Documentation_and_Usability/creating-helpful-how-to-examples.html 6 Creating helpful how-to examples resources/chapt_screen_images/creating-helpful-how-to-examples.png | ||
https://jhudatascience.org/Documentation_and_Usability/creating-handy-reference-guides.html 7 Creating handy reference guides resources/chapt_screen_images/creating-handy-reference-guides.png | ||
https://jhudatascience.org/Documentation_and_Usability/creating-clarifying-code-comments.html 8 Creating clarifying code comments resources/chapt_screen_images/creating-clarifying-code-comments.png | ||
https://jhudatascience.org/Documentation_and_Usability/obtaining-user-feedback.html 9 Obtaining user feedback resources/chapt_screen_images/obtaining-user-feedback.png | ||
https://jhudatascience.org/Documentation_and_Usability/other-helpful-features.html 10 Other helpful features resources/chapt_screen_images/other-helpful-features.png | ||
https://jhudatascience.org/Documentation_and_Usability/how-to-keep-your-documentation-up-to-date.html 11 How to keep your documentation up to date resources/chapt_screen_images/how-to-keep-your-documentation-up-to-date.png | ||
https://jhudatascience.org/Documentation_and_Usability/about-the-authors.html About the Authors resources/chapt_screen_images/about-the-authors.png | ||
https://jhudatascience.org/Documentation_and_Usability/references.html References resources/chapt_screen_images/references.png |
Binary file modified
BIN
+57.4 KB
(180%)
resources/chapt_screen_images/creating-a-smooth-getting-started-section.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
BIN
+54.7 KB
(180%)
resources/chapt_screen_images/creating-clarifying-code-comments.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
BIN
+60.2 KB
(180%)
resources/chapt_screen_images/creating-handy-reference-guides.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
BIN
+60.3 KB
(180%)
resources/chapt_screen_images/creating-helpful-how-to-examples.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
BIN
+49.1 KB
(160%)
resources/chapt_screen_images/documentation-why-its-worth-the-effort.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
BIN
+53.6 KB
(170%)
resources/chapt_screen_images/how-to-keep-your-documentation-up-to-date.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
BIN
+59.6 KB
(170%)
resources/chapt_screen_images/lessons-we-should-borrow-from-user-designers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
+58.9 KB
(180%)
resources/chapt_screen_images/what-does-good-documentation-look-like.png
Oops, something went wrong.