#' @export p <- function(...) tags$p(...) #' @export h1 <- function(...) tags$h1(...) #' @export h2 <- function(...) tags$h2(...) #' @export h3 <- function(...) tags$h3(...) #' @export h4 <- function(...) tags$h4(...) #' @export h5 <- function(...) tags$h5(...) #' @export h6 <- function(...) tags$h6(...) #' @export a <- function(...) tags$a(...) #' @export br <- function(...) tags$br(...) #' @export div <- function(...) tags$div(...) #' @export span <- function(...) tags$span(...) #' @export pre <- function(...) tags$pre(...) #' @export code <- function(...) tags$code(...) #' @export img <- function(...) tags$img(...) #' @export strong <- function(...) tags$strong(...) #' @export em <- function(...) tags$em(...) #' Include Content From a File #' #' Include HTML, text, or rendered Markdown into a \link[=shinyUI]{Shiny UI}. #' #' These functions provide a convenient way to include an extensive amount of #' HTML, textual, Markdown, CSS, or JavaScript content, rather than using a #' large literal R string. #' #' @note \code{includeText} escapes its contents, but does no other processing. #' This means that hard breaks and multiple spaces will be rendered as they #' usually are in HTML: as a single space character. If you are looking for #' preformatted text, wrap the call with \code{\link{pre}}, or consider using #' \code{includeMarkdown} instead. #' #' @note The \code{includeMarkdown} function requires the \code{markdown} #' package. #' #' @param path The path of the file to be included. It is highly recommended to #' use a relative path (the base path being the Shiny application directory), #' not an absolute path. #' #' @rdname include #' @export includeHTML <- function(path) { dependsOnFile(path) lines <- readLines(path, warn=FALSE, encoding='UTF-8') return(HTML(paste(lines, collapse='\r\n'))) } #' @rdname include #' @export includeText <- function(path) { dependsOnFile(path) lines <- readLines(path, warn=FALSE, encoding='UTF-8') return(paste(lines, collapse='\r\n')) } #' @rdname include #' @export includeMarkdown <- function(path) { if (!require(markdown)) stop("Markdown package is not installed") dependsOnFile(path) html <- markdown::markdownToHTML(path, fragment.only=TRUE) Encoding(html) <- 'UTF-8' return(HTML(html)) } #' @param ... Any additional attributes to be applied to the generated tag. #' @rdname include #' @export includeCSS <- function(path, ...) { dependsOnFile(path) lines <- readLines(path, warn=FALSE, encoding='UTF-8') args <- list(...) if (is.null(args$type)) args$type <- 'text/css' return(do.call(tags$style, c(list(HTML(paste(lines, collapse='\r\n'))), args))) } #' @rdname include #' @export includeScript <- function(path, ...) { dependsOnFile(path) lines <- readLines(path, warn=FALSE, encoding='UTF-8') return(tags$script(HTML(paste(lines, collapse='\r\n')), ...)) } #' Include Content Only Once #' #' Use \code{singleton} to wrap contents (tag, text, HTML, or lists) that should #' be included in the generated document only once, yet may appear in the #' document-generating code more than once. Only the first appearance of the #' content (in document order) will be used. Useful for custom components that #' have JavaScript files or stylesheets. #' #' @param x A \code{\link{tag}}, text, \code{\link{HTML}}, or list. #' #' @export singleton <- function(x) { class(x) <- c(class(x), 'shiny.singleton') return(x) } # Writes the portion of the showcase header that lives inside the
tag to # the connection. writeShowcaseHead <- function(connection) { writeLines(c(' ', ' ', ' ', ' ', ' ', ' '), con = connection) } # Writes the showcase preamble (the UI drawn above the application to be # showcased) to the connection. writeShowcasePreamble <- function(connection) { writeLines(c('',
readLines(file.path.ci(getwd(), 'ui.R')),
'',
readLines(file.path.ci(getwd(), 'server.R')),
'