From 7cc77d4abf5567c25bb16b85bf61fe3e85efe41d Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 5 Dec 2023 07:43:32 -0500 Subject: [PATCH 01/10] Fix capitalization --- R/mod_downloadHandler.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/mod_downloadHandler.R b/R/mod_downloadHandler.R index ff0cd7262..9231a07af 100644 --- a/R/mod_downloadHandler.R +++ b/R/mod_downloadHandler.R @@ -165,7 +165,7 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){ Report <- file.path(my_tempdir, "reportDocx.Rmd") if (!dir.exists(file.path(my_tempdir, "images"))) dir.create(file.path(my_tempdir, "images")) - file.copy(system.file('report_downloads', 'ReportDocx.Rmd', package = "riskassessment"), + file.copy(system.file('report_downloads', 'reportDocx.Rmd', package = "riskassessment"), Report, overwrite = TRUE) file.copy(system.file('report_downloads', 'header.docx', package = 'riskassessment'), @@ -189,7 +189,7 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){ Report <- file.path(my_tempdir, "reportPdf.Rmd") if (!dir.exists(file.path(my_tempdir, "images"))) dir.create(file.path(my_tempdir, "images")) - file.copy(system.file('report_downloads', 'ReportPdf.Rmd', package = "riskassessment"), + file.copy(system.file('report_downloads', 'reportPdf.Rmd', package = "riskassessment"), Report, overwrite = TRUE) file.copy(system.file('report_downloads', 'header.tex', package = 'riskassessment'), From 0cefbb5a3446633a036f42133f065372e01d198f Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 5 Dec 2023 07:51:01 -0500 Subject: [PATCH 02/10] Make sure tinytex is installed --- .Rprofile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rprofile b/.Rprofile index ebe3173aa..8b1e428a2 100644 --- a/.Rprofile +++ b/.Rprofile @@ -2,3 +2,5 @@ source("renv/activate.R") options(renv.config.mran.enabled = FALSE) options(renv.config.auto.snapshot = FALSE) options(renv.config.snapshot.inference = FALSE) + +if (!tinytex::is_tinytex()) tinytex::install_tinytex() From 54aed6e645fe49c3f21b2ff2ab78d7b1bac828e0 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 5 Dec 2023 07:53:57 -0500 Subject: [PATCH 03/10] Remove tinytex installation --- .Rprofile | 2 -- 1 file changed, 2 deletions(-) diff --git a/.Rprofile b/.Rprofile index 8b1e428a2..ebe3173aa 100644 --- a/.Rprofile +++ b/.Rprofile @@ -2,5 +2,3 @@ source("renv/activate.R") options(renv.config.mran.enabled = FALSE) options(renv.config.auto.snapshot = FALSE) options(renv.config.snapshot.inference = FALSE) - -if (!tinytex::is_tinytex()) tinytex::install_tinytex() From 7cc9a850b4c9a8104cce556b1b0fbe8834565119 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 5 Dec 2023 14:19:34 -0500 Subject: [PATCH 04/10] Switch out `system.file()` for `app_sys()` --- R/mod_downloadHandler.R | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/R/mod_downloadHandler.R b/R/mod_downloadHandler.R index 9231a07af..b460619f4 100644 --- a/R/mod_downloadHandler.R +++ b/R/mod_downloadHandler.R @@ -155,61 +155,61 @@ mod_downloadHandler_server <- function(id, pkgs, user, metric_weights){ } Report <- file.path(my_tempdir, "reportHtml.Rmd") - file.copy(system.file('report_downloads', 'reportHtml.Rmd', package = "riskassessment"), Report, overwrite = TRUE) - file.copy(system.file('report_downloads', 'raa-image.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'reportHtml.Rmd'), Report, overwrite = TRUE) + file.copy(app_sys('report_downloads', 'raa-image.png'), file.path(my_tempdir, 'raa-image.png'), overwrite = TRUE) - file.copy(system.file('report_downloads', 'header.html', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'header.html'), file.path(my_tempdir, 'header.html'), overwrite = TRUE) } else if (input$report_format == "docx") { Report <- file.path(my_tempdir, "reportDocx.Rmd") if (!dir.exists(file.path(my_tempdir, "images"))) dir.create(file.path(my_tempdir, "images")) - file.copy(system.file('report_downloads', 'reportDocx.Rmd', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'reportDocx.Rmd'), Report, overwrite = TRUE) - file.copy(system.file('report_downloads', 'header.docx', package = 'riskassessment'), + file.copy(app_sys('report_downloads', 'header.docx'), file.path(my_tempdir, 'header.docx'), overwrite = TRUE) - file.copy(system.file('report_downloads', 'read_html.lua', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'read_html.lua'), file.path(my_tempdir, "read_html.lua"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'user-tie.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'user-tie.png'), file.path(my_tempdir, "images", "user-tie.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'user-shield.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'user-shield.png'), file.path(my_tempdir, "images", "user-shield.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'calendar-alt.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'calendar-alt.png'), file.path(my_tempdir, "images", "calendar-alt.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'raa-image.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'raa-image.png'), file.path(my_tempdir, 'raa-image.png'), overwrite = TRUE) } else { Report <- file.path(my_tempdir, "reportPdf.Rmd") if (!dir.exists(file.path(my_tempdir, "images"))) dir.create(file.path(my_tempdir, "images")) - file.copy(system.file('report_downloads', 'reportPdf.Rmd', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'reportPdf.Rmd'), Report, overwrite = TRUE) - file.copy(system.file('report_downloads', 'header.tex', package = 'riskassessment'), + file.copy(app_sys('report_downloads', 'header.tex'), file.path(my_tempdir, 'header.tex'), overwrite = TRUE) - file.copy(system.file('report_downloads', 'fancyhdr.sty', package = 'riskassessment'), + file.copy(app_sys('report_downloads', 'fancyhdr.sty'), file.path(my_tempdir, 'fancyhdr.sty'), overwrite = TRUE) - file.copy(system.file('report_downloads', 'read_html.lua', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'read_html.lua'), file.path(my_tempdir, "read_html.lua"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'user-tie.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'user-tie.png'), file.path(my_tempdir, "images", "user-tie.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'user-shield.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'user-shield.png'), file.path(my_tempdir, "images", "user-shield.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'images', 'calendar-alt.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'images', 'calendar-alt.png'), file.path(my_tempdir, "images", "calendar-alt.png"), overwrite = TRUE) - file.copy(system.file('report_downloads', 'raa-image.png', package = "riskassessment"), + file.copy(app_sys('report_downloads', 'raa-image.png'), file.path(my_tempdir, 'raa-image.png'), overwrite = TRUE) } From 81e374d80c1ecb71e94db230602d53526a15d468 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 5 Dec 2023 14:19:54 -0500 Subject: [PATCH 05/10] Add some page breaks to the HTML output --- inst/report_downloads/reportHtml.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inst/report_downloads/reportHtml.Rmd b/inst/report_downloads/reportHtml.Rmd index f72bb9bfd..8708b7d47 100644 --- a/inst/report_downloads/reportHtml.Rmd +++ b/inst/report_downloads/reportHtml.Rmd @@ -286,7 +286,7 @@ tagList( br(), hr(), br(), br(), - h5("Maintenance Metrics", style = "text-align: center;"), + h5("Maintenance Metrics", style = "text-align: center; page-break-before: always;"), br() ) } else "", @@ -320,7 +320,7 @@ tagList( br(), hr(), br(), br(), - h5("Community Usage Metrics", style = "text-align: center;"), + h5("Community Usage Metrics", style = "text-align: center; page-break-before: always;"), br() ) } else "", From b2527768c889f4d967f419b8f91d5ddb47e545a4 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Thu, 7 Dec 2023 11:53:36 -0500 Subject: [PATCH 06/10] Apply nicer formatting for downloads to the cards --- inst/report_downloads/reportHtml.Rmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inst/report_downloads/reportHtml.Rmd b/inst/report_downloads/reportHtml.Rmd index 8708b7d47..160cdfd00 100644 --- a/inst/report_downloads/reportHtml.Rmd +++ b/inst/report_downloads/reportHtml.Rmd @@ -130,11 +130,13 @@ createCard <- function(title, desc, value, score = "NULL", html_component <- div(class="card mb-3 text-center border-info", style=card_style, div(class ="row no-gutters", div(class="col-md-4 text-center border-info", + style = "width: calc(100% / 3) !important;", display_obj # icon(icon_name, class=icon_class, verify_fa = FALSE, # style="padding-top: 40%; font-size:60px; padding-left: 20%;") ), div(class="col-md-8", + style = "width: calc(100% * 2 / 3) !important;", h5(class="card-header bg-transparent", style="font-size: 1vw", title), div(class="card-body text-info", From 3ed74badb74a57b1437937b0c6dd1bad1e305d3d Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Thu, 7 Dec 2023 11:55:26 -0500 Subject: [PATCH 07/10] Add DOCX into test --- tests/testthat/test-downloadHandler.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-downloadHandler.R b/tests/testthat/test-downloadHandler.R index 896b01b3a..1e4462be0 100644 --- a/tests/testthat/test-downloadHandler.R +++ b/tests/testthat/test-downloadHandler.R @@ -8,9 +8,9 @@ test_that("downloadHandler works", { expect_equal(tools::file_ext(report), "html") ## TODO: Add tests back in when issues are figured out - # app$set_inputs(`downloadHandler_1-report_format` = "docx") - # report <- app$get_download("downloadHandler_1-download_reports") - # expect_equal(tools::file_ext(report), "docx") + app$set_inputs(`downloadHandler_1-report_format` = "docx") + report <- app$get_download("downloadHandler_1-download_reports") + expect_equal(tools::file_ext(report), "docx") # # app$set_inputs(`downloadHandler_1-report_format` = "pdf") # report <- app$get_download("downloadHandler_1-download_reports") From 63983e54e5cb7733b9ba89232acd07d6ec850711 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Thu, 7 Dec 2023 12:16:05 -0500 Subject: [PATCH 08/10] Add PDF downloads into test --- tests/testthat/test-downloadHandler.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-downloadHandler.R b/tests/testthat/test-downloadHandler.R index 1e4462be0..03e556f73 100644 --- a/tests/testthat/test-downloadHandler.R +++ b/tests/testthat/test-downloadHandler.R @@ -12,9 +12,9 @@ test_that("downloadHandler works", { report <- app$get_download("downloadHandler_1-download_reports") expect_equal(tools::file_ext(report), "docx") # - # app$set_inputs(`downloadHandler_1-report_format` = "pdf") - # report <- app$get_download("downloadHandler_1-download_reports") - # expect_equal(tools::file_ext(report), "pdf") + app$set_inputs(`downloadHandler_1-report_format` = "pdf") + report <- app$get_download("downloadHandler_1-download_reports") + expect_equal(tools::file_ext(report), "pdf") app$set_inputs(tabs = "multiple") expect_equal(app$get_value(input = "downloadHandler_2-report_format"), "html") From e24ed493e42861f6869b77b2dc8db80f9ebc72c0 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Thu, 7 Dec 2023 12:30:43 -0500 Subject: [PATCH 09/10] Install XeLatex --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index aa5cf8aeb..86c8d6ab0 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -34,6 +34,7 @@ jobs: sudo apt-get install -y libcurl4-openssl-dev sudo apt-get install -y libharfbuzz-dev sudo apt-get install -y libfribidi-dev + sudo apt-get install -y texlive-xetex - uses: actions/checkout@v3 From e4b004ee65e4442549b1da6bf49dda2f865269dd Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Thu, 7 Dec 2023 13:06:54 -0500 Subject: [PATCH 10/10] Install TexLive on test-coverage workflow as well --- .github/workflows/test-coverage.yaml | 7 +++++++ tests/testthat/test-downloadHandler.R | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index de0e9ad3e..dffb85e7c 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -17,6 +17,13 @@ jobs: RENV_CONFIG_SANDBOX_ENABLED: false steps: + - name: Install TexLive + if: runner.os == 'Linux' + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y texlive-xetex + - uses: actions/checkout@v2 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/tests/testthat/test-downloadHandler.R b/tests/testthat/test-downloadHandler.R index 03e556f73..6baf422e3 100644 --- a/tests/testthat/test-downloadHandler.R +++ b/tests/testthat/test-downloadHandler.R @@ -7,11 +7,10 @@ test_that("downloadHandler works", { report <- app$get_download("downloadHandler_1-download_reports") expect_equal(tools::file_ext(report), "html") - ## TODO: Add tests back in when issues are figured out app$set_inputs(`downloadHandler_1-report_format` = "docx") report <- app$get_download("downloadHandler_1-download_reports") expect_equal(tools::file_ext(report), "docx") - # + app$set_inputs(`downloadHandler_1-report_format` = "pdf") report <- app$get_download("downloadHandler_1-download_reports") expect_equal(tools::file_ext(report), "pdf")