Skip to content

Commit

Permalink
test prototype app with GH pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rpodcast committed Feb 7, 2024
1 parent c425715 commit efe9cbd
Show file tree
Hide file tree
Showing 198 changed files with 410,173 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM ghcr.io/rocker-org/devcontainer/tidyverse:4.3
# key dependencies for utilities
RUN apt-get update -qq \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libxt6 curl libglpk-dev libcurl4-openssl-dev libssl-dev libxml2-dev
&& apt-get -y install --no-install-recommends libxt6 curl libglpk-dev libcurl4-openssl-dev libssl-dev libxml2-dev libarchive-dev

# install rpython and pip3 just in case
RUN apt-get update \
Expand All @@ -25,5 +25,5 @@ RUN apt-get update \

# install R package dependencies
# add / remove packages from line below (but keep httpgd, renv, languageserver
RUN install2.r renv httpgd languageserver
RUN install2.r renv httpgd languageserver shiny shinylive reactable httpuv arrow fs s3fs dplyr pointblank gt reclin2 epoxy logger purrr deps

4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile_rstudio
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM ghcr.io/rocker-org/devcontainer/tidyverse:4.3
# key dependencies for utilities
RUN apt-get update -qq \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libxt6 curl libglpk-dev libcurl4-openssl-dev libssl-dev libxml2-dev
&& apt-get -y install --no-install-recommends libxt6 curl libglpk-dev libcurl4-openssl-dev libssl-dev libxml2-dev libarchive-dev

# install rpython and pip3 just in case
RUN apt-get update \
Expand All @@ -25,5 +25,5 @@ RUN apt-get update \

# install R package dependencies
# add / remove packages from line below (but keep renv=
RUN install2.r renv
RUN install2.r renv shiny shinylive reactable httpuv arrow fs s3fs dplyr pointblank gt reclin2 epoxy logger purrr deps

13 changes: 11 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// README at: https://github.com/rocker-org/devcontainer-templates/tree/main/src/r-ver
// Change the 'name' field to suit your project
{
"name": "R-Dev-Projects (rocker/r-ver base)",
"name": "Podcast2.9-database-dashboard",
"dockerComposeFile": "docker-compose.yml",
"service": "vscode",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
Expand All @@ -13,7 +13,10 @@
"features": {
"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {},
"ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {},
"ghcr.io/guiyomh/features/vim:0": {}
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
"version": "latest"
},
},


