1- # ' File Viewer `teal` Module
1+ # ' File viewer module
22# '
33# ' The file viewer module provides a tool to view static files.
4- # ' Supported formats include text formats, \code{ PDF}, \code{ PNG}, \code{ APNG} ,
5- # ' \code{ JPEG}, \code{ SVG}, \code{ WEBP}, \code{ GIF} and \code{ BMP} .
4+ # ' Supported formats include text formats, ` PDF`, ` PNG` ` APNG` ,
5+ # ' ` JPEG` ` SVG`, ` WEBP`, ` GIF` and ` BMP` .
66# '
77# ' @inheritParams teal::module
88# ' @inheritParams shared_params
9- # ' @param input_path optional, (`list`) of the input paths to either: specific files of accepted formats,
10- # ' a directory or a URL. The paths can be specified as absolute paths or relative to the running
11- # ' directory of the application. Will default to current working directory if not supplied.
9+ # ' @param input_path (`list`) of the input paths, optional. Each element can be:
1210# '
13- # ' @export
11+ # ' 1. Specific path to files of accepted formats
12+ # ' 2. A directory or a URL
1413# '
15- # ' @examples
16- # ' data <- teal_data()
17- # ' data <- within(data, {
18- # ' data <- data.frame(1)
19- # ' })
20- # ' datanames(data) <- c("data")
14+ # ' The paths can be specified as absolute paths or relative to the running
15+ # ' directory of the application.
16+ # ' Default to the current working directory if not supplied.
17+ # '
18+ # ' @inherit shared_params return
2119# '
22- # ' app <- teal::init(
23- # ' data = data,
24- # ' modules = teal::modules(
25- # ' teal.modules.general::tm_file_viewer(
20+ # ' @examples
21+ # ' app <- init(
22+ # ' data = teal_data(data = 1), # Mock dataset to initialize the app without error
23+ # ' modules = modules(
24+ # ' tm_file_viewer(
2625# ' input_path = list(
2726# ' folder = system.file("sample_files", package = "teal.modules.general"),
2827# ' png = system.file("sample_files/sample_file.png", package = "teal.modules.general"),
2928# ' txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"),
30- # ' url =
31- # ' "https://www.fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf"
29+ # ' url = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf"
3230# ' )
3331# ' )
3432# ' )
3533# ' )
3634# ' if (interactive()) {
3735# ' shinyApp(app$ui, app$server)
3836# ' }
37+ # ' @export
3938# '
4039tm_file_viewer <- function (label = " File Viewer Module" ,
4140 input_path = list (" Current Working Directory" = " ." )) {
@@ -90,6 +89,7 @@ tm_file_viewer <- function(label = "File Viewer Module",
9089 )
9190}
9291
92+ # UI function for the file viewer module
9393ui_viewer <- function (id , ... ) {
9494 args <- list (... )
9595 ns <- NS(id )
@@ -116,6 +116,7 @@ ui_viewer <- function(id, ...) {
116116 )
117117}
118118
119+ # Server function for the file viewer module
119120srv_viewer <- function (id , input_path ) {
120121 moduleServer(id , function (input , output , session ) {
121122 temp_dir <- tempfile()
0 commit comments