From 0f431ed3846ca91c811ab5b1a75422234ae80ff6 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Tue, 12 Aug 2014 16:36:00 -0500 Subject: [PATCH] Detect showcase mode for single-file apps --- R/app.R | 26 +------------------------- R/shinyui.R | 4 ++-- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/R/app.R b/R/app.R index 9e58247d1..956e39870 100644 --- a/R/app.R +++ b/R/app.R @@ -51,31 +51,7 @@ shinyApp <- function(ui=NULL, server=NULL, onStart=NULL, options=list(), # Ensure that the entire path is a match uiPattern <- sprintf("^%s$", uiPattern) - httpHandler <- function(req) { - if (!identical(req$REQUEST_METHOD, 'GET')) - return(NULL) - - if (!isTRUE(grepl(uiPattern, req$PATH_INFO))) - return(NULL) - - textConn <- textConnection(NULL, "w") - on.exit(close(textConn)) - - uiValue <- if (is.function(ui)) { - if (length(formals(ui)) > 0) - ui(req) - else - ui() - } else { - ui - } - if (is.null(uiValue)) - return(NULL) - - renderPage(uiValue, textConn) - html <- paste(textConnectionValue(textConn), collapse='\n') - return(httpResponse(200, content=enc2utf8(html))) - } + httpHandler <- uiHttpHandler(ui, uiPattern) serverFuncSource <- function() { server diff --git a/R/shinyui.R b/R/shinyui.R index d3323cddb..511609cc4 100644 --- a/R/shinyui.R +++ b/R/shinyui.R @@ -99,7 +99,7 @@ shinyUI <- function(ui) { ui } -uiHttpHandler <- function(ui, path = "/") { +uiHttpHandler <- function(ui, uiPattern = "^/$") { force(ui) @@ -107,7 +107,7 @@ uiHttpHandler <- function(ui, path = "/") { if (!identical(req$REQUEST_METHOD, 'GET')) return(NULL) - if (req$PATH_INFO != path) + if (!isTRUE(grepl(uiPattern, req$PATH_INFO))) return(NULL) textConn <- textConnection(NULL, "w")