-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.json
1 lines (1 loc) · 5.28 KB
/
app.json
1
[{"name":"app.R","content":"library(shiny)\nlibrary(dplyr)\nlibrary(DT)\nlibrary(purrr)\n\nui <- fluidPage(\n theme = bslib::bs_theme(version = 5),\n div(\n class = \"container my-3\",\n h1(\"WebR binary R package repository\"),\n p(\n class = \"lead\",\n \"This CRAN-like repository contains R packages compiled to WebAssembly for use with webR.\",\n \"Set this page's URL as the named\",\n code(\"repos\"),\n \"argument when using the\",\n code(\"webr::install()\"),\n \"command to use this repository as the source for downloading binary R packages.\"\n ),\n p(\n \"By default, \",\n code(\"webr::install()\"),\n \"will use the public repository hosted at\",\n a(href = \"https://repo.r-wasm.org/\", \"https://repo.r-wasm.org/\"),\n \". See the\",\n a(href = \"https://docs.r-wasm.org/webr/latest/packages.html\", \"webR documentation\"),\n \"for further information about webR.\"\n ),\n div(\n class = \"my-3\",\n h2(\"Repo statistics\"),\n div(\n class = \"card-group\",\n div(\n class = \"card\",\n div(\n class = \"card-body d-flex flex-column\",\n h4(class = \"card-title\", \"Built R packages: \",\n textOutput(\"built\", inline = TRUE)),\n p(\n class = \"card-text flex-fill\",\n \"CRAN packages that have been built for WebAssembly and are available for download from this repo.\"\n )\n )\n ),\n div(\n class = \"card\",\n div(\n class = \"card-body d-flex flex-column\",\n h4(class = \"card-title\", \"Available R packages: \",\n textOutput(\"available\", inline = TRUE)),\n p(\n class = \"card-text flex-fill\",\n \"CRAN packages for which all of the package dependencies have also been built for WebAssembly and are available for download from this repo.\"\n )\n )\n )\n ),\n ),\n div(\n class = \"my-3\",\n h2(\"Table of packages:\"),\n DTOutput(\"webr_pkgs\")\n )\n )\n)\n\nserver <- function(input, output) {\n res <- withProgress(\n {\n webr_info <- as.data.frame(available.packages(\n contriburl = \"https://repo.r-wasm.org/bin/emscripten/contrib/4.3\"\n ))\n avail_pkgs <- c(rownames(webr_info),\n c(\"base\", \"compiler\", \"datasets\", \"graphics\", \"grDevices\",\n \"grid\", \"methods\", \"splines\", \"stats\", \"stats4\",\n \"tools\", \"utils\", \"parallel\", \"webr\"))\n incProgress(2 / 5)\n\n deps <- tools::package_dependencies(packages = rownames(webr_info),\n db = webr_info, recursive = TRUE)\n incProgress(2 / 5)\n\n deps <- tibble(\n Package = names(deps),\n Available = deps |> map(\\(x) all(x %in% avail_pkgs)),\n Depends = deps,\n Missing = deps |> map(\\(x) x[!(x %in% avail_pkgs)]),\n )\n incProgress(1 / 5)\n\n package_table <- webr_info |>\n select(c(\"Package\", \"Version\", \"Repository\")) |>\n left_join(deps, by = \"Package\") |>\n arrange(Package)\n names(package_table) <- c(\"Package\", \"Version\", \"Available\", \"Depends\",\n \"Missing\")\n\n list(\n table = package_table,\n n_built = dim(package_table)[1],\n n_avail = sum(as.numeric(deps$Available))\n )\n },\n message = \"Loading package lists and crunching dependencies\",\n detail = \"This may take a little while...\",\n value = 0\n )\n\n output$built <- renderText({\n res$n_built\n })\n\n output$available <- renderText({\n res$n_avail\n })\n\n output$webr_pkgs <- renderDT(\n datatable(\n res$table,\n rownames = FALSE,\n selection = \"none\",\n options = list(\n ordering = FALSE,\n search = list(regex = TRUE),\n columns = JS(\"[\n null,\n null,\n { searchable: false, visible: false },\n { title: 'All depends available?' },\n {\n searchable: false,\n title: 'Depends<br><small>Missing dependencies are shown in bold.<\/small>'\n },\n { searchable: false, visible: false } \n ]\"),\n rowCallback=JS(\"\n function(row, data) {\n if (data[3][0]) {\n $('td:eq(2)', row).html('Yes');\n } else {\n $('td:eq(2)', row).html('<b>No<\/b>');\n }\n $('td:eq(0)', row).html(`<a target=\\\"_blank\\\" href=\\\"${data[2]}/${data[0]}_${data[1]}.tgz\\\">${data[0]}<\/a>`);\n $('td:eq(3)', row).html(data[4].map((v) => {\n if (data[5].includes(v))\n return '<b>' + v + '<\/b>';\n return v;\n }).join(', '));\n }\n \")\n )\n )\n )\n}\n\nshinyApp(ui = ui, server = server)\n","type":"text"},{"name":"dashboard.Rproj","content":"Version: 1.0\n\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 2\nEncoding: UTF-8\n\nRnwWeave: Sweave\nLaTeX: pdfLaTeX\n\nAutoAppendNewline: Yes\n","type":"text"}]