Expand All @@ -31,10 +34,16 @@
"ionutvmi.path-autocomplete",
"hoovercj.vscode-power-mode",
"REditorSupport.r",
"REditorSupport.r-lsp",
"rdebugger.r-debugger",
"hediet.vscode-drawio",
"redhat.vscode-yaml",
"codezombiech.gitignore",
"ms-python.python",
"yzhang.markdown-all-in-one",
"ms-azuretools.vscode-docker",
"ms-vscode-remote.remote-containers",
"quarto.quarto"
],
"settings": {
"editor.wordWrap": "on",
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ services:
unless-stopped
# change local port number if needed. Keep container port (8787) the same.
ports:
- 9998:8787
- 3450:8787
env_file: .env
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.RData
.Ruserdata
.DS_Store
.Renviron

# container-specific files
.devcontainer/.rstudio_config/*
Expand Down
5 changes: 0 additions & 5 deletions .lintr

This file was deleted.

3 changes: 3 additions & 0 deletions app/R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello_world <- function() {
print("Hello World!")
}
60 changes: 60 additions & 0 deletions app/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
library(shiny)
source("R/utils.R")

# Define UI for app that draws a histogram ----
ui <- fluidPage(

# App title ----
titlePanel(hello_world()),

# Sidebar layout with input and output definitions ----
sidebarLayout(

# Sidebar panel for inputs ----
sidebarPanel(

# Input: Slider for the number of bins ----
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1,
max = 50,
value = 30)

),

# Main panel for displaying outputs ----
mainPanel(

# Output: Histogram ----
plotOutput(outputId = "distPlot")

)
)
)

# Define server logic required to draw a histogram ----
server <- function(input, output) {

# Histogram of the Old Faithful Geyser Data ----
# with requested number of bins
# This expression that generates a histogram is wrapped in a call
# to renderPlot to indicate that:
#
# 1. It is "reactive" and therefore should be automatically
# re-executed when inputs (input$bins) change
# 2. Its output type is a plot
output$distPlot <- renderPlot({

x <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)

hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")

})

}

# Create Shiny app ----
shinyApp(ui = ui, server = server)
1 change: 1 addition & 0 deletions docs/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"app.R","content":"library(shiny)\nsource(\"R/utils.R\")\n\n# Define UI for app that draws a histogram ----\nui <- fluidPage(\n\n # App title ----\n titlePanel(hello_world()),\n\n # Sidebar layout with input and output definitions ----\n sidebarLayout(\n\n # Sidebar panel for inputs ----\n sidebarPanel(\n\n # Input: Slider for the number of bins ----\n sliderInput(inputId = \"bins\",\n label = \"Number of bins:\",\n min = 1,\n max = 50,\n value = 30)\n\n ),\n\n # Main panel for displaying outputs ----\n mainPanel(\n\n # Output: Histogram ----\n plotOutput(outputId = \"distPlot\")\n\n )\n )\n)\n\n# Define server logic required to draw a histogram ----\nserver <- function(input, output) {\n\n # Histogram of the Old Faithful Geyser Data ----\n # with requested number of bins\n # This expression that generates a histogram is wrapped in a call\n # to renderPlot to indicate that:\n #\n # 1. It is \"reactive\" and therefore should be automatically\n # re-executed when inputs (input$bins) change\n # 2. Its output type is a plot\n output$distPlot <- renderPlot({\n\n x <- faithful$waiting\n bins <- seq(min(x), max(x), length.out = input$bins + 1)\n\n hist(x, breaks = bins, col = \"#75AADB\", border = \"white\",\n xlab = \"Waiting time to next eruption (in mins)\",\n main = \"Histogram of waiting times\")\n\n })\n\n}\n\n# Create Shiny app ----\nshinyApp(ui = ui, server = server)","type":"text"},{"name":"R/utils.R","content":"hello_world <- function() {\n print(\"Hello World!\")\n}","type":"text"}]
34 changes: 34 additions & 0 deletions docs/edit/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shiny examples browser</title>
<script
src="../shinylive/load-shinylive-sw.js"
type="module"
></script>
<script src="../shinylive/jquery.min.js"></script>
<script src="../shinylive/jquery.terminal/js/jquery.terminal.min.js"></script>
<link
href="../shinylive/jquery.terminal/css/jquery.terminal.min.css"
rel="stylesheet"
/>
<script type="module">
import { runApp } from "../shinylive/shinylive.js";
const response = await fetch("../app.json");
if (!response.ok) {
throw new Error("HTTP error loading app.json: " + response.status);
}
const appFiles = await response.json();

const appRoot = document.getElementById("root");
runApp(appRoot, "editor-terminal-viewer", {startFiles: appFiles}, "r");
</script>
<link rel="stylesheet" href="../shinylive/style-resets.css" />
<link rel="stylesheet" href="../shinylive/shinylive.css" />
</head>
<body>
<div style="height: 100vh; width: 100vw" id="root"></div>
</body>
</html>
28 changes: 28 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shiny App</title>
<script
src="./shinylive/load-shinylive-sw.js"
type="module"
></script>
<script type="module">
import { runApp } from "./shinylive/shinylive.js";
const response = await fetch("./app.json");
if (!response.ok) {
throw new Error("HTTP error loading app.json: " + response.status);
}
const appFiles = await response.json();

const appRoot = document.getElementById("root");
runApp(appRoot, "viewer", {startFiles: appFiles}, "r");
</script>
<link rel="stylesheet" href="./shinylive/style-resets.css" />
<link rel="stylesheet" href="./shinylive/shinylive.css" />
</head>
<body>
<div style="height: 100vh; width: 100vw" id="root"></div>
</body>
</html>
Loading

0 comments on commit efe9cbd

Please sign in to comment.