From 03e416e887943b5e92ddb67cc9ace61bc902b71c Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:06:39 +0000 Subject: [PATCH 1/8] Change to webshot2 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1faeb1d..e7a5103 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,7 +33,7 @@ Imports: R.utils, readr, stringr, - webshot + webshot2 Suggests: knitr, rcrossref, From 24f151a649955060b2f26326d7c0959a9952bcfb Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:08:27 +0000 Subject: [PATCH 2/8] Change to webshot2 and remove phantomjs check --- R/write_vc.R | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/R/write_vc.R b/R/write_vc.R index 27834ed..0a2afb6 100644 --- a/R/write_vc.R +++ b/R/write_vc.R @@ -73,10 +73,7 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { } ) } else if (export_as == "png") { - if (!webshot::is_phantomjs_installed()) { - message("You need to download and install phantomJS to save output as PNG. Try running 'webshot::install_phantomjs()' once.") - } else { - # renders as "complete" html to get the white background for PNG snapshot. + # renders as "complete" html to get the white background for PNG snapshot. tryCatch( expr = { htmltools::save_html(work_item$vcs, file = output_file) @@ -89,12 +86,10 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { message("Having difficulties saving the intermediate HTML output:") print(w) } - ) - tryCatch( expr = { - webshot::webshot(output_file, paste0(output_file, ".png"), selector = ".visual-citation", zoom = 2) + webshot2::webshot(output_file, paste0(output_file, ".png"), selector = ".visual-citation", zoom = 2) }, error = function(e) { message("Could not take a screenshot of the intermediate HTML.") From 395aa13a61238783e53067d675c5ffdf7a3741e5 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:10:03 +0000 Subject: [PATCH 3/8] Change to webshot2 --- R/write_vc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/write_vc.R b/R/write_vc.R index 0a2afb6..288a443 100644 --- a/R/write_vc.R +++ b/R/write_vc.R @@ -15,7 +15,7 @@ #' } #' #' @importFrom htmltools tags save_html -#' @importFrom webshot webshot +#' @importFrom webshot2 webshot write_vc <- function(work_item, path_absolute, output_dir, export_as) { From f4ec216943afd1ffcc1148365d1cb2a6dc078608 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:11:46 +0000 Subject: [PATCH 4/8] Update to webshot2 --- R/drop_name.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/drop_name.R b/R/drop_name.R index 52e496e..6c55d1e 100644 --- a/R/drop_name.R +++ b/R/drop_name.R @@ -11,8 +11,7 @@ #' In other words, either one, many or no BibTeX citation keys can be specified. #' @param export_as A string specifying the desired output format. For now supports PNG and HTML. #' Use "html" to include the 'bare' taglist (recommended for inclusion in Rmarkdown documents) or "html_full" to write a standalone .html file including etc. -#' The PNG is a screenshot of the rendered HTML via the 'webshot' package. The filename represents this two step approach on purpose. -#' For webshot you need to install phantomJS once (see 'webshot' documentation). +#' The PNG is a screenshot of the rendered HTML via the 'webshot2' package. The filename represents this two step approach on purpose. #' @param output_dir A string specifying the relative path, where the rendered output files should be stored. #' @param max_authors Integer number of maximum authors to print. If the number of authors exceeds this, the list is cropped accordingly. #' @param include_qr Character string specifying the way the QR code should be included or if no QR code should be included. From 88d363b7ce7041db2e0258cba7fd94b1a71c5737 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:13:12 +0000 Subject: [PATCH 5/8] Fix typo --- R/write_vc.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/write_vc.R b/R/write_vc.R index 288a443..cacfd8f 100644 --- a/R/write_vc.R +++ b/R/write_vc.R @@ -86,6 +86,7 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { message("Having difficulties saving the intermediate HTML output:") print(w) } + ) tryCatch( expr = { From 8c0526e21e9b8ca841e350e6a7d2ea1f04fd9095 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:30:23 +0000 Subject: [PATCH 6/8] Squash changes to webshot2 --- DESCRIPTION | 69 ++++++++++++++++------------------ R/drop_name.R | 9 ++--- R/write_vc.R | 12 ++---- cran-comments.md | 13 +++---- tests/testthat/test-write_vc.R | 4 +- 5 files changed, 48 insertions(+), 59 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d855404..e7a5103 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,53 +1,48 @@ -Package: namedropR Type: Package +Package: namedropR Title: Create Visual Citations for Presentations and Posters Version: 2.4.1 Authors@R: c( - person(given = c("Christian", "A."), - family = "Gebhard", - role = c("aut", "cre"), - email = "christian.gebhard@posteo.de", + person(c("Christian", "A."), "Gebhard", , "christian.gebhard@posteo.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8792-565X")), - person(given = "Lukas", - family = "Wallrich", - role = c("ctb"), - email = "l.wallrich@bbk.ac.uk", - comment = c(ORCID = "0000-0003-2121-5177")), - person(given = "Matthew T.", - family = "Warkentin", - role = c("ctb"), - email = "warkentin@lunenfeld.ca", + person("Lukas", "Wallrich", , "l.wallrich@bbk.ac.uk", role = "ctb", + comment = c(ORCID = "0000-0003-2121-5177")), + person("Matthew T.", "Warkentin", , "warkentin@lunenfeld.ca", role = "ctb", comment = c(ORCID = "0000-0001-8730-3511")) - ) -Description: Provides 'visual citations' containing the metadata of a scientific paper and a 'QR' code. - A 'visual citation' is a banner containing title, authors, journal and year of a publication. - This package can create such banners based on 'BibTeX' and 'BibLaTeX' references or call the - reference metadata from 'Crossref'-API. The banners include a QR code pointing to the 'DOI'. - The resulting HTML object or PNG image can be included in a presentation to point the audience to good resources for further reading. - Styling is possible via predefined designs or via custom 'CSS'. - This package is not intended as replacement for proper reference manager packages, - but a tool to enrich scientific presentation slides and conference posters. + ) +Description: Provides 'visual citations' containing the metadata of a + scientific paper and a 'QR' code. A 'visual citation' is a banner + containing title, authors, journal and year of a publication. This + package can create such banners based on 'BibTeX' and 'BibLaTeX' + references or call the reference metadata from 'Crossref'-API. The + banners include a QR code pointing to the 'DOI'. The resulting HTML + object or PNG image can be included in a presentation to point the + audience to good resources for further reading. Styling is possible + via predefined designs or via custom 'CSS'. This package is not + intended as replacement for proper reference manager packages, but a + tool to enrich scientific presentation slides and conference posters. License: MIT + file LICENSE +URL: https://github.com/nucleic-acid/namedropR +BugReports: https://github.com/nucleic-acid/namedropR/issues Imports: - htmltools, - qrcode (>= 0.1.4), - lubridate, - webshot, bib2df, dplyr, + htmltools, + lubridate, + qrcode (>= 0.1.4), + R.utils, readr, stringr, - R.utils -Encoding: UTF-8 -LazyData: false -BugReports: https://github.com/nucleic-acid/namedropR/issues -URL: https://github.com/nucleic-acid/namedropR -RoxygenNote: 7.2.1 + webshot2 Suggests: - testthat (>= 3.0.0), knitr, - withr, + rcrossref, rmarkdown, - rcrossref + testthat (>= 3.0.0), + withr +VignetteBuilder: + knitr Config/testthat/edition: 3 -VignetteBuilder: knitr +Encoding: UTF-8 +LazyData: false +RoxygenNote: 7.2.1 diff --git a/R/drop_name.R b/R/drop_name.R index a7457d1..3163e1e 100644 --- a/R/drop_name.R +++ b/R/drop_name.R @@ -11,8 +11,7 @@ #' In other words, either one, many or no BibTeX citation keys can be specified. #' @param export_as A string specifying the desired output format. For now supports PNG and HTML. #' Use "html" to include the 'bare' taglist (recommended for inclusion in Rmarkdown documents) or "html_full" to write a standalone .html file including etc. -#' The PNG is a screenshot of the rendered HTML via the 'webshot' package. The filename represents this two step approach on purpose. -#' For webshot you need to install phantomJS once (see 'webshot' documentation). +#' The PNG is a screenshot of the rendered HTML via the 'webshot2' package. The filename represents this two step approach on purpose. #' @param output_dir A string specifying the relative path, where the rendered output files should be stored. #' @param max_authors Integer number of maximum authors to print. If the number of authors exceeds this, the list is cropped accordingly. #' @param include_qr Character string specifying the way the QR code should be included or if no QR code should be included. @@ -83,7 +82,7 @@ #' @import dplyr #' @importFrom htmltools tags save_html #' @importFrom lubridate year ymd -#' @importFrom webshot webshot +#' @importFrom webshot2 webshot #' @importFrom stringr str_detect str_remove_all str_trunc str_replace_all drop_name <- function(bib, cite_key, @@ -193,7 +192,7 @@ drop_name <- function(bib, cite_key, dplyr::mutate(JOURNAL = ifelse(is.na(.data$JOURNAL), .data$JOURNALTITLE, .data$JOURNAL)) } else { bib_data <- bib_data %>% - dplyr::rename(JOURNAL = .data$JOURNALTITLE) + dplyr::rename(JOURNAL = "JOURNALTITLE") } # message("One or more references had BibLaTeX field 'JOURNALTITLE' and were transformed to 'JOURNAL'.") } @@ -252,7 +251,7 @@ drop_name <- function(bib, cite_key, # the remaining URLs will be created below, after condensing the authors lists # select required columns only and add missing BIBTEXKEYs: - clean_bib <- dplyr::select(bib_data, .data$YEAR, .data$AUTHOR, .data$JOURNAL, .data$TITLE, .data$BIBTEXKEY, .data$QR) %>% + clean_bib <- dplyr::select(bib_data, "YEAR", "AUTHOR", "JOURNAL", "TITLE", "BIBTEXKEY", "QR") %>% dplyr::mutate( `BIBTEXKEY` = ifelse( is.na(.data$BIBTEXKEY), diff --git a/R/write_vc.R b/R/write_vc.R index 27834ed..56d132f 100644 --- a/R/write_vc.R +++ b/R/write_vc.R @@ -15,7 +15,7 @@ #' } #' #' @importFrom htmltools tags save_html -#' @importFrom webshot webshot +#' @importFrom webshot2 webshot write_vc <- function(work_item, path_absolute, output_dir, export_as) { @@ -73,10 +73,7 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { } ) } else if (export_as == "png") { - if (!webshot::is_phantomjs_installed()) { - message("You need to download and install phantomJS to save output as PNG. Try running 'webshot::install_phantomjs()' once.") - } else { - # renders as "complete" html to get the white background for PNG snapshot. + # renders as "complete" html to get the white background for PNG snapshot. tryCatch( expr = { htmltools::save_html(work_item$vcs, file = output_file) @@ -91,10 +88,9 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { } ) - tryCatch( expr = { - webshot::webshot(output_file, paste0(output_file, ".png"), selector = ".visual-citation", zoom = 2) + webshot2::webshot(output_file, paste0(output_file, ".png"), selector = ".visual-citation", zoom = 2) }, error = function(e) { message("Could not take a screenshot of the intermediate HTML.") @@ -116,7 +112,7 @@ write_vc <- function(work_item, path_absolute, output_dir, export_as) { R.utils::getRelativePath(png_out) ) return(return_path_png) - } + } else { stop("Output format unknown") } diff --git a/cran-comments.md b/cran-comments.md index 22739a0..7ea390e 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,17 +1,16 @@ ## Test environments -- R-hub Windows Server 2022, R-devel, 64 bit (r-devel) -- R-hub Ubuntu Linux 20.04.1 LTS, R-release, GCC (r-release) -- R-hub Fedora Linux, R-devel, clang, gfortran (r-devel) +- R-hub windows-x86_64-devel (r-devel) +- R-hub ubuntu-gcc-release (r-release) +- R-hub fedora-clang-devel (r-devel) ## R CMD check results - > On windows-x86_64-devel (r-devel) checking for detritus in the temp directory ... NOTE Found the following files/directories: 'lastMiKTeXException' - -> On Fedora Linux, R-devel, clang, gfortran + +> On fedora-clang-devel (r-devel) checking HTML version of manual ... NOTE Skipping checking HTML validation: no command 'tidy' found -0 errors ✓ | 0 warnings ✓ | 2 notes x +0 errors | 0 warnings | 2 notes diff --git a/tests/testthat/test-write_vc.R b/tests/testthat/test-write_vc.R index b924b1a..1f96b28 100644 --- a/tests/testthat/test-write_vc.R +++ b/tests/testthat/test-write_vc.R @@ -142,8 +142,8 @@ test_that("saving as html works as expected", { # "Some 2023", "Alice; Bob; Charlie", "Journal of Unnecessary R Packages", "Alice2023", "2023", VCS # ) # -# # writes a file, this test can only be run, if phantomJS is installed: -# if(webshot::is_phantomjs_installed()) { +# # writes a file, this test can only be run, if a chromium browser is installed +# if(!is.null(chromote::find_chrome())) { # withr::with_dir( # new = new, # code = { From 990e4cdf2b1ecb95d6507884b247ce25964194db Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:38:55 +0000 Subject: [PATCH 7/8] Remove no cite_key warning when single citation is processed --- R/drop_name.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/drop_name.R b/R/drop_name.R index 3163e1e..f7afb5c 100644 --- a/R/drop_name.R +++ b/R/drop_name.R @@ -292,7 +292,9 @@ drop_name <- function(bib, cite_key, # handle different input options for bibtex keys if (missing(cite_key)) { n_bib <- nrow(clean_bib) - message(paste0("No cite_key specified. Working through all possible ", n_bib, " entries in the bibliography.")) + if (n_bib > 1) { + message(paste0("No cite_key specified. Working through all possible ", n_bib, " entries in the bibliography.")) + } work_list <- clean_bib } else if (!is.character(cite_key)) { stop("cite_key must be of type 'caracter'.") From 7cf2526520982023deee1feb342faca1d1023a08 Mon Sep 17 00:00:00 2001 From: Lukas Wallrich Date: Sun, 11 Dec 2022 13:41:18 +0000 Subject: [PATCH 8/8] Update rcrossref note after CRAN release of 1.2 --- DESCRIPTION | 2 +- README.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e7a5103..d97af3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Imports: webshot2 Suggests: knitr, - rcrossref, + rcrossref (>= 1.2), rmarkdown, testthat (>= 3.0.0), withr diff --git a/README.Rmd b/README.Rmd index 3a0cee7..5e4f5e7 100644 --- a/README.Rmd +++ b/README.Rmd @@ -119,7 +119,7 @@ drop_name( ### Pulling data from Crossref If you don't have a *.bib file, but DOIs instead, you can pass them to `drop_name_crossref()` which pulls the data from [Crossref](https://www.crossref.org) and passes the downloaded data on to `drop_name()`. -**TEMPORARY NOTE:** *Due to recent API changes in Crossref you need to have {rcrossref} version > 1.1 installed. As long as {rcrossref} v1.2 is not yet available on CRAN, installing the development version >= v1.1.0.99 might avoid error messages. If you don't feel comfortable with installing development versions (use at your own risk!), this function will only work with CRAN version of {rcrossref} >= v1.2 installed.* +**TEMPORARY NOTE:** *Due to recent API changes in Crossref you need to have {rcrossref} version >= 1.2 installed.* ``` r # DOIs can be named vectors...