Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GHAs for DOCX and PDF downloads #717

Merged
merged 11 commits into from
Dec 14, 2023
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions R/mod_downloadHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 4 additions & 2 deletions inst/report_downloads/reportHtml.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -286,7 +288,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 "",
Expand Down Expand Up @@ -320,7 +322,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 "",
Expand Down
15 changes: 7 additions & 8 deletions tests/testthat/test-downloadHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ 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")
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")

app$set_inputs(tabs = "multiple")
expect_equal(app$get_value(input = "downloadHandler_2-report_format"), "html")
Expand Down
Loading