## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  eval = FALSE
)

## -----------------------------------------------------------------------------
# library(shiny)
# library(brochure)

## -----------------------------------------------------------------------------
# home <- function() {
#   page(
#     href = "/",
#     ui = tagList(
#       h1("Home"),
#       plotOutput("plot")
#     ),
#     server = function(input, output, session) {
#       output$plot <- renderPlot(plot(mtcars))
#     }
#   )
# }
# 
# contact <- function() {
#   page(
#     href = "/contact",
#     ui = tagList(
#       h1("Contact"),
#       tags$p("here@example.com")
#     )
#   )
# }

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   contact()
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   tags$head(
#     tags$link(rel = "stylesheet", href = "/www/custom.css"),
#     tags$link(rel = "icon", href = "/www/favicon.ico")
#   ),
#   home(),
#   contact()
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   contact(),
#   wrapped = fluidPage
# )

## -----------------------------------------------------------------------------
# with_nav <- function(ui) {
#   fluidPage(
#     tags$nav(
#       tags$a(href = "/", "Home"),
#       tags$a(href = "/contact", "Contact")
#     ),
#     ui
#   )
# }
# 
# brochureApp(home(), contact(), wrapped = with_nav)

## -----------------------------------------------------------------------------
# brochureApp(
#   page(href = "/who/me", ui = tagList(h1("It's you"))),
#   page(href = "/who/:id", ui = tagList(h1("Someone else")))
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   contact(),
#   content_404 = tagList(
#     h1("This page does not exist"),
#     tags$a(href = "/", "Back home")
#   )
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   page(
#     href = "/who/:id",
#     ui = function(request) {
#       tagList(
#         h1(sprintf("Hello %s", get_keys(request)$id)),
#         verbatimTextOutput("from_server")
#       )
#     },
#     server = function(input, output, session) {
#       output$from_server <- renderText(get_keys()$id)
#     }
#   )
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   redirect(from = "/index.html", to = "/")
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   page(
#     href = "/healthcheck",
#     ui = tagList(),
#     req_handlers = list(
#       ~ shiny::httpResponse(200, content = "OK")
#     )
#   )
# )

## -----------------------------------------------------------------------------
# page(
#   href = "/login",
#   ui = tagList(h1("Logged in")),
#   res_handlers = list(
#     ~ set_cookie(.x, "SESSION", "abc123")
#   )
# )

## -----------------------------------------------------------------------------
# brochureApp(
#   home(),
#   basepath = "myapp"
# )

